From 2ff6c9e8d89590c8180769bd54e545f40ca9a56f Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 7 Sep 2009 10:12:47 +0200 Subject: Please welcome the Lighthouse Research Project! Lighthouse is a lighter, nimbler version of Qt/Embedded, which does not contain a window system. Instead, it uses graphics system plugins to provide the necessary functionality or interface with existing window systems. The first version was written by Rhys. Squashed commit. --- configure | 138 +- src/corelib/global/qglobal.cpp | 11 +- src/corelib/global/qglobal.h | 8 +- src/corelib/global/qnamespace.h | 2 +- src/corelib/io/qsettings.cpp | 2 +- src/corelib/io/qsettings_p.h | 2 +- src/gui/accessible/accessible.pri | 2 +- src/gui/dialogs/dialogs.pri | 4 +- src/gui/egl/egl.pri | 10 +- src/gui/egl/qegl_lite.cpp | 105 ++ src/gui/embedded/qkbd_qws.cpp | 23 +- src/gui/gui.pro | 2 +- src/gui/image/image.pri | 5 +- src/gui/image/qpixmap_lite.cpp | 52 + src/gui/image/qpixmapdatafactory.cpp | 5 + src/gui/inputmethod/inputmethod.pri | 2 +- src/gui/kernel/kernel.pri | 20 +- src/gui/kernel/qapplication.cpp | 2 + src/gui/kernel/qapplication_lite.cpp | 624 +++++++ src/gui/kernel/qapplication_p.h | 6 + src/gui/kernel/qclipboard_lite.cpp | 163 ++ src/gui/kernel/qcursor.h | 2 +- src/gui/kernel/qcursor_lite.cpp | 127 ++ src/gui/kernel/qcursor_p.h | 2 +- src/gui/kernel/qdesktopwidget_lite.cpp | 141 ++ src/gui/kernel/qdnd_p.h | 2 +- src/gui/kernel/qgenericplugin_lite.cpp | 112 ++ src/gui/kernel/qgenericplugin_lite.h | 84 + src/gui/kernel/qgenericpluginfactory_lite.cpp | 115 ++ src/gui/kernel/qgenericpluginfactory_lite.h | 67 + src/gui/kernel/qsound_lite.cpp | 74 + src/gui/kernel/qwidget.cpp | 2 +- src/gui/kernel/qwidget_lite.cpp | 616 +++++++ src/gui/kernel/qwidget_p.h | 6 + src/gui/kernel/qwindowdefs.h | 6 + src/gui/painting/painting.pri | 16 +- src/gui/painting/qbackingstore.cpp | 9 +- src/gui/painting/qcolormap_lite.cpp | 235 +++ src/gui/painting/qgraphicssystem.cpp | 18 + src/gui/painting/qgraphicssystem_p.h | 14 + src/gui/painting/qpaintdevice.cpp | 2 + src/gui/painting/qpaintdevice_lite.cpp | 68 + src/gui/painting/qpaintengine.h | 3 + src/gui/painting/qregion.cpp | 4 +- src/gui/painting/qregion.h | 6 +- src/gui/painting/qwindowsurface.cpp | 31 + src/gui/painting/qwindowsurface_p.h | 5 + src/gui/styles/styles.pri | 2 +- src/gui/text/qfont.cpp | 4 + src/gui/text/qfont.h | 4 +- src/gui/text/qfontdatabase.cpp | 42 +- src/gui/text/qfontdatabase.h | 2 +- src/gui/text/qfontdatabase_qws.cpp | 8 + src/gui/text/qfontengine.cpp | 4 +- src/gui/text/qfontengine_ft_p.h | 2 +- src/gui/text/qfontengine_p.h | 2 +- src/gui/text/text.pri | 15 +- src/gui/util/qdesktopservices.cpp | 2 +- src/gui/util/util.pri | 4 +- src/gui/widgets/qlinecontrol.cpp | 4 +- src/gui/widgets/widgets.pri | 2 +- src/plugins/generic/linuxinput/linuxinput.pro | 18 + src/plugins/generic/linuxinput/main.cpp | 80 + src/plugins/generic/linuxinput/qlinuxinput.cpp | 371 ++++ src/plugins/generic/linuxinput/qlinuxinput.h | 101 ++ src/plugins/graphicssystems/graphicssystems.pro | 16 +- src/plugins/graphicssystems/linuxfb/linuxfb.pro | 10 + src/plugins/graphicssystems/linuxfb/main.cpp | 71 + .../linuxfb/qgraphicssystem_linuxfb.cpp | 797 ++++++++ .../linuxfb/qgraphicssystem_linuxfb.h | 130 ++ .../linuxfb/qwindowsurface_linuxfb.cpp | 114 ++ .../linuxfb/qwindowsurface_linuxfb.h | 73 + src/plugins/graphicssystems/minimal/main.cpp | 71 + src/plugins/graphicssystems/minimal/minimal.pro | 10 + .../minimal/qgraphicssystem_minimal.cpp | 70 + .../minimal/qgraphicssystem_minimal.h | 85 + .../minimal/qwindowsurface_minimal.cpp | 101 ++ .../minimal/qwindowsurface_minimal.h | 73 + src/plugins/graphicssystems/openvglite/main.cpp | 71 + .../graphicssystems/openvglite/openvglite.pro | 12 + .../openvglite/qgraphicssystem_vglite.cpp | 193 ++ .../openvglite/qgraphicssystem_vglite.h | 93 + .../openvglite/qwindowsurface_vglite.cpp | 131 ++ .../openvglite/qwindowsurface_vglite.h | 91 + src/plugins/graphicssystems/testlite/main.cpp | 71 + .../testlite/qgraphicssystem_testlite.cpp | 80 + .../testlite/qgraphicssystem_testlite.h | 89 + .../testlite/qwindowsurface_testlite.cpp | 528 ++++++ .../testlite/qwindowsurface_testlite.h | 88 + src/plugins/graphicssystems/testlite/testlite.pro | 17 + src/plugins/graphicssystems/testlite/x11util.cpp | 684 +++++++ src/plugins/graphicssystems/testlite/x11util.h | 126 ++ src/plugins/graphicssystems/vnc/main.cpp | 72 + .../graphicssystems/vnc/qgraphicssystem_vnc.cpp | 109 ++ .../graphicssystems/vnc/qgraphicssystem_vnc.h | 105 ++ src/plugins/graphicssystems/vnc/qvncserver.cpp | 1912 ++++++++++++++++++++ src/plugins/graphicssystems/vnc/qvncserver.h | 524 ++++++ .../graphicssystems/vnc/qwindowsurface_vnc.cpp | 106 ++ .../graphicssystems/vnc/qwindowsurface_vnc.h | 77 + src/plugins/graphicssystems/vnc/vnc.pro | 16 + tools/tools.pro | 2 +- 101 files changed, 10339 insertions(+), 101 deletions(-) create mode 100644 src/gui/egl/qegl_lite.cpp create mode 100644 src/gui/image/qpixmap_lite.cpp create mode 100644 src/gui/kernel/qapplication_lite.cpp create mode 100644 src/gui/kernel/qclipboard_lite.cpp create mode 100644 src/gui/kernel/qcursor_lite.cpp create mode 100644 src/gui/kernel/qdesktopwidget_lite.cpp create mode 100644 src/gui/kernel/qgenericplugin_lite.cpp create mode 100644 src/gui/kernel/qgenericplugin_lite.h create mode 100644 src/gui/kernel/qgenericpluginfactory_lite.cpp create mode 100644 src/gui/kernel/qgenericpluginfactory_lite.h create mode 100644 src/gui/kernel/qsound_lite.cpp create mode 100644 src/gui/kernel/qwidget_lite.cpp create mode 100644 src/gui/painting/qcolormap_lite.cpp create mode 100644 src/gui/painting/qpaintdevice_lite.cpp create mode 100644 src/plugins/generic/linuxinput/linuxinput.pro create mode 100644 src/plugins/generic/linuxinput/main.cpp create mode 100644 src/plugins/generic/linuxinput/qlinuxinput.cpp create mode 100644 src/plugins/generic/linuxinput/qlinuxinput.h create mode 100644 src/plugins/graphicssystems/linuxfb/linuxfb.pro create mode 100644 src/plugins/graphicssystems/linuxfb/main.cpp create mode 100644 src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp create mode 100644 src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h create mode 100644 src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp create mode 100644 src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h create mode 100644 src/plugins/graphicssystems/minimal/main.cpp create mode 100644 src/plugins/graphicssystems/minimal/minimal.pro create mode 100644 src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp create mode 100644 src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h create mode 100644 src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp create mode 100644 src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h create mode 100644 src/plugins/graphicssystems/openvglite/main.cpp create mode 100644 src/plugins/graphicssystems/openvglite/openvglite.pro create mode 100644 src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp create mode 100644 src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h create mode 100644 src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp create mode 100644 src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h create mode 100644 src/plugins/graphicssystems/testlite/main.cpp create mode 100644 src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp create mode 100644 src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h create mode 100644 src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp create mode 100644 src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h create mode 100644 src/plugins/graphicssystems/testlite/testlite.pro create mode 100644 src/plugins/graphicssystems/testlite/x11util.cpp create mode 100644 src/plugins/graphicssystems/testlite/x11util.h create mode 100644 src/plugins/graphicssystems/vnc/main.cpp create mode 100644 src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp create mode 100644 src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h create mode 100644 src/plugins/graphicssystems/vnc/qvncserver.cpp create mode 100644 src/plugins/graphicssystems/vnc/qvncserver.h create mode 100644 src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp create mode 100644 src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h create mode 100644 src/plugins/graphicssystems/vnc/vnc.pro diff --git a/configure b/configure index 70c91c2..332b739 100755 --- a/configure +++ b/configure @@ -166,9 +166,12 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown PLATFORM_X11=no PLATFORM_MAC=no -PLATFORM_QWS=no +PLATFORM_QWS=maybe +PLATFORM_EMBLITE=no +BUILD_ON_MAC=no; +[ -d /System/Library/Frameworks/Carbon.framework ] && BUILD_ON_MAC=yes -if [ -f "$relpath"/src/gui/kernel/qapplication_mac.mm ] && [ -d /System/Library/Frameworks/Carbon.framework ]; then +if [ -f "$relpath"/src/gui/kernel/qapplication_mac.mm ] && [ $BUILD_ON_MAC = "yes" ]; then # Qt/Mac # ~ the Carbon SDK exists # ~ src/gui/base/qapplication_mac.cpp is present @@ -262,6 +265,16 @@ earlyArgParse() VAL=$1 fi ;; + -embedded-lite) + VAR=embedded-lite + # this option may or may not be followed by an argument + if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then + VAL=auto + else + shift; + VAL=$1 + fi + ;; -h|help|--help|-help) if [ "$VAL" = "yes" ]; then OPT_HELP="$VAL" @@ -298,12 +311,27 @@ earlyArgParse() PLATFORM_X11=no PLATFORM_MAC=no PLATFORM_QWS=yes + PLATFORM_EMBLITE=no fi else echo "No license exists to enable Qt for Embedded Linux. Disabling." CFG_EMBEDDED=no fi ;; + embedded-lite) + CFG_EMBEDDED="$VAL" + if [ "$PLATFORM_QWS" != "no" ]; then + if [ "$PLATFORM_QWS" = "maybe" ]; then + PLATFORM_X11=no + PLATFORM_MAC=no + PLATFORM_QWS=no + PLATFORM_EMBLITE=yes + fi + else + echo "No license exists to enable Qt for Embedded Linux Lite. Disabling." + CFG_EMBEDDED=no + fi + ;; developer-build) CFG_DEV="yes" ;; @@ -363,6 +391,7 @@ elif [ $COMMERCIAL_USER = "yes" ]; then # one of commercial editions [ "$PLATFORM_MAC" = "maybe" ] && PLATFORM_MAC=yes [ "$PLATFORM_QWS" = "maybe" ] && PLATFORM_QWS=yes + [ "$PLATFORM_EMBLITE" = "maybe" ] && PLATFORM_EMBLITE=yes # read in the license file if [ -f "$LICENSE_FILE" ]; then @@ -450,7 +479,7 @@ elif [ $COMMERCIAL_USER = "yes" ]; then if [ "$PlatformCode" = "X" ]; then # Qt All-OS LICENSE_EXTENSION="-ALLOS" - elif [ "$PLATFORM_QWS" = "yes" ]; then + elif [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then case $PlatformCode in 2|4|8|A|B|E|G|J|K|P|Q|S|U|V|W) # Qt for Embedded Linux @@ -917,7 +946,7 @@ while [ "$#" -gt 0 ]; do ;; #Qt style options that pass an argument -qconfig) - if [ "$PLATFORM_QWS" != "yes" ]; then + if [ "$PLATFORM_QWS" != "yes" -a "$PLATFORM_EMBLITE" != "yes" ]; then echo echo "WARNING: -qconfig is only tested and supported on Qt for Embedded Linux." echo @@ -957,6 +986,16 @@ while [ "$#" -gt 0 ]; do VAL=$1 fi ;; + -embedded-lite) + VAR=embedded-lite + # this option may or may not be followed by an argument + if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then + VAL=auto + else + shift; + VAL=$1 + fi + ;; -opengl) VAR=opengl # this option may or may not be followed by an argument @@ -1171,12 +1210,27 @@ while [ "$#" -gt 0 ]; do PLATFORM_X11=no PLATFORM_MAC=no PLATFORM_QWS=yes + PLATFORM_EMBLITE=no fi else echo "No license exists to enable Qt for Embedded Linux. Disabling." CFG_EMBEDDED=no fi ;; + embedded-lite) + CFG_EMBEDDED="$VAL" + if [ "$PLATFORM_EMBLITE" != "no" ]; then + if [ "$PLATFORM_EMBLITE" = "maybe" ]; then + PLATFORM_X11=no + PLATFORM_MAC=no + PLATFORM_QWS=no + PLATFORM_EMBLITE=yes + fi + else + echo "No license exists to enable Qt for Embedded Linux Lite. Disabling." + CFG_EMBEDDED=no + fi + ;; sse) if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then CFG_SSE="$VAL" @@ -1273,6 +1327,8 @@ while [ "$#" -gt 0 ]; do PLATFORM_MAC=no elif [ "$PLATFORM_QWS" = "yes" ]; then PLATFORM_QWS=no + elif [ "$PLATFORM_EMBLITE" = "yes" ]; then + PLATFORM_EMBLITE=no fi if [ "$CFG_FRAMEWORK" = "auto" ]; then CFG_FRAMEWORK=no @@ -1469,7 +1525,7 @@ while [ "$#" -gt 0 ]; do fi ;; feature-*) - if [ "$PLATFORM_QWS" = "yes" ]; then + if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then FEATURE=`echo $VAR | sed "s,^[^-]*-\([^-]*\),\1," | tr 'abcdefghijklmnopqrstuvwxyz-' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` if [ "$VAL" = "no" ]; then QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_$FEATURE" @@ -2140,7 +2196,7 @@ if [ "$OPT_SHADOW" = "yes" ]; then [ "$OPT_VERBOSE" = "yes" ] && echo "Performing shadow build..." fi -if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" ] && [ "$CFG_DEBUG_RELEASE" = "yes" ]; then +if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ] && [ "$CFG_DEBUG_RELEASE" = "yes" ]; then echo echo "WARNING: -debug-and-release is not supported anymore on Qt/X11 and Qt for Embedded Linux" echo "By default, Qt is built in release mode with separate debug information, so" @@ -2243,7 +2299,7 @@ if [ "$CFG_DEV" = "yes" ]; then fi # symlink fonts to be able to run application from build directory -if [ "$PLATFORM_QWS" = "yes" ] && [ ! -e "${outpath}/lib/fonts" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ] && [ ! -e "${outpath}/lib/fonts" ]; then if [ "$PLATFORM" = "$XPLATFORM" ]; then mkdir -p "${outpath}/lib" ln -s "${relpath}/lib/fonts" "${outpath}/lib/fonts" @@ -2283,6 +2339,7 @@ fi ### help #------------------------------------------------------------------------------- [ "$PLATFORM_QWS" = "yes" -a "$CFG_EMBEDDED" = "no" ] && CFG_EMBEDDED=auto +[ "$PLATFORM_EMBLITE" = "yes" -a "$CFG_EMBEDDED" = "no" ] && CFG_EMBEDDED=auto if [ "$CFG_EMBEDDED" != "no" ]; then case "$UNAME_SYSTEM:$UNAME_RELEASE" in Darwin:*) @@ -2361,6 +2418,7 @@ if [ "$CFG_EMBEDDED" != "no" ]; then echo "Qt for Embedded Linux is not supported on this platform. Disabling." CFG_EMBEDDED=no PLATFORM_QWS=no + PLATFORM_EMBLITE=no ;; esac fi @@ -2525,7 +2583,7 @@ if [ -z "$PLATFORM" ]; then esac fi -if [ "$PLATFORM_QWS" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then CFG_SM=no PLATFORMS=`find "$relpath/mkspecs/qws" | sed "s,$relpath/mkspecs/qws/,,"` else @@ -2809,7 +2867,7 @@ fi if [ "$OPT_VERBOSE" = "yes" ]; then echo "System architecture: '$CFG_ARCH'" - if [ "$PLATFORM_QWS" = "yes" ]; then + if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then echo "Host architecture: '$CFG_HOST_ARCH'" fi fi @@ -2988,7 +3046,7 @@ if [ "$CFG_USE_GNUMAKE" = "auto" ] && "$MAKE" -v | grep "GNU Make" >/dev/null 2> fi # If -opengl wasn't specified, don't try to auto-detect -if [ "$PLATFORM_QWS" = "yes" ] && [ "$CFG_OPENGL" = "auto" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ] && [ "$CFG_OPENGL" = "auto" ]; then CFG_OPENGL=no fi @@ -3043,7 +3101,7 @@ fi if [ -z "$QT_INSTALL_PREFIX" ]; then if [ "$CFG_DEV" = "yes" ]; then QT_INSTALL_PREFIX="$outpath" # In Development, we use sandboxed builds by default - elif [ "$PLATFORM_QWS" = "yes" ]; then + elif [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then QT_INSTALL_PREFIX="/usr/local/Trolltech/QtEmbedded-${QT_VERSION}" if [ "$PLATFORM" != "$XPLATFORM" ]; then QT_INSTALL_PREFIX="${QT_INSTALL_PREFIX}-${CFG_ARCH}" @@ -3248,7 +3306,7 @@ Installation options: -prefix ...... This will install everything relative to (default $QT_INSTALL_PREFIX) EOF -if [ "$PLATFORM_QWS" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then cat <: arm mips x86 generic + -embedded-lite This will enable the embedded lite build, you must + have a proper license for this switch to work. + Example values for : arm mips x86 generic + Qt/Embedded Lite does not use QWS. + -armfpa ............. Target platform is uses the ARM-FPA floating point format. -no-armfpa .......... Target platform does not use the ARM-FPA floating point format. @@ -3829,7 +3892,7 @@ EOF fi -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_X11" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" -o "$PLATFORM_X11" = "yes" ]; then if [ "$CFG_GLIB" = "no" ]; then GBY=" " GBN="+" @@ -3853,7 +3916,7 @@ fi # Help # LICENSING, INTERACTIVE PART # ----------------------------------------------------------------------------- -if [ "$PLATFORM_QWS" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then Platform="Qt for Embedded Linux" elif [ "$PLATFORM_MAC" = "yes" ]; then Platform="Qt/Mac" @@ -4298,7 +4361,7 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ]; EXTRA_LFLAGS="\$(QMAKE_RPATH)\"$rpath\" $EXTRA_LFLAGS" done fi - if [ "$PLATFORM_MAC" = "yes" ]; then + if [ "$BUILD_ON_MAC" = "yes" ]; then echo "export MACOSX_DEPLOYMENT_TARGET = 10.4" >> "$mkfile" echo "CARBON_LFLAGS =-framework ApplicationServices" >>"$mkfile" echo "CARBON_CFLAGS =-fconstant-cfstrings" >>"$mkfile" @@ -4801,7 +4864,7 @@ fi # auto-detect iconv(3) support if [ "$CFG_ICONV" != "no" ]; then - if [ "$PLATFORM_QWS" = "yes" ]; then + if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then CFG_ICONV=no elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/iconv" "POSIX iconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_ICONV=yes @@ -4852,7 +4915,7 @@ if [ "$PLATFORM_MAC" = "yes" -a ! -z "$QT_NAMESPACE" ]; then QT_NAMESPACE_MAC_CRC=`"$mactests/crc.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/mac/crc $QT_NAMESPACE $L_FLAGS $I_FLAGS $l_FLAGS` fi -if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" ]; then +if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then # detect EGL support if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/egl" "EGL (EGL/egl.h)" $L_FLAGS $I_FLAGS $l_FLAGS; then @@ -5314,7 +5377,7 @@ if [ "$PLATFORM_MAC" = "yes" ]; then fi # QWS -if [ "$PLATFORM_QWS" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then # auto-detect OpenGL support (es1 = OpenGL ES 1.x Common, es1cl = ES 1.x common lite, es2 = OpenGL ES 2.x) if [ "$CFG_OPENGL" = "yes" ]; then @@ -5504,7 +5567,7 @@ fi if [ "$CFG_DOUBLEFORMAT" = "auto" ]; then - if [ "$PLATFORM_QWS" != "yes" ]; then + if [ "$PLATFORM_QWS" != "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then CFG_DOUBLEFORMAT=normal else "$unixtests/doubleformat.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" @@ -5772,7 +5835,12 @@ fi #------------------------------------------------------------------------------- ### fix this: user input should be validated in a loop -if [ "$CFG_QWS_DEPTHS" = "prompted" -a "$PLATFORM_QWS" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then + PROMPT_FOR_DEPTHS="yes" +else + PROMPT_FOR_DEPTHS="no" +fi +if [ "$CFG_QWS_DEPTHS" = "prompted" -a "$PROMPT_FOR_DEPTHS" = "yes" ]; then echo echo "Choose pixel-depths to support:" echo @@ -5931,7 +5999,7 @@ else fi if [ "$CFG_OPENGL" = "es1" ] || [ "$CFG_OPENGL" = "es1cl" ] || [ "$CFG_OPENGL" = "es2" ]; then - if [ "$PLATFORM_QWS" = "yes" ]; then + if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then QCONFIG_FLAGS="$QCONFIG_FLAGS Q_BACKINGSTORE_SUBSURFACES" QCONFIG_FLAGS="$QCONFIG_FLAGS Q_USE_EGLWINDOWSURFACE" fi @@ -5979,6 +6047,12 @@ if [ "$PLATFORM_QWS" = "yes" ]; then QT_CONFIG="$QT_CONFIG embedded" rm -f "src/.moc/$QMAKE_OUTDIR/allmoc.cpp" # needs remaking if config changes fi +if [ "$PLATFORM_EMBLITE" = "yes" ]; then + QMAKE_OUTDIR="${QMAKE_OUTDIR}-emb-$CFG_EMBEDDED" + QMAKE_CONFIG="$QMAKE_CONFIG embedded_lite" + QT_CONFIG="$QT_CONFIG embedded_lite" + rm -f "src/.moc/$QMAKE_OUTDIR/allmoc.cpp" # needs remaking if config changes +fi QMakeVar set PRECOMPILED_DIR ".pch/$QMAKE_OUTDIR" QMakeVar set OBJECTS_DIR ".obj/$QMAKE_OUTDIR" QMakeVar set MOC_DIR ".moc/$QMAKE_OUTDIR" @@ -6200,7 +6274,7 @@ if [ '!' -z "$I_FLAGS" ]; then fi # turn off exceptions for the compilers that support it -if [ "$PLATFORM_QWS" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then COMPILER=`echo $XPLATFORM | cut -f 3- -d-` else COMPILER=`echo $PLATFORM | cut -f 2- -d-` @@ -6208,6 +6282,9 @@ fi if [ "$CFG_EXCEPTIONS" = "unspecified" -a "$PLATFORM_QWS" = "yes" ]; then CFG_EXCEPTIONS=no fi +if [ "$CFG_EXCEPTIONS" = "unspecified" -a "$PLATFORM_EMBLITE" = "yes" ]; then + CFG_EXCEPTIONS=no +fi if [ "$CFG_EXCEPTIONS" != "no" ]; then QTCONFIG_CONFIG="$QTCONFIG_CONFIG exceptions" @@ -6537,7 +6614,7 @@ esac # ipv6 # # X11 : x11sm xinerama xcursor xfixes xrandr xrender mitshm fontconfig xkb -# Embedded: embedded freetype +# Embedded: embedded embedded_lite freetype # ALL_OPTIONS= BUILD_CONFIG= @@ -6834,6 +6911,11 @@ if [ "$PLATFORM_QWS" = "yes" ]; then done fi # QWS +if [ "$PLATFORM_EMBLITE" = "yes" ]; then + # Add LITE to config.h + QCONFIG_FLAGS="$QCONFIG_FLAGS Q_WS_LITE QT_NO_QWS_QPF QT_NO_QWS_QPF2" +fi + if [ "${CFG_USE_FLOATMATH}" = "yes" ]; then QCONFIG_FLAGS="${QCONFIG_FLAGS} QT_USE_MATH_H_FLOATS" fi @@ -7221,7 +7303,7 @@ else echo "Architecture: $CFG_ARCH" fi -if [ "$PLATFORM_QWS" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then echo "Host architecture: $CFG_HOST_ARCH" fi @@ -7320,7 +7402,7 @@ else fi echo "zlib support ........ $CFG_ZLIB" echo "Session management .. $CFG_SM" -if [ "$PLATFORM_QWS" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then echo "Embedded support .... $CFG_EMBEDDED" if [ "$CFG_QWS_FREETYPE" = "auto" ]; then echo "Freetype2 support ... $CFG_QWS_FREETYPE ($CFG_LIBFREETYPE)" diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 787eba7..d29cd5f 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1227,7 +1227,16 @@ bool qSharedBuild() Defined on Qt for Embedded Linux. - \sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11 + \sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11, Q_WS_LITE +*/ + +/*! + \macro Q_WS_LITE + \relates + + Defined on Qt for Embedded Linux, Lite version. + + \sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11, Q_WS_QWS */ /*! diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index a2c532f..158fa53 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -284,7 +284,7 @@ namespace QT_NAMESPACE {} # endif #endif -#if defined(Q_OS_MAC64) && !defined(QT_MAC_USE_COCOA) && !defined(QT_BUILD_QMAKE) +#if defined(Q_WS_MAC64) && !defined(QT_MAC_USE_COCOA) && !defined(QT_BUILD_QMAKE) #error "You are building a 64-bit application, but using a 32-bit version of Qt. Check your build configuration." #endif @@ -799,7 +799,7 @@ namespace QT_NAMESPACE {} # define Q_WS_PM # error "Qt does not work with OS/2 Presentation Manager or Workplace Shell" #elif defined(Q_OS_UNIX) -# if defined(Q_OS_MAC) && !defined(__USE_WS_X11__) && !defined(Q_WS_QWS) +# if defined(Q_OS_MAC) && !defined(__USE_WS_X11__) && !defined(Q_WS_QWS) && !defined(Q_WS_LITE) # define Q_WS_MAC # define Q_WS_MACX # if defined(Q_OS_MAC64) @@ -811,7 +811,7 @@ namespace QT_NAMESPACE {} # if (defined(__SERIES60_31__) || defined(__S60_32__) || defined(__S60_50__)) && !defined(QT_NO_S60) # define Q_WS_S60 # endif -# elif !defined(Q_WS_QWS) +# elif !defined(Q_WS_QWS) && !defined(Q_WS_LITE) # define Q_WS_X11 # endif #endif @@ -1056,7 +1056,7 @@ redefine to built-in booleans to make autotests work properly */ typedef int QNoImplicitBoolCast; -#if defined(QT_ARCH_ARM) || defined(QT_ARCH_ARMV6) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_MIPS) && (defined(Q_WS_QWS) || defined(Q_OS_WINCE))) || defined(QT_ARCH_SH) || defined(QT_ARCH_SH4A) +#if defined(QT_ARCH_ARM) || defined(QT_ARCH_ARMV6) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_MIPS) && (defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_WINCE))) || defined(QT_ARCH_SH) || defined(QT_ARCH_SH4A) #define QT_NO_FPU #endif diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 8f34e30..c37122c 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1537,7 +1537,7 @@ public: typedef void *HANDLE; #elif defined(Q_WS_X11) typedef unsigned long HANDLE; -#elif defined(Q_WS_QWS) +#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) typedef void * HANDLE; #elif defined(Q_OS_SYMBIAN) typedef unsigned long int HANDLE; // equivalent to TUint32 diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 48671ba..94aad7a 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1133,7 +1133,7 @@ static QString getPath(QSettings::Format format, QSettings::Scope scope) if (env == 0) { userPath = homePath; userPath += QLatin1Char('/'); -#ifdef Q_WS_QWS +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) userPath += QLatin1String("Settings"); #else userPath += QLatin1String(".config"); diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h index dc1beb3..3dff0e3 100644 --- a/src/corelib/io/qsettings_p.h +++ b/src/corelib/io/qsettings_p.h @@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE -#if defined(Q_WS_QWS) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) #define QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER #endif diff --git a/src/gui/accessible/accessible.pri b/src/gui/accessible/accessible.pri index ad2fb4c..afa5ecd 100644 --- a/src/gui/accessible/accessible.pri +++ b/src/gui/accessible/accessible.pri @@ -12,7 +12,7 @@ contains(QT_CONFIG, accessibility) { accessible/qaccessiblewidget.cpp \ accessible/qaccessibleplugin.cpp - mac:!embedded { + mac:!embedded:!embedded_lite { HEADERS += accessible/qaccessible_mac_p.h OBJECTIVE_SOURCES += accessible/qaccessible_mac.mm \ accessible/qaccessible_mac_cocoa.mm diff --git a/src/gui/dialogs/dialogs.pri b/src/gui/dialogs/dialogs.pri index b9fad41..08584a9 100644 --- a/src/gui/dialogs/dialogs.pri +++ b/src/gui/dialogs/dialogs.pri @@ -27,7 +27,7 @@ HEADERS += \ dialogs/qwizard.h \ dialogs/qprintpreviewdialog.h -!embedded:mac { +!embedded:!embedded_lite:mac { OBJECTIVE_SOURCES += dialogs/qcolordialog_mac.mm \ dialogs/qfiledialog_mac.mm \ dialogs/qfontdialog_mac.mm \ @@ -46,7 +46,7 @@ win32 { !win32-borland:!wince*: LIBS += -lshell32 # the filedialog needs this library } -!mac:!embedded:!symbian:unix { +!mac:!embedded:!symbian:unix|embedded_lite { HEADERS += dialogs/qpagesetupdialog_unix_p.h SOURCES += dialogs/qprintdialog_unix.cpp \ dialogs/qpagesetupdialog_unix.cpp diff --git a/src/gui/egl/egl.pri b/src/gui/egl/egl.pri index 75a3d91..9ba7017 100644 --- a/src/gui/egl/egl.pri +++ b/src/gui/egl/egl.pri @@ -12,10 +12,14 @@ unix { embedded { SOURCES += egl/qegl_qws.cpp } else { - symbian { - SOURCES += egl/qegl_symbian.cpp + embedded_lite { + SOURCES += egl/qegl_lite.cpp } else { - SOURCES += egl/qegl_x11.cpp + symbian { + SOURCES += egl/qegl_symbian.cpp + } else { + SOURCES += egl/qegl_x11.cpp + } } } } diff --git a/src/gui/egl/qegl_lite.cpp b/src/gui/egl/qegl_lite.cpp new file mode 100644 index 0000000..784b252 --- /dev/null +++ b/src/gui/egl/qegl_lite.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 +#include +#include +#include "qegl_p.h" + +#if !defined(QT_NO_EGL) + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +bool QEglContext::createSurface(QPaintDevice *device, const QEglProperties *properties) +{ + Q_UNUSED(device); + Q_UNUSED(properties); + return false; +} + +EGLDisplay QEglContext::getDisplay(QPaintDevice *device) +{ + Q_UNUSED(device); + return eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY)); +} + +static QGraphicsSystemScreen *screenForDevice(QPaintDevice *device) +{ + QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); + if (!gs) + return 0; + + QList screens = gs->screens(); + + int screenNumber; + if (device && device->devType() == QInternal::Widget) + screenNumber = qApp->desktop()->screenNumber(static_cast(device)); + else + screenNumber = 0; + if (screenNumber < 0 || screenNumber >= screens.size()) + return 0; + return screens[screenNumber]; +} + +// Set pixel format and other properties based on a paint device. +void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev) +{ + if (!dev) + return; + + // Find the QGLScreen for this paint device. + QGraphicsSystemScreen *screen = screenForDevice(dev); + if (!screen) + return; + int devType = dev->devType(); + if (devType == QInternal::Image) + setPixelFormat(static_cast(dev)->format()); + else + setPixelFormat(screen->format()); +} + +QT_END_NAMESPACE + +#endif // !QT_NO_EGL diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp index 4d97ba7..9a496ac 100644 --- a/src/gui/embedded/qkbd_qws.cpp +++ b/src/gui/embedded/qkbd_qws.cpp @@ -48,8 +48,16 @@ #include #include +#ifdef Q_WS_QWS #include "qwindowsystem_qws.h" #include "qscreen_qws.h" +#endif + +#ifdef Q_WS_LITE +#include +#include +#endif + #include "qtimer.h" #include @@ -352,7 +360,16 @@ QWSKeyboardHandler::~QWSKeyboardHandler() void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat) { +#if defined(Q_WS_QWS) qwsServer->processKeyEvent(unicode, keycode, modifiers, isPress, autoRepeat); +#elif defined(Q_WS_LITE) + QEvent::Type type = isPress ? QEvent::KeyPress : QEvent::KeyRelease; + QString str; + if (unicode != 0xffff) + str = QString(unicode); + QKeyEvent ke(type, keycode, modifiers, str); + QApplicationPrivate::handleKeyEvent(0, &ke); +#endif } /*! @@ -375,6 +392,7 @@ void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardM */ int QWSKeyboardHandler::transformDirKey(int key) { +#ifdef Q_WS_QWS static int dir_keyrot = -1; if (dir_keyrot < 0) { // get the rotation @@ -387,6 +405,9 @@ int QWSKeyboardHandler::transformDirKey(int key) } int xf = qt_screen->transformOrientation() + dir_keyrot; return (key-Qt::Key_Left+xf)%4+Qt::Key_Left; +#else + return 0; +#endif } /*! @@ -452,7 +473,7 @@ void QWSKeyboardHandler::endAutoRepeat() Maps \a keycode according to a keymap and sends that key event to the \l{Qt for Embedded Linux} server application. - + Please see the \l{Qt for Embedded Linux Character Input} and the \l {kmap2qmap} documentations for a description on how to create and use keymap files. diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 7c24002..6949e39 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -4,7 +4,7 @@ QT = core DEFINES += QT_BUILD_GUI_LIB QT_NO_USING_NAMESPACE win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000 -!win32:!embedded:!mac:!symbian:CONFIG += x11 +!win32:!embedded:!embedded_lite:!mac:!symbian:CONFIG += x11 unix:QMAKE_PKGCONFIG_REQUIRES = QtCore diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 0970385..67f0699 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -61,11 +61,14 @@ win32 { embedded { SOURCES += image/qpixmap_qws.cpp } +embedded_lite { + SOURCES += image/qpixmap_lite.cpp +} x11 { HEADERS += image/qpixmap_x11_p.h SOURCES += image/qpixmap_x11.cpp } -mac { +!embedded:!embedded_lite:mac { HEADERS += image/qpixmap_mac_p.h SOURCES += image/qpixmap_mac.cpp } diff --git a/src/gui/image/qpixmap_lite.cpp b/src/gui/image/qpixmap_lite.cpp new file mode 100644 index 0000000..4ba69fa --- /dev/null +++ b/src/gui/image/qpixmap_lite.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 QPixmap::grabWindow(WId window, int x, int y, int w, int h) +{ + Q_UNUSED(window); + Q_UNUSED(x); + Q_UNUSED(y); + Q_UNUSED(w); + Q_UNUSED(h); + return QPixmap(); +} diff --git a/src/gui/image/qpixmapdatafactory.cpp b/src/gui/image/qpixmapdatafactory.cpp index 53c93ad..fab6af8 100644 --- a/src/gui/image/qpixmapdatafactory.cpp +++ b/src/gui/image/qpixmapdatafactory.cpp @@ -53,6 +53,9 @@ #ifdef Q_WS_MAC # include #endif +#ifdef Q_WS_LITE +# include +#endif #include "private/qapplication_p.h" #include "private/qgraphicssystem_p.h" @@ -79,6 +82,8 @@ QPixmapData* QSimplePixmapDataFactory::create(QPixmapData::PixelType type) return new QRasterPixmapData(type); #elif defined(Q_WS_MAC) return new QMacPixmapData(type); +#elif defined(Q_WS_LITE) + return new QRasterPixmapData(type); #else #error QSimplePixmapDataFactory::create() not implemented #endif diff --git a/src/gui/inputmethod/inputmethod.pri b/src/gui/inputmethod/inputmethod.pri index 6d9f748..b3b7a3a 100644 --- a/src/gui/inputmethod/inputmethod.pri +++ b/src/gui/inputmethod/inputmethod.pri @@ -19,7 +19,7 @@ embedded { HEADERS += inputmethod/qwsinputcontext_p.h SOURCES += inputmethod/qwsinputcontext_qws.cpp } -mac:!embedded { +mac:!embedded:!embedded_lite { HEADERS += inputmethod/qmacinputcontext_p.h SOURCES += inputmethod/qmacinputcontext_mac.cpp } diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 8489817..85c838b 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -181,7 +181,25 @@ embedded { } -!embedded:!x11:mac { +embedded_lite { + HEADERS += \ + kernel/qgenericpluginfactory_lite.h \ + kernel/qgenericplugin_lite.h + + SOURCES += \ + kernel/qapplication_lite.cpp \ + kernel/qclipboard_lite.cpp \ + kernel/qcursor_lite.cpp \ + kernel/qdnd_qws.cpp \ + kernel/qdesktopwidget_lite.cpp \ + kernel/qgenericpluginfactory_lite.cpp \ + kernel/qgenericplugin_lite.cpp \ + kernel/qkeymapper_qws.cpp \ + kernel/qsound_lite.cpp \ + kernel/qwidget_lite.cpp +} + +!embedded:!embedded_lite:!x11:mac { SOURCES += \ kernel/qclipboard_mac.cpp \ kernel/qmime_mac.cpp \ diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 511c797..2bcaa68 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -741,6 +741,8 @@ void QApplicationPrivate::construct( { initResources(); + graphics_system_name = qgetenv("QT_DEFAULT_GRAPHICS_SYSTEM"); + qt_is_gui_used = (qt_appType != QApplication::Tty); process_cmdline(); // Must be called before initialize() diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp new file mode 100644 index 0000000..eec3e6c --- /dev/null +++ b/src/gui/kernel/qapplication_lite.cpp @@ -0,0 +1,624 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "qapplication_p.h" +#include "qcolormap.h" +#include "qpixmapcache.h" +#if !defined(QT_NO_GLIB) +#include "private/qeventdispatcher_glib_p.h" +#endif +#include "private/qeventdispatcher_unix_p.h" +#ifndef QT_NO_CURSOR +#include "private/qcursor_p.h" +#endif + +#include "qgenericpluginfactory_lite.h" +#include + +#include + +#include + + +QT_BEGIN_NAMESPACE + +static QString appName; +static const char *appFont = 0; // application font + +QWidget *qt_button_down = 0; // widget got last button-down + +static bool app_do_modal = false; +extern QWidgetList *qt_modal_stack; // stack of modal widgets + +int qt_last_x = 0; +int qt_last_y = 0; + +QString QApplicationPrivate::appName() const +{ + return QT_PREPEND_NAMESPACE(appName); +} + +void QApplicationPrivate::createEventDispatcher() +{ + Q_Q(QApplication); +#if !defined(QT_NO_GLIB) + if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported()) + eventDispatcher = new QEventDispatcherGlib(q); + else +#endif + eventDispatcher = new QEventDispatcherUNIX(q); +} + +static bool qt_try_modal(QWidget *widget, const QEvent *event) +{ + QWidget * top = 0; + + if (QApplicationPrivate::tryModalHelper(widget, &top)) + return true; + + bool block_event = false; + bool paint_event = false; + + switch (event->type()) { +#if 0 + case QEvent::Focus: + if (!static_cast(event)->simpleData.get_focus) + break; + // drop through +#endif + case QEvent::MouseButtonPress: // disallow mouse/key events + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + case QEvent::KeyPress: + case QEvent::KeyRelease: + block_event = true; + break; + default: + break; + } + + if ((block_event || paint_event) && top->parentWidget() == 0) + top->raise(); + + return !block_event; +} + + + +void QApplicationPrivate::enterModal_sys(QWidget *widget) +{ + qDebug() << ">>>>>>>> enterModal_sys" << app_do_modal << widget; + if (!qt_modal_stack) + qt_modal_stack = new QWidgetList; + qt_modal_stack->insert(0, widget); + app_do_modal = true; +} + +void QApplicationPrivate::leaveModal_sys(QWidget *widget ) +{ + qDebug() << "<<<<<<<<< leaveModal_sys" << app_do_modal << widget; + if (qt_modal_stack && qt_modal_stack->removeAll(widget)) { + if (qt_modal_stack->isEmpty()) { + delete qt_modal_stack; + qt_modal_stack = 0; + } + } + app_do_modal = qt_modal_stack != 0; +} + +bool QApplicationPrivate::modalState() +{ + return app_do_modal; +} + +void QApplicationPrivate::closePopup(QWidget *popup) +{ + Q_Q(QApplication); + if (!popupWidgets) + return; + popupWidgets->removeAll(popup); + +//### +// if (popup == qt_popup_down) { +// qt_button_down = 0; +// qt_popup_down = 0; +// } + + if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup + delete QApplicationPrivate::popupWidgets; + QApplicationPrivate::popupWidgets = 0; + + //### replay mouse event? + + //### transfer/release mouse grab + + //### transfer/release keyboard grab + + //give back focus + + if (active_window) { + if (QWidget *fw = active_window->focusWidget()) { + if (fw != QApplication::focusWidget()) { + fw->setFocus(Qt::PopupFocusReason); + } else { + QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason); + q->sendEvent(fw, &e); + } + } + } + + } else { + // A popup was closed, so the previous popup gets the focus. + + QWidget* aw = QApplicationPrivate::popupWidgets->last(); + if (QWidget *fw = aw->focusWidget()) + fw->setFocus(Qt::PopupFocusReason); + + //### regrab the keyboard and mouse in case 'popup' lost the grab + + + } + +} + +static int openPopupCount = 0; +void QApplicationPrivate::openPopup(QWidget *popup) +{ + openPopupCount++; + if (!popupWidgets) { // create list + popupWidgets = new QWidgetList; + + /* only grab if you are the first/parent popup */ + //#### ->grabMouse(popup,true); + //#### ->grabKeyboard(popup,true); + //### popupGrabOk = true; + } + popupWidgets->append(popup); // add to end of list + + // popups are not focus-handled by the window system (the first + // popup grabbed the keyboard), so we have to do that manually: A + // new popup gets the focus + if (popup->focusWidget()) { + popup->focusWidget()->setFocus(Qt::PopupFocusReason); + } else if (popupWidgets->count() == 1) { // this was the first popup + if (QWidget *fw = QApplication::focusWidget()) { + QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); + QApplication::sendEvent(fw, &e); + } + } +} + +void QApplicationPrivate::initializeMultitouch_sys() +{ +} + +void QApplicationPrivate::cleanupMultitouch_sys() +{ +} + +void QApplicationPrivate::initializeWidgetPaletteHash() +{ +} + +void QApplication::setCursorFlashTime(int msecs) +{ + QApplicationPrivate::cursor_flash_time = msecs; +} + +int QApplication::cursorFlashTime() +{ + return QApplicationPrivate::cursor_flash_time; +} + +void QApplication::setDoubleClickInterval(int ms) +{ + QApplicationPrivate::mouse_double_click_time = ms; +} + +int QApplication::doubleClickInterval() +{ + return QApplicationPrivate::mouse_double_click_time; +} + +void QApplication::setKeyboardInputInterval(int ms) +{ + QApplicationPrivate::keyboard_input_time = ms; +} + +int QApplication::keyboardInputInterval() +{ + return QApplicationPrivate::keyboard_input_time; +} + +#ifndef QT_NO_WHEELEVENT +void QApplication::setWheelScrollLines(int lines) +{ + QApplicationPrivate::wheel_scroll_lines = lines; +} + +int QApplication::wheelScrollLines() +{ + return QApplicationPrivate::wheel_scroll_lines; +} +#endif + +void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable) +{ + switch (effect) { + case Qt::UI_AnimateMenu: + QApplicationPrivate::animate_menu = enable; + break; + case Qt::UI_FadeMenu: + if (enable) + QApplicationPrivate::animate_menu = true; + QApplicationPrivate::fade_menu = enable; + break; + case Qt::UI_AnimateCombo: + QApplicationPrivate::animate_combo = enable; + break; + case Qt::UI_AnimateTooltip: + QApplicationPrivate::animate_tooltip = enable; + break; + case Qt::UI_FadeTooltip: + if (enable) + QApplicationPrivate::animate_tooltip = true; + QApplicationPrivate::fade_tooltip = enable; + break; + case Qt::UI_AnimateToolBox: + QApplicationPrivate::animate_toolbox = enable; + break; + default: + QApplicationPrivate::animate_ui = enable; + break; + } +} + +bool QApplication::isEffectEnabled(Qt::UIEffect effect) +{ + if (QColormap::instance().depth() < 16 || !QApplicationPrivate::animate_ui) + return false; + + switch(effect) { + case Qt::UI_AnimateMenu: + return QApplicationPrivate::animate_menu; + case Qt::UI_FadeMenu: + return QApplicationPrivate::fade_menu; + case Qt::UI_AnimateCombo: + return QApplicationPrivate::animate_combo; + case Qt::UI_AnimateTooltip: + return QApplicationPrivate::animate_tooltip; + case Qt::UI_FadeTooltip: + return QApplicationPrivate::fade_tooltip; + case Qt::UI_AnimateToolBox: + return QApplicationPrivate::animate_toolbox; + default: + return QApplicationPrivate::animate_ui; + } +} + +#ifndef QT_NO_CURSOR +void QApplication::setOverrideCursor(const QCursor &) +{ + // XXX +} + +void QApplication::restoreOverrideCursor() +{ + // XXX +} + +#endif// QT_NO_CURSOR + +QWidget *QApplication::topLevelAt(const QPoint &pos) +{ +//### We have to implement a windowsystem-aware way to do this + + //fallback implementation assuming widgets are in stacking order + + QWidgetList list = topLevelWidgets(); + for (int i = list.size()-1; i >= 0; --i) { + QWidget *w = list[i]; + //### mask is ignored + if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos)) + return w; + } + + return 0; +} + +void QApplication::beep() +{ +} + +void QApplication::alert(QWidget *, int) +{ +} + +static void init_plugins(const QList pluginList) +{ + for (int i = 0; i < pluginList.count(); ++i) { + QByteArray pluginSpec = pluginList.at(i); + qDebug() << "init_plugins" << i << pluginSpec; + int colonPos = pluginSpec.indexOf(':'); + QObject *plugin; + if (colonPos < 0) + plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString()); + else + plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)), + QLatin1String(pluginSpec.mid(colonPos+1))); + qDebug() << " created" << plugin; + } +} + +class QDummyInputContext : public QInputContext +{ +public: + explicit QDummyInputContext(QObject* parent = 0) : QInputContext(parent) {} + ~QDummyInputContext() {} + QString identifierName() { return QString(); } + QString language() { return QString(); } + + void reset() {} + bool isComposing() const { return false; } + +}; + +void qt_init(QApplicationPrivate *priv, int type) +{ + Q_UNUSED(type); + + char *p; + char **argv = priv->argv; + int argc = priv->argc; + + if (argv && *argv) { //apparently, we allow people to pass 0 on the other platforms + p = strrchr(argv[0], '/'); + appName = QString::fromLocal8Bit(p ? p + 1 : argv[0]); + } + + QList pluginList; + + // Get command line params + + int j = argc ? 1 : 0; + for (int i=1; iargc) { + priv->argv[j] = 0; + priv->argc = j; + } + + + + +#if 0 + QByteArray pluginEnv = qgetenv("QT_LITE_PLUGINS"); + if (!pluginEnv.isEmpty()) { + pluginList.append(pluginEnv.split(';')); + } +#endif + + + qDebug() << pluginList; + + init_plugins(pluginList); + + QColormap::initialize(); + QFont::initialize(); +#ifndef QT_NO_CURSOR +// QCursorData::initialize(); +#endif + + qApp->setObjectName(appName); + +#ifndef QT_NO_QWS_INPUTMETHODS + qApp->setInputContext(new QDummyInputContext(qApp)); +#endif +} + +void qt_cleanup() +{ + QPixmapCache::clear(); +#ifndef QT_NO_CURSOR + QCursorData::cleanup(); +#endif + QFont::cleanup(); + QColormap::cleanup(); +} + + +/*! + +\a tlw == 0 means that \a ev is in global coords only + + +*/ + +void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) +{ +// qDebug() << "handleMouseEvent" << tlw << ev.pos() << hex << ev.buttons(); + + static QWidget *implicit_mouse_grabber=0; + + QPoint localPoint = ev.pos(); + QPoint globalPoint = ev.globalPos(); + bool trustLocalPoint = !!tlw; //is there something the local point can be local to? + QWidget *mouseWidget = tlw; + + qt_last_x = globalPoint.x(); + qt_last_y = globalPoint.y(); + + if (self->inPopupMode()) { + //popup mouse handling is magical... + mouseWidget = qApp->activePopupWidget(); + trustLocalPoint = (mouseWidget == tlw); + + //### how should popup mode and implicit mouse grab interact? + + } else if (tlw && app_do_modal && !qt_try_modal(tlw, &ev) ) { + //even if we're blocked by modality, we should deliver the mouse release event.. + //### this code is not completely correct: multiple buttons can be pressed simultaneously + if (!(implicit_mouse_grabber && ev.buttons() == Qt::NoButton)) { + //qDebug() << "modal blocked mouse event to" << tlw; + return; + } + } else { + QWidget *mouseWindow = tlw; + + // find the tlw if we didn't get it from the plugin + if (!mouseWindow) { + mouseWindow = QApplication::topLevelAt(globalPoint); + } + + if (!mouseWindow && !implicit_mouse_grabber) + return; //nowhere to send it + + // which child should have it? + mouseWidget = mouseWindow; + if (mouseWindow) { + QWidget *w = mouseWindow->childAt(ev.pos()); + if (w) { + mouseWidget = w; + } + } + + //handle implicit mouse grab + if (ev.type() == QEvent::MouseButtonPress && !implicit_mouse_grabber) { + implicit_mouse_grabber = mouseWidget; + + Q_ASSERT(mouseWindow); + mouseWindow->activateWindow(); //focus + } else if (implicit_mouse_grabber) { + mouseWidget = implicit_mouse_grabber; + mouseWindow = mouseWidget->window(); + trustLocalPoint = (mouseWindow == tlw); + } + } + Q_ASSERT(mouseWidget); + + if (trustLocalPoint) { + // we have a sensible localPoint, so we prefer that, since the + // window system may know more than we do + localPoint = mouseWidget->mapFrom(tlw, localPoint); + } else { + // we don't want to map a local point from a different toplevel + // and we definitely don't want to map from the null pointer + localPoint = mouseWidget->mapFromGlobal(globalPoint); + } + + if (ev.buttons() == Qt::NoButton) { + //qDebug() << "resetting mouse grabber"; + implicit_mouse_grabber = 0; + } + + // Remember, we might enter a modal event loop when sending the event, + // so think carefully before adding code below this point. + + // qDebug() << "sending mouse ev." << ev.type() << localPoint << globalPoint << ev.button() << ev.buttons() << mouseWidget << "mouse grabber" << implicit_mouse_grabber; + + QMouseEvent e(ev.type(), localPoint, globalPoint, ev.button(), ev.buttons(), ev.modifiers()); + QApplication::sendSpontaneousEvent(mouseWidget, &e); + +} + + + +// Remember, Qt convention is: keyboard state is state *before* + +void QApplicationPrivate::handleKeyEvent(QWidget *tlw, QKeyEvent *e) +{ + QWidget *focusW = 0; + if (self->inPopupMode()) { + QWidget *popupW = qApp->activePopupWidget(); + focusW = popupW->focusWidget() ? popupW->focusWidget() : popupW; + } + if (!focusW) + focusW = QApplication::focusWidget(); + if (!focusW) + focusW = tlw; + if (!focusW) + focusW = QApplication::activeWindow(); + + //qDebug() << "handleKeyEvent" << hex << e->key() << e->modifiers() << e->text() << "widget" << focusW; + + if (!focusW) + return; + if (app_do_modal && !qt_try_modal(focusW, e)) + return; + + QApplication::sendSpontaneousEvent(focusW, e); +} + + +void QApplicationPrivate::handleGeometryChange(QWidget *tlw, const QRect &newRect) +{ + QRect cr(tlw->geometry()); + + bool isResize = cr.size() != newRect.size(); + bool isMove = cr.topLeft() != newRect.topLeft(); + tlw->data->crect = newRect; + if (isResize) { + QResizeEvent e(tlw->data->crect.size(), cr.size()); + QApplication::sendSpontaneousEvent(tlw, &e); + } + + if (isMove) { + //### frame geometry + QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft()); + QApplication::sendSpontaneousEvent(tlw, &e); + } +} +QT_END_NAMESPACE diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 3b6cd43..84182cb 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -571,6 +571,12 @@ public: void _q_readRX71MultiTouchEvents(); #endif +#ifdef Q_WS_LITE + static void handleMouseEvent(QWidget *tlw, const QMouseEvent &ev); + static void handleKeyEvent(QWidget *tlw, QKeyEvent *e); + static void handleGeometryChange(QWidget *tlw, const QRect &newRect); +#endif + private: #ifdef Q_WS_QWS QMap maxWindowRects; diff --git a/src/gui/kernel/qclipboard_lite.cpp b/src/gui/kernel/qclipboard_lite.cpp new file mode 100644 index 0000000..0d9268f --- /dev/null +++ b/src/gui/kernel/qclipboard_lite.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "qclipboard.h" + +#ifndef QT_NO_CLIPBOARD + +#include "qmimedata.h" +#include "qapplication.h" + +QT_BEGIN_NAMESPACE + +QT_USE_NAMESPACE + + +class QClipboardData +{ +public: + QClipboardData(); + ~QClipboardData(); + + void setSource(QMimeData* s) + { + if (s == src) + return; + delete src; + src = s; + } + QMimeData* source() + { return src; } + + void clear(); + +private: + QMimeData* src; +}; + +QClipboardData::QClipboardData() +{ + src = 0; +} + +QClipboardData::~QClipboardData() +{ + delete src; +} + +void QClipboardData::clear() +{ + delete src; + src = 0; +} + + +static QClipboardData *internalCbData = 0; + +static void cleanupClipboardData() +{ + delete internalCbData; + internalCbData = 0; +} + +static QClipboardData *clipboardData() +{ + if (internalCbData == 0) { + internalCbData = new QClipboardData; + qAddPostRoutine(cleanupClipboardData); + } + return internalCbData; +} + + +void QClipboard::clear(Mode mode) +{ + setText(QString(), mode); +} + + +bool QClipboard::event(QEvent *e) +{ + return QObject::event(e); +} + +const QMimeData* QClipboard::mimeData(Mode mode) const +{ + if (mode != Clipboard) return 0; + + QClipboardData *d = clipboardData(); + return d->source(); +} + +void QClipboard::setMimeData(QMimeData* src, Mode mode) +{ + if (mode != Clipboard) return; + + QClipboardData *d = clipboardData(); + + d->setSource(src); + + emitChanged(QClipboard::Clipboard); +} + +bool QClipboard::supportsMode(Mode mode) const +{ + return (mode == Clipboard); +} + +bool QClipboard::ownsMode(Mode mode) const +{ + if (mode == Clipboard) + qWarning("QClipboard::ownsClipboard: UNIMPLEMENTED!"); + return false; +} + +void QClipboard::connectNotify( const char * ) +{ +} + +void QClipboard::ownerDestroyed() +{ +} + +#endif // QT_NO_CLIPBOARD + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h index 2a919b3..115a4cc 100644 --- a/src/gui/kernel/qcursor.h +++ b/src/gui/kernel/qcursor.h @@ -120,7 +120,7 @@ public: static int x11Screen(); #elif defined(Q_WS_MAC) Qt::HANDLE handle() const; -#elif defined(Q_WS_QWS) +#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) int handle() const; #endif #endif diff --git a/src/gui/kernel/qcursor_lite.cpp b/src/gui/kernel/qcursor_lite.cpp new file mode 100644 index 0000000..5af03fc --- /dev/null +++ b/src/gui/kernel/qcursor_lite.cpp @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 +#include +#include + +QT_BEGIN_NAMESPACE + +QT_USE_NAMESPACE + +#ifndef QT_NO_CURSOR + +static int nextCursorId = Qt::BitmapCursor; + +/***************************************************************************** + Internal QCursorData class + *****************************************************************************/ + +QCursorData::QCursorData(Qt::CursorShape s) + : cshape(s), bm(0), bmm(0), hx(0), hy(0), id(s) +{ + ref = 1; +} + +QCursorData::~QCursorData() +{ + delete bm; + delete bmm; +} + + +/***************************************************************************** + Global cursors + *****************************************************************************/ + +extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp + +int QCursor::handle() const +{ + return d->id; +} + + +QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY) +{ + if (!QCursorData::initialized) + QCursorData::initialize(); + if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) { + qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)"); + QCursorData *c = qt_cursorTable[0]; + c->ref.ref(); + return c; + } + QCursorData *d = new QCursorData; + d->bm = new QBitmap(bitmap); + d->bmm = new QBitmap(mask); + d->cshape = Qt::BitmapCursor; + d->id = ++nextCursorId; + d->hx = hotX >= 0 ? hotX : bitmap.width() / 2; + d->hy = hotY >= 0 ? hotY : bitmap.height() / 2; + + return d; +} + +void QCursorData::update() +{ +} + +#endif //QT_NO_CURSOR + +extern int qt_last_x,qt_last_y; + +QPoint QCursor::pos() +{ + return QPoint(qt_last_x, qt_last_y); +} + +void QCursor::setPos(int x, int y) +{ + // Need to check, since some X servers generate null mouse move + // events, causing looping in applications which call setPos() on + // every mouse move event. + // + if (pos() == QPoint(x, y)) + return; +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qcursor_p.h b/src/gui/kernel/qcursor_p.h index 94b751a..17164e7 100644 --- a/src/gui/kernel/qcursor_p.h +++ b/src/gui/kernel/qcursor_p.h @@ -88,7 +88,7 @@ struct QCursorData { short hx, hy; #if defined (Q_WS_MAC) int mId; -#elif defined(Q_WS_QWS) +#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) int id; #endif #if defined (Q_WS_WIN) diff --git a/src/gui/kernel/qdesktopwidget_lite.cpp b/src/gui/kernel/qdesktopwidget_lite.cpp new file mode 100644 index 0000000..7aea787 --- /dev/null +++ b/src/gui/kernel/qdesktopwidget_lite.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "qdesktopwidget.h" +#include "private/qapplication_p.h" +#include "private/qgraphicssystem_p.h" + +QT_BEGIN_NAMESPACE + +QT_USE_NAMESPACE + +QDesktopWidget::QDesktopWidget() + : QWidget(0, Qt::Desktop) +{ + setObjectName(QLatin1String("desktop")); +} + +QDesktopWidget::~QDesktopWidget() +{ +} + +bool QDesktopWidget::isVirtualDesktop() const +{ + return true; +} + +int QDesktopWidget::primaryScreen() const +{ + return 0; +} + +int QDesktopWidget::numScreens() const +{ + QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); + if (!gs) + return 0; + return qMax(gs->screens().size(), 1); +} + +QWidget *QDesktopWidget::screen(int) +{ + return this; +} + +const QRect QDesktopWidget::availableGeometry(int screenNo) const +{ + QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); + if (!gs) + return QRect(); + QList screens = gs->screens(); + if (screenNo == -1) + screenNo = 0; + if (screenNo < 0 || screenNo >= screens.size()) + return QRect(); + else + return screens[screenNo]->availableGeometry(); +} + +const QRect QDesktopWidget::screenGeometry(int screenNo) const +{ + QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); + if (!gs) + return QRect(); + QList screens = gs->screens(); + if (screenNo == -1) + screenNo = 0; + if (screenNo < 0 || screenNo >= screens.size()) + return QRect(); + else + return screens[screenNo]->geometry(); +} + +int QDesktopWidget::screenNumber(const QWidget *w) const +{ + if (!w) + return 0; + + QRect frame = w->frameGeometry(); + if (!w->isWindow()) + frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0))); + const QPoint midpoint = (frame.topLeft() + frame.bottomRight()) / 2; + return screenNumber(midpoint); +} + +int QDesktopWidget::screenNumber(const QPoint &p) const +{ + QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); + if (!gs) + return -1; + QList screens = gs->screens(); + + for (int i = 0; i < screens.size(); ++i) + if (screens[i]->geometry().contains(p)) + return i; + + return -1; +} + +void QDesktopWidget::resizeEvent(QResizeEvent *) +{ +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h index 1f64015..a9d5056 100644 --- a/src/gui/kernel/qdnd_p.h +++ b/src/gui/kernel/qdnd_p.h @@ -262,7 +262,7 @@ public: private: QPixmap *pm_cursor; int n_cursor; -#ifdef Q_WS_QWS +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) Qt::DropAction currentActionForOverrideCursor; #endif diff --git a/src/gui/kernel/qgenericplugin_lite.cpp b/src/gui/kernel/qgenericplugin_lite.cpp new file mode 100644 index 0000000..29d7728 --- /dev/null +++ b/src/gui/kernel/qgenericplugin_lite.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "qgenericplugin_lite.h" + +#ifndef QT_NO_LIBRARY + +QT_BEGIN_NAMESPACE + +/*! + \class QGenericPlugin + \ingroup plugins + \ingroup lite + + \brief The QGenericPlugin class is an abstract base class for + window-system related plugins in Qt for Embedded Linux LITE. + + Note that this class is only available in \l{Qt for Embedded Linux LITE}. + + A mouse plugin can be created by subclassing + QGenericPlugin and reimplementing the pure virtual keys() and + create() functions. By exporting the derived class using the + Q_EXPORT_PLUGIN2() macro, The default implementation of the + QGenericPluginFactory class will automatically detect the plugin and + load the driver into the server application at run-time. See \l + {How to Create Qt Plugins} for details. + + \sa QGenericPluginFactory +*/ + +/*! + \fn QStringList QGenericPlugin::keys() const + + Implement this function to return the list of valid keys, i.e. the + drivers supported by this plugin. + + \sa create() +*/ + +/*! + Constructs a plugin with the given \a parent. + + Note that this constructor is invoked automatically by the + Q_EXPORT_PLUGIN2() macro, so there is no need for calling it + explicitly. +*/ +QGenericPlugin::QGenericPlugin(QObject *parent) + : QObject(parent) +{ +} + +/*! + Destroys the plugin. + + Note that Qt destroys a plugin automatically when it is no longer + used, so there is no need for calling the destructor explicitly. +*/ +QGenericPlugin::~QGenericPlugin() +{ +} + +/*! + \fn QObject* QGenericPlugin::create(const QString &key, const QString& specification) + + Implement this function to create a driver matching the type + specified by the given \a key and \a specification parameters. Note that + keys are case-insensitive. + + \sa keys() +*/ + +QT_END_NAMESPACE + +#endif // QT_NO_LIBRARY diff --git a/src/gui/kernel/qgenericplugin_lite.h b/src/gui/kernel/qgenericplugin_lite.h new file mode 100644 index 0000000..2c0ee7a --- /dev/null +++ b/src/gui/kernel/qgenericplugin_lite.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 QGENERICPLUGIN_LITE_H +#define QGENERICPLUGIN_LITE_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +#ifndef QT_NO_LIBRARY + +//class QGenericObject; ????? + + struct Q_GUI_EXPORT QGenericPluginFactoryInterface : public QFactoryInterface +{ + virtual QObject* create(const QString &name, const QString &spec) = 0; +}; + +#define QGenericPluginFactoryInterface_iid "com.trolltech.Qt.QGenericPluginFactoryInterface" +Q_DECLARE_INTERFACE(QGenericPluginFactoryInterface, QGenericPluginFactoryInterface_iid) + +class Q_GUI_EXPORT QGenericPlugin : public QObject, public QGenericPluginFactoryInterface +{ + Q_OBJECT + Q_INTERFACES(QGenericPluginFactoryInterface:QFactoryInterface) +public: + explicit QGenericPlugin(QObject *parent = 0); + ~QGenericPlugin(); + + virtual QStringList keys() const = 0; + virtual QObject* create(const QString& name, const QString &spec) = 0; +}; + +#endif // QT_NO_LIBRARY + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QMOUSEDRIVERPLUGIN_QWS_H diff --git a/src/gui/kernel/qgenericpluginfactory_lite.cpp b/src/gui/kernel/qgenericpluginfactory_lite.cpp new file mode 100644 index 0000000..4e5b12b --- /dev/null +++ b/src/gui/kernel/qgenericpluginfactory_lite.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "qgenericpluginfactory_lite.h" + +#include "qapplication.h" +#include "private/qfactoryloader_p.h" +#include "qgenericplugin_lite.h" +#include "qdebug.h" + +QT_BEGIN_NAMESPACE + +#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) +#ifndef QT_NO_LIBRARY + +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, + (QGenericPluginFactoryInterface_iid, + QLatin1String("/generic"), Qt::CaseInsensitive)) + +#endif //QT_NO_LIBRARY +#endif //QT_MAKEDLL + +/*! + \class QGenericPluginFactory + \ingroup qws + + \brief The QGenericPluginFactory class creates window-system + related plugin drivers in Qt for Embedded Linux LITE. + + Note that this class is only available in \l{Qt for Embedded Linux LITE}. + + + \sa QGenericPlugin +*/ + +/*! + Creates the driver specified by \a key, using the given \a specification. + + Note that the keys are case-insensitive. + + \sa keys() +*/ +QObject *QGenericPluginFactory::create(const QString& key, const QString &specification) +{ + QString driver = key.toLower(); + +#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) +#ifndef QT_NO_LIBRARY + if (QGenericPluginFactoryInterface *factory = qobject_cast(loader()->instance(driver))) + return factory->create(driver, specification); +#endif +#endif + return 0; +} + +/*! + Returns the list of valid keys, i.e. the available mouse drivers. + + \sa create() +*/ +QStringList QGenericPluginFactory::keys() +{ + QStringList list; + +#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) +#ifndef QT_NO_LIBRARY + QStringList plugins = loader()->keys(); + for (int i = 0; i < plugins.size(); ++i) { + if (!list.contains(plugins.at(i))) + list += plugins.at(i); + } +#endif //QT_NO_LIBRARY +#endif //QT_MAKEDLL + return list; +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qgenericpluginfactory_lite.h b/src/gui/kernel/qgenericpluginfactory_lite.h new file mode 100644 index 0000000..3be4614 --- /dev/null +++ b/src/gui/kernel/qgenericpluginfactory_lite.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 QGENERICPLUGINFACTORY_LITE_H +#define QGENERICPLUGINFACTORY_LITE_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QString; +class QObject; + +class Q_GUI_EXPORT QGenericPluginFactory +{ +public: + static QStringList keys(); + static QObject *create(const QString&, const QString &); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QGENERICPLUGINFACTORY_QWS_H diff --git a/src/gui/kernel/qsound_lite.cpp b/src/gui/kernel/qsound_lite.cpp new file mode 100644 index 0000000..2e2c1e8 --- /dev/null +++ b/src/gui/kernel/qsound_lite.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "qapplication.h" + +#ifndef QT_NO_SOUND + +#include "qsound.h" +#include "qsound_p.h" + +class QAuServerLite : public QAuServer +{ + Q_OBJECT +public: + QAuServerLite( QObject* parent ); + + void play( QSound* s ) {} + void stop( QSound* s ) {} + bool okay() { return false; } +}; + +QAuServerLite::QAuServerLite(QObject* parent) : + QAuServer(parent) +{ +} + +QAuServer* qt_new_audio_server() +{ + return new QAuServerLite(qApp); +} + +#include "qsound_lite.moc" + +#endif // QT_NO_SOUND + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 44f9db1..a3b861e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5266,7 +5266,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP //actually send the paint event QPaintEvent e(toBePainted); QCoreApplication::sendSpontaneousEvent(q, &e); -#if !defined(Q_WS_MAC) && !defined(Q_WS_QWS) +#if !defined(Q_WS_MAC) && !defined(Q_WS_QWS) && !defined(Q_WS_LITE) if (backingStore && !onScreen && !asRoot && (q->internalWinId() || !q->nativeParentWidget()->isWindow())) backingStore->markDirtyOnScreen(toBePainted, q, offset); #endif diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp new file mode 100644 index 0000000..bbc7766 --- /dev/null +++ b/src/gui/kernel/qwidget_lite.cpp @@ -0,0 +1,616 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "qwidget.h" +#include "qevent.h" +#include "qapplication.h" +#include "private/qbackingstore_p.h" +#include "private/qwidget_p.h" +#include "private/qgraphicssystem_p.h" +#include "private/qapplication_p.h" + +QT_BEGIN_NAMESPACE + +void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool /*destroyOldWindow*/) +{ + Q_Q(QWidget); + + Q_UNUSED(window); + Q_UNUSED(initializeWindow); + // XXX + + + Qt::WindowFlags flags = data.window_flags; + +#if 1 + QWindowSurface *surface = q->windowSurface(); + if (surface && (flags & Qt::Window)) + data.window_flags = surface->setWindowFlags(data.window_flags); +#endif +// qDebug() << "create_sys" << q; +} + +void QWidget::destroy(bool destroyWindow, bool destroySubWindows) +{ + Q_UNUSED(destroyWindow); + Q_UNUSED(destroySubWindows); + // XXX + + + if ((windowType() == Qt::Popup)) + qApp->d_func()->closePopup(this); + +} + +void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) +{ + Q_Q(QWidget); + + QWidget *oldParent = q->parentWidget(); + Qt::WindowFlags oldFlags = data.window_flags; + if (parent != newparent) { + QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? + + } + if (!newparent) { + f |= Qt::Window; + } + data.window_flags = f; + if (f & Qt::Window) { + //qDebug() << "setParent_sys" << q << newparent << hex << f; + if (QWindowSurface *surface = q->windowSurface()) + data.window_flags = surface->setWindowFlags(data.window_flags); + } + // XXX Reparenting child to toplevel or vice versa ### + if ((f&Qt::Window) && !(oldFlags&Qt::Window)) { + qDebug() << "setParent_sys() change to toplevel"; + q->create(); //### this cannot be right + } else if ((f&Qt::Window) && !(oldFlags&Qt::Window)) { + qDebug() << "######## setParent_sys() change from toplevel not implemented ########"; + } +} + +QPoint QWidget::mapToGlobal(const QPoint &pos) const +{ + int x=pos.x(), y=pos.y(); + const QWidget* w = this; + while (w) { + x += w->data->crect.x(); + y += w->data->crect.y(); + w = w->isWindow() ? 0 : w->parentWidget(); + } + return QPoint(x, y); +} + +QPoint QWidget::mapFromGlobal(const QPoint &pos) const +{ + int x=pos.x(), y=pos.y(); + const QWidget* w = this; + while (w) { + x -= w->data->crect.x(); + y -= w->data->crect.y(); + w = w->isWindow() ? 0 : w->parentWidget(); + } + return QPoint(x, y); +} + +void QWidgetPrivate::updateSystemBackground() {} + +#ifndef QT_NO_CURSOR +void QWidgetPrivate::setCursor_sys(const QCursor &cursor) +{ + Q_UNUSED(cursor); + Q_Q(QWidget); + if (q->isVisible()) + updateCursor(); +} + +void QWidgetPrivate::unsetCursor_sys() +{ + Q_Q(QWidget); + if (q->isVisible()) + updateCursor(); +} + +void QWidgetPrivate::updateCursor() const +{ + // XXX +} + +#endif //QT_NO_CURSOR + +void QWidgetPrivate::setWindowTitle_sys(const QString &caption) +{ + Q_UNUSED(caption); + // XXX +} + +void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/) +{ +} + +void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) +{ + Q_UNUSED(iconText); +} + +QWidget *qt_pressGrab = 0; +QWidget *qt_mouseGrb = 0; +static QWidget *keyboardGrb = 0; + +void QWidget::grabMouse() +{ + if (qt_mouseGrb) + qt_mouseGrb->releaseMouse(); + + // XXX + //qwsDisplay()->grabMouse(this,true); + + qt_mouseGrb = this; + qt_pressGrab = 0; +} + +#ifndef QT_NO_CURSOR +void QWidget::grabMouse(const QCursor &cursor) +{ + Q_UNUSED(cursor); + + if (qt_mouseGrb) + qt_mouseGrb->releaseMouse(); + + // XXX + //qwsDisplay()->grabMouse(this,true); + //qwsDisplay()->selectCursor(this, cursor.handle()); + qt_mouseGrb = this; + qt_pressGrab = 0; +} +#endif + +void QWidget::releaseMouse() +{ + if (qt_mouseGrb == this) { + // XXX + //qwsDisplay()->grabMouse(this,false); + qt_mouseGrb = 0; + } +} + +void QWidget::grabKeyboard() +{ + if (keyboardGrb) + keyboardGrb->releaseKeyboard(); + // XXX + //qwsDisplay()->grabKeyboard(this, true); + keyboardGrb = this; +} + +void QWidget::releaseKeyboard() +{ + if (keyboardGrb == this) { + // XXX + //qwsDisplay()->grabKeyboard(this, false); + keyboardGrb = 0; + } +} + +QWidget *QWidget::mouseGrabber() +{ + if (qt_mouseGrb) + return qt_mouseGrb; + return qt_pressGrab; +} + +QWidget *QWidget::keyboardGrabber() +{ + return keyboardGrb; +} + +void QWidget::activateWindow() +{ + // XXX +// qDebug() << "QWidget::activateWindow" << this; + QApplication::setActiveWindow(this); //##### +} + +void QWidgetPrivate::show_sys() +{ + Q_Q(QWidget); + q->setAttribute(Qt::WA_Mapped); + if (q->testAttribute(Qt::WA_DontShowOnScreen)) { + invalidateBuffer(q->rect()); + return; + } + + QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); + + if (!q->isWindow()) + return; + + if (QWindowSurface *surface = q->windowSurface()) { + const QRect geomRect = q->geometry(); + if (surface->geometry() != geomRect) + surface->setGeometry(geomRect); + surface->setVisible(true); + } + + if (q->windowType() != Qt::Popup) + q->activateWindow(); //### +} + + +void QWidgetPrivate::hide_sys() +{ + Q_Q(QWidget); + q->setAttribute(Qt::WA_Mapped, false); + if (!q->isWindow()) { + QWidget *p = q->parentWidget(); + if (p &&p->isVisible()) { + invalidateBuffer(q->rect()); + } + return; + } + if (QWindowSurface *surface = q->windowSurface()) { + surface->setVisible(false); + } + + //### we don't yet have proper focus event handling + if (q == QApplicationPrivate::active_window) + QApplication::setActiveWindow(0); + +} + +void QWidgetPrivate::setMaxWindowState_helper() +{ + // XXX +} + +void QWidgetPrivate::setFullScreenSize_helper() +{ + // XXX +} + +static Qt::WindowStates effectiveState(Qt::WindowStates state) + { + if (state & Qt::WindowMinimized) + return Qt::WindowMinimized; + else if (state & Qt::WindowFullScreen) + return Qt::WindowFullScreen; + else if (state & Qt::WindowMaximized) + return Qt::WindowMaximized; + return Qt::WindowNoState; + } + +void QWidget::setWindowState(Qt::WindowStates newstate) +{ + Q_D(QWidget); + Qt::WindowStates oldstate = windowState(); + if (oldstate == newstate) + return; + if (isWindow() && !testAttribute(Qt::WA_WState_Created)) + create(); + + data->window_state = newstate; + data->in_set_window_state = 1; + bool needShow = false; + Qt::WindowStates newEffectiveState = effectiveState(newstate); + Qt::WindowStates oldEffectiveState = effectiveState(oldstate); + if (isWindow() && newEffectiveState != oldEffectiveState) { + d->createTLExtra(); + if (oldEffectiveState == Qt::WindowNoState) { //normal + d->topData()->normalGeometry = geometry(); + } else if (oldEffectiveState == Qt::WindowFullScreen) { + setParent(0, d->topData()->savedFlags); + needShow = true; + } else if (oldEffectiveState == Qt::WindowMinimized) { + needShow = true; + } + + if (newEffectiveState == Qt::WindowMinimized) { + //### not ideal... + hide(); + needShow = false; + } else if (newEffectiveState == Qt::WindowFullScreen) { + d->topData()->savedFlags = windowFlags(); + setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint)); + d->setFullScreenSize_helper(); + raise(); + needShow = true; + } else if (newEffectiveState == Qt::WindowMaximized) { + createWinId(); + d->setMaxWindowState_helper(); + } else { //normal + QRect r = d->topData()->normalGeometry; + if (r.width() >= 0) { + d->topData()->normalGeometry = QRect(0,0,-1,-1); + setGeometry(r); + } + } + } + data->in_set_window_state = 0; + + if (needShow) + show(); + + if (newstate & Qt::WindowActive) + activateWindow(); + + QWindowStateChangeEvent e(oldstate); + QApplication::sendEvent(this, &e); +} + +void QWidgetPrivate::setFocus_sys() +{ + +} + +void QWidgetPrivate::raise_sys() +{ + // XXX +} + +void QWidgetPrivate::lower_sys() +{ + // XXX +} + +void QWidgetPrivate::stackUnder_sys(QWidget*) +{ + // XXX +} + +void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) +{ + Q_Q(QWidget); + if (extra) { // any size restrictions? + w = qMin(w,extra->maxw); + h = qMin(h,extra->maxh); + w = qMax(w,extra->minw); + h = qMax(h,extra->minh); + } + + QPoint oldp = q->geometry().topLeft(); + QSize olds = q->size(); + QRect r(x, y, w, h); + + bool isResize = olds != r.size(); + isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter? + + + // We only care about stuff that changes the geometry, or may + // cause the window manager to change its state + if (r.size() == olds && oldp == r.topLeft()) + return; + + if (!data.in_set_window_state) { + q->data->window_state &= ~Qt::WindowMaximized; + q->data->window_state &= ~Qt::WindowFullScreen; + if (q->isWindow()) + topData()->normalGeometry = QRect(0, 0, -1, -1); + } + + QPoint oldPos = q->pos(); + data.crect = r; + + if (q->isVisible()) { + + if (q->isWindow()) { + const QWidgetBackingStore *bs = maybeBackingStore(); + if (bs->windowSurface) + bs->windowSurface->setGeometry(q->frameGeometry()); + } else { + if (isMove && !isResize) + moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y()); + else + invalidateBuffer_resizeHelper(oldPos, olds); + } + + if (isMove) { + QMoveEvent e(q->pos(), oldPos); + QApplication::sendEvent(q, &e); + } + if (isResize) { + QResizeEvent e(r.size(), olds); + QApplication::sendEvent(q, &e); + } + } else { // not visible + if (isMove && q->pos() != oldPos) + q->setAttribute(Qt::WA_PendingMoveEvent, true); + if (isResize) + q->setAttribute(Qt::WA_PendingResizeEvent, true); + } + +} + +void QWidgetPrivate::setConstraints_sys() +{ +} + +void QWidgetPrivate::scroll_sys(int dx, int dy) +{ + Q_Q(QWidget); + scrollChildren(dx, dy); + scrollRect(q->rect(), dx, dy); +} + +void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) +{ + scrollRect(r, dx, dy); +} + +static QGraphicsSystemScreen *qt_screenForWidget(const QWidget *w) +{ + if (!w) + return 0; + QRect frame = w->frameGeometry(); + if (!w->isWindow()) + frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0))); + const QPoint p = (frame.topLeft() + frame.bottomRight()) / 2; + + QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); + if (!gs) { + qWarning("qt_screenForWidget: no graphics system"); + return 0; + } + QList screens = gs->screens(); + + for (int i = 0; i < screens.size(); ++i) { + if (screens[i]->geometry().contains(p)) + return screens[i]; + } + + // Assume screen zero if we have it. + if (!screens.isEmpty()) + return screens[0]; + else + qWarning("qt_screenForWidget: no screens"); + + return 0; +} + +int QWidget::metric(PaintDeviceMetric m) const +{ + Q_D(const QWidget); + + QGraphicsSystemScreen *screen = qt_screenForWidget(this); + if (!screen) { + if (m == PdmDpiX || m == PdmDpiY) + return 72; + return QPaintDevice::metric(m); + } + int val; + if (m == PdmWidth) { + val = data->crect.width(); + } else if (m == PdmWidthMM) { + val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width(); + } else if (m == PdmHeight) { + val = data->crect.height(); + } else if (m == PdmHeightMM) { + val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height(); + } else if (m == PdmDepth) { + return screen->depth(); + } else if (m == PdmDpiX || m == PdmPhysicalDpiX) { + if (d->extra && d->extra->customDpiX) + return d->extra->customDpiX; + else if (d->parent) + return static_cast(d->parent)->metric(m); + return qRound(screen->geometry().width() / double(screen->physicalSize().width() / 25.4)); + } else if (m == PdmDpiY || m == PdmPhysicalDpiY) { + if (d->extra && d->extra->customDpiY) + return d->extra->customDpiY; + else if (d->parent) + return static_cast(d->parent)->metric(m); + return qRound(screen->geometry().height() / double(screen->physicalSize().height() / 25.4)); + } else { + val = QPaintDevice::metric(m);// XXX + } + return val; +} + +void QWidgetPrivate::createSysExtra() +{ +} + +void QWidgetPrivate::deleteSysExtra() +{ +} + +void QWidgetPrivate::createTLSysExtra() +{ +} + +void QWidgetPrivate::deleteTLSysExtra() +{ +} + +void QWidgetPrivate::registerDropSite(bool on) +{ + Q_UNUSED(on); +} + +void QWidgetPrivate::setMask_sys(const QRegion ®ion) +{ + Q_UNUSED(region); + // XXX +} + +void QWidgetPrivate::updateFrameStrut() +{ + // XXX +} + +void QWidgetPrivate::setWindowOpacity_sys(qreal level) +{ + Q_UNUSED(level); + // XXX +} + +void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect) +{ + Q_UNUSED(dontShow); + Q_UNUSED(oldRect); + // XXX +} + +QPaintEngine *QWidget::paintEngine() const +{ + qWarning("QWidget::paintEngine: Should no longer be called"); + return 0; //##### @@@ +} + +QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys() +{ + Q_Q(QWidget); + if (q->windowType() == Qt::Desktop) + return 0; + q->ensurePolished(); + + QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); + if (!gs) + return 0; + + return gs->createWindowSurface(q); +} + +void QWidgetPrivate::setModal_sys() +{ +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index f69c3a7..3636ffb 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -681,6 +681,12 @@ public: void updateCursor() const; #endif QScreen* getScreen() const; +#elif defined(Q_WS_LITE) + void setMaxWindowState_helper(); + void setFullScreenSize_helper(); +#ifndef QT_NO_CURSOR + void updateCursor() const; +#endif #elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN static QWidget *mouseGrabber; static QWidget *keyboardGrabber; diff --git a/src/gui/kernel/qwindowdefs.h b/src/gui/kernel/qwindowdefs.h index da3425d..a114bb1 100644 --- a/src/gui/kernel/qwindowdefs.h +++ b/src/gui/kernel/qwindowdefs.h @@ -131,6 +131,12 @@ QT_END_HEADER #endif // Q_WS_QWS +#if defined(Q_WS_LITE) + +typedef unsigned long WId; + +#endif // Q_WS_LITE + #if defined(Q_OS_SYMBIAN) class CCoeControl; typedef CCoeControl * WId; diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 5abac2f..1f2076c 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -136,7 +136,7 @@ unix:x11 { painting/qpaintengine_x11.cpp } -!embedded:!x11:mac { +!embedded:!embedded_lite:!x11:mac { HEADERS += \ painting/qpaintengine_mac_p.h \ painting/qgraphicssystem_mac_p.h \ @@ -152,14 +152,14 @@ unix:x11 { painting/qprintengine_mac.mm \ } -unix:!mac:!symbian { +unix:!mac:!symbian|embedded_lite { HEADERS += \ painting/qprinterinfo_unix_p.h SOURCES += \ painting/qprinterinfo_unix.cpp } -win32|x11|mac|embedded|symbian { +win32|x11|mac|embedded|embedded_lite|symbian { SOURCES += painting/qbackingstore.cpp HEADERS += painting/qbackingstore_p.h } @@ -176,13 +176,19 @@ embedded { painting/qpaintdevice_qws.cpp } +embedded_lite { + SOURCES += \ + painting/qcolormap_lite.cpp \ + painting/qpaintdevice_lite.cpp +} + symbian { SOURCES += \ painting/qregion_s60.cpp \ painting/qcolormap_s60.cpp } -x11|embedded { +x11|embedded|embedded_lite { contains(QT_CONFIG,qtopia) { DEFINES += QT_NO_CUPS QT_NO_LPR } else { @@ -348,7 +354,7 @@ x11 { SOURCES += painting/qwindowsurface_x11.cpp } -mac { +!embedded:!embedded_lite:mac { HEADERS += painting/qwindowsurface_mac_p.h SOURCES += painting/qwindowsurface_mac.cpp } diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index e82f36e..d1ead97 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -691,9 +691,12 @@ void QWidgetBackingStore::markDirtyOnScreen(const QRegion ®ion, QWidget *widg } // Alien widgets. - if (!widget->internalWinId()) { - QWidget *nativeParent = widget->nativeParentWidget(); - // Alien widgets with the top-level as the native parent (common case). + if (!widget->internalWinId() && !widget->isWindow()) { //### LITEHACK we need winid support!!! +#ifdef Q_WS_LITE + QWidget *nativeParent = widget->window(); //### LITEHACK so far only toplevels are native +#else + QWidget *nativeParent = widget->nativeParentWidget(); // Alien widgets with the top-level as the native parent (common case). +#endif if (nativeParent == tlw) { if (!widget->testAttribute(Qt::WA_WState_InPaintEvent)) dirtyOnScreen += region.translated(topLevelOffset); diff --git a/src/gui/painting/qcolormap_lite.cpp b/src/gui/painting/qcolormap_lite.cpp new file mode 100644 index 0000000..b8ae1af --- /dev/null +++ b/src/gui/painting/qcolormap_lite.cpp @@ -0,0 +1,235 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "qcolormap.h" +#include "qcolor.h" +#include "qpaintdevice.h" +#include "private/qapplication_p.h" +#include "private/qgraphicssystem_p.h" + +QT_BEGIN_NAMESPACE + +class QColormapPrivate +{ +public: + inline QColormapPrivate() + : ref(1), mode(QColormap::Direct), depth(0), numcolors(0) + { } + + QAtomicInt ref; + + QColormap::Mode mode; + int depth; + int numcolors; +}; + +static QColormapPrivate *screenMap = 0; + +void QColormap::initialize() +{ + screenMap = new QColormapPrivate; + + QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); + if (!gs) + return; + QList screens = gs->screens(); + if (screens.isEmpty()) + return; + + screenMap->depth = screens[0]->depth(); + if (screenMap->depth < 8) { + screenMap->mode = QColormap::Indexed; + screenMap->numcolors = 256; + } else { + screenMap->mode = QColormap::Direct; + screenMap->numcolors = -1; + } +} + +void QColormap::cleanup() +{ + delete screenMap; + screenMap = 0; +} + +QColormap QColormap::instance(int /*screen*/) +{ + return QColormap(); +} + +QColormap::QColormap() + : d(screenMap) +{ d->ref.ref(); } + +QColormap::QColormap(const QColormap &colormap) + :d (colormap.d) +{ d->ref.ref(); } + +QColormap::~QColormap() +{ + if (!d->ref.deref()) + delete d; +} + +QColormap::Mode QColormap::mode() const +{ return d->mode; } + + +int QColormap::depth() const +{ return d->depth; } + + +int QColormap::size() const +{ + return d->numcolors; +} + +#ifndef QT_QWS_DEPTH16_RGB +#define QT_QWS_DEPTH16_RGB 565 +#endif +static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100); +static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10); +static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10); +static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits); +static const int qt_green_shift = qt_bbits-(8-qt_gbits); +static const int qt_neg_blue_shift = 8-qt_bbits; +static const int qt_blue_mask = (1<> qt_neg_blue_shift; + + return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask); +} + +inline QRgb qt_conv16ToRgb(ushort c) +{ + const int r=(c & qt_red_mask); + const int g=(c & qt_green_mask); + const int b=(c & qt_blue_mask); + const int tr = r >> qt_red_shift | r >> qt_red_rounding_shift; + const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift; + const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift; + + return qRgb(tr,tg,tb); +} + +uint QColormap::pixel(const QColor &color) const +{ + QRgb rgb = color.rgba(); + if (d->mode == QColormap::Direct) { + switch(d->depth) { + case 16: + return qt_convRgbTo16(rgb); + case 24: + case 32: + { + const int r = qRed(rgb); + const int g = qGreen(rgb); + const int b = qBlue(rgb); + const int red_shift = 16; + const int green_shift = 8; + const int red_mask = 0xff0000; + const int green_mask = 0x00ff00; + const int blue_mask = 0x0000ff; + const int tg = g << green_shift; +#ifdef QT_QWS_DEPTH_32_BGR + if (qt_screen->pixelType() == QScreen::BGRPixel) { + const int tb = b << red_shift; + return 0xff000000 | (r & blue_mask) | (tg & green_mask) | (tb & red_mask); + } +#endif + const int tr = r << red_shift; + return 0xff000000 | (b & blue_mask) | (tg & green_mask) | (tr & red_mask); + } + } + } + //XXX + //return qt_screen->alloc(qRed(rgb), qGreen(rgb), qBlue(rgb)); + return 0; +} + +const QColor QColormap::colorAt(uint pixel) const +{ + if (d->mode == Direct) { + if (d->depth == 16) { + pixel = qt_conv16ToRgb(pixel); + } + const int red_shift = 16; + const int green_shift = 8; + const int red_mask = 0xff0000; + const int green_mask = 0x00ff00; + const int blue_mask = 0x0000ff; +#ifdef QT_QWS_DEPTH_32_BGR + if (qt_screen->pixelType() == QScreen::BGRPixel) { + return QColor((pixel & blue_mask), + (pixel & green_mask) >> green_shift, + (pixel & red_mask) >> red_shift); + } +#endif + return QColor((pixel & red_mask) >> red_shift, + (pixel & green_mask) >> green_shift, + (pixel & blue_mask)); + } +#if 0 // XXX + Q_ASSERT_X(int(pixel) < qt_screen->numCols(), "QColormap::colorAt", "pixel out of bounds of palette"); + return QColor(qt_screen->clut()[pixel]); +#endif + return QColor(); +} + +const QVector QColormap::colormap() const +{ + return QVector(); +} + +QColormap &QColormap::operator=(const QColormap &colormap) +{ qAtomicAssign(d, colormap.d); return *this; } + +QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp index a7f5efb..ce8e500 100644 --- a/src/gui/painting/qgraphicssystem.cpp +++ b/src/gui/painting/qgraphicssystem.cpp @@ -50,6 +50,9 @@ #ifdef Q_WS_MAC # include #endif +#ifdef Q_WS_LITE +# include +#endif QT_BEGIN_NAMESPACE @@ -68,11 +71,26 @@ QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType typ return new QRasterPixmapData(type); #elif defined(Q_WS_MAC) return new QMacPixmapData(type); +#elif defined(Q_WS_LITE) + return new QRasterPixmapData(type); #elif !defined(Q_WS_QWS) #error QGraphicsSystem::createDefaultPixmapData() not implemented #endif return 0; } +QList QGraphicsSystem::screens() const +{ + return QList(); +} + +QGraphicsSystemScreen::~QGraphicsSystemScreen() +{ +} + +QRect QGraphicsSystemScreen::availableGeometry() const +{ + return geometry(); +} QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index c4f87f7..7e1ef67 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -60,6 +60,18 @@ QT_BEGIN_NAMESPACE class QPixmapFilter; +class Q_GUI_EXPORT QGraphicsSystemScreen +{ +public: + virtual ~QGraphicsSystemScreen(); + + virtual QRect geometry() const = 0; + virtual QRect availableGeometry() const; + virtual int depth() const = 0; + virtual QImage::Format format() const = 0; + virtual QSize physicalSize() const = 0; +}; + class Q_GUI_EXPORT QGraphicsSystem { public: @@ -68,6 +80,8 @@ public: virtual ~QGraphicsSystem() = 0; + virtual QList screens() const; + //### Remove this & change qpixmap.cpp & qbitmap.cpp once every platform is gaurenteed // to have a graphics system. static QPixmapData *createDefaultPixmapData(QPixmapData::PixelType type); diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp index 7ee0818..b6bd40c 100644 --- a/src/gui/painting/qpaintdevice.cpp +++ b/src/gui/painting/qpaintdevice.cpp @@ -59,10 +59,12 @@ QPaintDevice::~QPaintDevice() } +#ifndef Q_WS_LITE int QPaintDevice::metric(PaintDeviceMetric) const { qWarning("QPaintDevice::metrics: Device has no metric information"); return 0; } +#endif QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintdevice_lite.cpp b/src/gui/painting/qpaintdevice_lite.cpp new file mode 100644 index 0000000..2560bf5 --- /dev/null +++ b/src/gui/painting/qpaintdevice_lite.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "qpaintdevice.h" +#include "qpainter.h" +#include "qwidget.h" +#include "qbitmap.h" +#include "qapplication.h" + +QT_BEGIN_NAMESPACE + +extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp + +int QPaintDevice::metric(PaintDeviceMetric m) const +{ + qWarning("QPaintDevice::metrics: Device has no metric information"); + if (m == PdmDpiX) { + return 72; + } else if (m == PdmDpiY) { + return 72; + } else if (m == PdmNumColors) { + // FIXME: does this need to be a real value? + return 256; + } else { + qDebug("Unrecognised metric %d!",m); + return 0; + } +} + +QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h index 921db4f..6da0a2f 100644 --- a/src/gui/painting/qpaintengine.h +++ b/src/gui/painting/qpaintengine.h @@ -270,6 +270,9 @@ private: friend class QtopiaPrintEnginePrivate; friend class QProxyFontEngine; #endif +#ifdef Q_WS_LITE + friend class QProxyFontEngine; +#endif friend class QPainter; friend class QPainterPrivate; friend class QWidget; diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index d138663..3e3e8b9 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -1627,7 +1627,7 @@ QT_END_INCLUDE_NAMESPACE QT_BEGIN_INCLUDE_NAMESPACE # include "qregion_win.cpp" QT_END_INCLUDE_NAMESPACE -#elif defined(Q_WS_QWS) +#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) static QRegionPrivate qrp; QRegion::QRegionData QRegion::shared_empty = {Q_BASIC_ATOMIC_INITIALIZER(1), &qrp}; #endif @@ -4233,7 +4233,7 @@ QRect QRegion::boundingRect() const Returns true if \a rect is guaranteed to be fully contained in \a region. A false return value does not guarantee the opposite. */ -#ifdef Q_WS_QWS +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) Q_GUI_EXPORT #endif bool qt_region_strictContains(const QRegion ®ion, const QRect &rect) diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index 226e3fa..786283c 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -59,7 +59,7 @@ QT_MODULE(Gui) template class QVector; class QVariant; -#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) struct QRegionPrivate; #endif @@ -160,7 +160,7 @@ public: #endif HIMutableShapeRef toHIMutableShape() const; static QRegion fromHIShapeRef(HIShapeRef shape); -#elif defined(Q_WS_QWS) +#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) inline void *handle() const { return d->qt_rgn; } #endif #endif @@ -200,7 +200,7 @@ private: #elif defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) mutable RgnHandle unused; // Here for binary compatability reasons. ### Qt 5 remove. #endif -#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) QRegionPrivate *qt_rgn; #endif }; diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp index 1bd343d..c750a05 100644 --- a/src/gui/painting/qwindowsurface.cpp +++ b/src/gui/painting/qwindowsurface.cpp @@ -349,4 +349,35 @@ void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) } } + +#ifdef Q_WS_LITE +/*! +Requests setting the window flags of this surface to \a type. Returns the actual flags set. +*/ +Qt::WindowFlags QWindowSurface::setWindowFlags(Qt::WindowFlags type) +{ + Q_UNUSED(type); + qDebug() << "QWindowSurface::setWindowFlags" << hex << type; + return Qt::Window; +} + +/*! + Returns the effective window flags for this surface. +*/ +Qt::WindowFlags QWindowSurface::windowFlags() const +{ + return Qt::Window; +} + +/*! +Reimplemented in subclasses to show the surface if \a visible is \c true, and hide it if \a visible is \c false. +*/ + +void QWindowSurface::setVisible(bool visible) +{ + Q_UNUSED(visible); +} + +#endif + QT_END_NAMESPACE diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h index 502e10d..06d3dad 100644 --- a/src/gui/painting/qwindowsurface_p.h +++ b/src/gui/painting/qwindowsurface_p.h @@ -89,6 +89,11 @@ public: virtual QPoint offset(const QWidget *widget) const; inline QRect rect(const QWidget *widget) const; +#ifdef Q_WS_LITE + virtual void setVisible(bool visible); + virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); + virtual Qt::WindowFlags windowFlags() const; +#endif bool hasStaticContentsSupport() const; void setStaticContents(const QRegion ®ion); diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index 767ade0..78d0359 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -33,7 +33,7 @@ contains( styles, all ) { styles = mac windows windowsxp windowsvista } -x11|embedded|!macx-*:styles -= mac +x11|embedded|embedded_lite|!macx-*:styles -= mac x11{ QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 03f69db..b9ce238 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -172,6 +172,8 @@ Q_GUI_EXPORT int qt_defaultDpiX() if (!subScreens.isEmpty()) screen = subScreens.at(0); dpi = qRound(screen->width() / (screen->physicalWidth() / qreal(25.4))); +#elif defined(Q_WS_LITE) + dpi = 72; #elif defined(Q_OS_SYMBIAN) dpi = S60->defaultDpiX; #endif // Q_WS_X11 @@ -200,6 +202,8 @@ Q_GUI_EXPORT int qt_defaultDpiY() if (!subScreens.isEmpty()) screen = subScreens.at(0); dpi = qRound(screen->height() / (screen->physicalHeight() / qreal(25.4))); +#elif defined(Q_WS_LITE) + dpi = 72; #elif defined(Q_OS_SYMBIAN) dpi = S60->defaultDpiY; #endif // Q_WS_X11 diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 9fe660a..33aa4c4 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -46,7 +46,7 @@ #include #include -#if defined(Q_WS_X11) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) typedef struct FT_FaceRec_* FT_Face; #endif @@ -232,7 +232,7 @@ public: #ifdef Q_WS_MAC quint32 macFontID() const; #endif -#if defined(Q_WS_X11) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) FT_Face freetypeFace() const; #endif diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 78847ef..98d848f 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -56,7 +56,7 @@ #include #include -#if (defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) +#if (defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) # include # include FT_TRUETYPE_TABLES_H #endif @@ -153,10 +153,11 @@ struct QtFontSize QtFontEncoding *encodingID(int id, uint xpoint = 0, uint xres = 0, uint yres = 0, uint avgwidth = 0, bool add = false); #endif // Q_WS_X11 -#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) + +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) QByteArray fileName; int fileIndex; -#endif // defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) +#endif // defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) }; @@ -230,14 +231,14 @@ struct QtFontStyle delete [] weightName; delete [] setwidthName; #endif -#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) while (count) { // bitfield count-- in while condition does not work correctly in mwccsym2 count--; #ifdef Q_WS_X11 free(pixelSizes[count].encodings); #endif -#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) pixelSizes[count].fileName.~QByteArray(); #endif } @@ -255,7 +256,7 @@ struct QtFontStyle const char *weightName; const char *setwidthName; #endif // Q_WS_X11 -#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) bool antialiased; #endif @@ -296,7 +297,7 @@ QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add) pixelSizes[count].count = 0; pixelSizes[count].encodings = 0; #endif -#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) new (&pixelSizes[count].fileName) QByteArray; pixelSizes[count].fileIndex = 0; #endif @@ -382,7 +383,7 @@ struct QtFontFamily fixedPitchComputed(false), #endif name(n), count(0), foundries(0) -#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) , bogusWritingSystems(false) #endif { @@ -422,7 +423,7 @@ struct QtFontFamily int count; QtFontFoundry **foundries; -#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) bool bogusWritingSystems; QStringList fallbackFamilies; #endif @@ -469,7 +470,8 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create) // ### copied to tools/makeqpf/qpf2.cpp -#if (defined(Q_WS_QWS) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)) +#if ((defined(Q_WS_QWS) || defined(Q_WS_LITE)) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)) + // see the Unicode subset bitfields in the MSDN docs static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = { // Any, @@ -604,7 +606,7 @@ class QFontDatabasePrivate public: QFontDatabasePrivate() : count(0), families(0), reregisterAppFonts(false) -#if defined(Q_WS_QWS) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) , stream(0) #endif #if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) @@ -652,11 +654,11 @@ public: void invalidate(); -#if defined(Q_WS_QWS) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) bool loadFromCache(const QString &fontPath); void addQPF2File(const QByteArray &file); #endif // Q_WS_QWS -#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) void addFont(const QString &familyname, const char *foundryname, int weight, bool italic, int pixelSize, const QByteArray &file, int fileIndex, bool antialiased, @@ -665,7 +667,7 @@ public: QStringList addTTFile(const QByteArray &file, const QByteArray &fontData = QByteArray()); #endif // QT_NO_FREETYPE #endif -#if defined(Q_WS_QWS) +#if defined(Q_WS_QWS) || defined (Q_WS_LITE) QDataStream *stream; QStringList fallbackFamilies; #elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) @@ -719,7 +721,7 @@ QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create) return families[pos]; } -#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundryname, int weight, bool italic, int pixelSize, const QByteArray &file, int fileIndex, bool antialiased, const QList &writingSystems) @@ -750,7 +752,7 @@ void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundr size->fileName = file; size->fileIndex = fileIndex; -#if defined(Q_WS_QWS) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) if (stream) { *stream << familyname << foundry->name << weight << quint8(italic) << pixelSize << file << fileIndex << quint8(antialiased); @@ -765,7 +767,7 @@ void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundr } #endif -#if (defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) +#if (defined(Q_WS_QWS) || defined (Q_WS_LITE) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) QStringList QFontDatabasePrivate::addTTFile(const QByteArray &file, const QByteArray &fontData) { QStringList families; @@ -877,7 +879,7 @@ static const int scriptForWritingSystem[] = { }; -#if defined Q_WS_QWS || (defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)) || defined(Q_WS_WIN) +#if defined Q_WS_QWS || defined(Q_WS_LITE) || (defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)) || defined(Q_WS_WIN) static inline bool requiresOpenType(int writingSystem) { return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala) @@ -951,7 +953,7 @@ static void match(int script, const QFontDef &request, const QString &family_name, const QString &foundry_name, int force_encoding_id, QtFontDesc *desc, const QList &blacklistedFamilies = QList()); -#if defined(Q_WS_X11) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef) { fontDef->family = desc.family->name; @@ -1039,7 +1041,7 @@ QT_BEGIN_INCLUDE_NAMESPACE # include "qfontdatabase_mac.cpp" #elif defined(Q_WS_WIN) # include "qfontdatabase_win.cpp" -#elif defined(Q_WS_QWS) +#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) # include "qfontdatabase_qws.cpp" #elif defined(Q_OS_SYMBIAN) # include "qfontdatabase_s60.cpp" diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h index e62bb31..9b92c57 100644 --- a/src/gui/text/qfontdatabase.h +++ b/src/gui/text/qfontdatabase.h @@ -151,7 +151,7 @@ public: private: static void createDatabase(); static void parseFontName(const QString &name, QString &foundry, QString &family); -#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) static QFontEngine *findFont(int script, const QFontPrivate *fp, const QFontDef &request); #endif static void load(const QFontPrivate *d, int script); diff --git a/src/gui/text/qfontdatabase_qws.cpp b/src/gui/text/qfontdatabase_qws.cpp index 0a9630f..62c67a3 100644 --- a/src/gui/text/qfontdatabase_qws.cpp +++ b/src/gui/text/qfontdatabase_qws.cpp @@ -40,8 +40,10 @@ ****************************************************************************/ #include "qdir.h" +#if defined(Q_WS_QWS) #include "qscreen_qws.h" //so we can check for rotation #include "qwindowsystem_qws.h" +#endif #include "qlibraryinfo.h" #include "qabstractfileengine.h" #include @@ -153,7 +155,11 @@ extern QString qws_fontCacheDir(); #ifndef QT_FONTS_ARE_RESOURCES bool QFontDatabasePrivate::loadFromCache(const QString &fontPath) { +#ifdef Q_WS_QWS const bool weAreTheServer = QWSServer::instance(); +#else + const bool weAreTheServer = true; // assume single-process +#endif QString fontDirFile = fontPath + QLatin1String("/fontdir"); @@ -687,6 +693,7 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp, { QScopedPointer engine(loadSingleEngine(script, fp, request, family, foundry, style, size)); +#ifndef QT_NO_QWS_QPF if (!engine.isNull() && script == QUnicodeTables::Common && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) { @@ -700,6 +707,7 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp, engine.take(); engine.reset(fe); } +#endif return engine.take(); } diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 7a3b3e1..74d72c4 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -816,7 +816,7 @@ QFontEngineGlyphCache *QFontEngine::glyphCache(QFontEngineGlyphCache::Type key, return 0; } -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) static inline QFixed kerning(int left, int right, const QFontEngine::KernPair *pairs, int numPairs) { uint left_right = (left << 16) + right; @@ -1182,7 +1182,7 @@ glyph_metrics_t QFontEngineBox::boundingBox(const QGlyphLayout &glyphs) return overall; } -#if defined(Q_WS_QWS) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) void QFontEngineBox::draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &ti) { if (!ti.glyphs.numGlyphs) diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 4cc5c5e..9e10eab 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -256,7 +256,7 @@ public: QGlyphSet *loadTransformedGlyphSet(const QTransform &matrix); bool loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, GlyphFormat format = Format_Render); -#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) virtual void draw(QPaintEngine * /*p*/, qreal /*x*/, qreal /*y*/, const QTextItemInt & /*si*/) {} #endif diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index d654215..dc17c83 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -234,7 +234,7 @@ public: bool symbol; mutable HB_FontRec hbFont; mutable HB_Face hbFace; -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) struct KernPair { uint left_right; QFixed adjust; diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index b28ecd7..2375f08 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -85,7 +85,7 @@ unix:x11 { text/qfontengine_ft.cpp } -!embedded:!x11:mac { +!embedded:!embedded_lite:!x11:mac { SOURCES += \ text/qfont_mac.cpp OBJECTIVE_SOURCES += text/qfontengine_mac.mm @@ -106,6 +106,19 @@ embedded { DEFINES += QT_NO_FONTCONFIG } +embedded_lite { + SOURCES += \ + text/qfont_qws.cpp \ + text/qfontengine_ft.cpp \ + text/qfontengine_qpf.cpp \ + text/qabstractfontengine_qws.cpp + HEADERS += \ + text/qfontengine_ft_p.h \ + text/qabstractfontengine_qws.h \ + text/qabstractfontengine_p.h + DEFINES += QT_NO_FONTCONFIG +} + symbian { SOURCES += \ text/qfont_s60.cpp diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 76f583d..da4de73 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -45,7 +45,7 @@ #include -#if defined(Q_WS_QWS) +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) #include "qdesktopservices_qws.cpp" #elif defined(Q_WS_X11) #include "qdesktopservices_x11.cpp" diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri index cdbb7cc..e718c7b 100644 --- a/src/gui/util/util.pri +++ b/src/gui/util/util.pri @@ -30,12 +30,12 @@ unix:x11 { util/qsystemtrayicon_x11.cpp } -embedded { +embedded|embedded_lite { SOURCES += \ util/qsystemtrayicon_qws.cpp } -!embedded:!x11:mac { +!embedded:!embedded_lite:!x11:mac { OBJECTIVE_SOURCES += util/qsystemtrayicon_mac.mm } diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index da18f86..db6a572 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -112,7 +112,7 @@ void QLineControl::updateDisplayText() Copies the currently selected text into the clipboard using the given \a mode. - + \note If the echo mode is set to a mode other than Normal then copy will not work. This is to prevent using copy as a method of bypassing password features of the line control. @@ -479,7 +479,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) /*! \internal - Draws the display text for the line control using the given + Draws the display text for the line control using the given \a painter, \a clip, and \a offset. Which aspects of the display text are drawn is specified by the given \a flags. diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri index 4567902..5ee693c 100644 --- a/src/gui/widgets/widgets.pri +++ b/src/gui/widgets/widgets.pri @@ -146,7 +146,7 @@ SOURCES += \ widgets/qprintpreviewwidget.cpp \ widgets/qactiontokeyeventmapper.cpp -!embedded:mac { +!embedded:!embedded_lite:mac { HEADERS += widgets/qmacnativewidget_mac.h \ widgets/qmaccocoaviewcontainer_mac.h OBJECTIVE_HEADERS += widgets/qcocoatoolbardelegate_mac_p.h \ diff --git a/src/plugins/generic/linuxinput/linuxinput.pro b/src/plugins/generic/linuxinput/linuxinput.pro new file mode 100644 index 0000000..ad9f6a9 --- /dev/null +++ b/src/plugins/generic/linuxinput/linuxinput.pro @@ -0,0 +1,18 @@ +TARGET = qlinuxinputplugin +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/generic +target.path = $$[QT_INSTALL_PLUGINS]/generic +INSTALLS += target + +DEFINES += QT_QWS_KBD_LINUXINPUT + +HEADERS = qlinuxinput.h + +SOURCES = main.cpp \ + qlinuxinput.cpp + +HEADERS += $$QT_SOURCE_TREE/src/gui/embedded/qkbd_qws.h \ + $$QT_SOURCE_TREE/src/gui/embedded/qkbd_qws_p.h + +SOURCES += $$QT_SOURCE_TREE/src/gui/embedded/qkbd_qws.cpp diff --git a/src/plugins/generic/linuxinput/main.cpp b/src/plugins/generic/linuxinput/main.cpp new file mode 100644 index 0000000..21209b8 --- /dev/null +++ b/src/plugins/generic/linuxinput/main.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 +#include "qlinuxinput.h" + +QT_BEGIN_NAMESPACE + +class QLinuxInputPlugin : public QGenericPlugin +{ +public: + QLinuxInputPlugin(); + + QStringList keys() const; + QObject* create(const QString &key, const QString &specification); +}; + +QLinuxInputPlugin::QLinuxInputPlugin() + : QGenericPlugin() +{ +} + +QStringList QLinuxInputPlugin::keys() const +{ + return (QStringList() + << QLatin1String("LinuxInputMouse") + << QLatin1String("LinuxInputKeyboard")); +} + +QObject* QLinuxInputPlugin::create(const QString &key, + const QString &specification) +{ + if (!key.compare(QLatin1String("LinuxInputMouse"), Qt::CaseInsensitive)) + return new QLinuxInputMouseHandler(key, specification); + if (!key.compare(QLatin1String("LinuxInputKeyboard"), Qt::CaseInsensitive)) + return new QLinuxInputKeyboardHandler(key, specification); + return 0; + } + +Q_EXPORT_PLUGIN2(qlinuxinputplugin, QLinuxInputPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp new file mode 100644 index 0000000..2ce687d --- /dev/null +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -0,0 +1,371 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "qlinuxinput.h" + + +#include +#include +#include +#include +#include + +#include + + +#include +#include // overrides QT_OPEN + +#include +#include + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +QLinuxInputMouseHandler::QLinuxInputMouseHandler(const QString &key, + const QString &specification) + : m_notify(0), m_x(0), m_y(0), m_buttons(0) +{ + qDebug() << "QLinuxInputMouseHandler" << key << specification; + + + setObjectName(QLatin1String("LinuxInputSubsystem Mouse Handler")); + + QString dev = QLatin1String("/dev/input/event0"); + if (specification.startsWith(QLatin1String("/dev/"))) + dev = specification; + + m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0); + if (m_fd >= 0) { + m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); + connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData())); + } else { + qWarning("Cannot open mouse input device '%s': %s", qPrintable(dev), strerror(errno)); + return; + } + +} + + +QLinuxInputMouseHandler::~QLinuxInputMouseHandler() +{ + if (m_fd >= 0) + QT_CLOSE(m_fd); +} + +void QLinuxInputMouseHandler::readMouseData() +{ + struct ::input_event buffer[32]; + int n = 0; + + forever { + n = QT_READ(m_fd, reinterpret_cast(buffer) + n, sizeof(buffer) - n); + + if (n == 0) { + qWarning("Got EOF from the input device."); + return; + } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) { + qWarning("Could not read from input device: %s", strerror(errno)); + return; + } else if (n % sizeof(buffer[0]) == 0) { + break; + } + } + + n /= sizeof(buffer[0]); + + for (int i = 0; i < n; ++i) { + struct ::input_event *data = &buffer[i]; + + bool unknown = false; + if (data->type == EV_ABS) { + if (data->code == ABS_X) { + m_x = data->value; + } else if (data->code == ABS_Y) { + m_y = data->value; + } else { + unknown = true; + } + } else if (data->type == EV_REL) { + if (data->code == REL_X) { + m_x += data->value; + } else if (data->code == REL_Y) { + m_y += data->value; + } else { + unknown = true; + } + } else if (data->type == EV_KEY && data->code == BTN_TOUCH) { + m_buttons = data->value ? Qt::LeftButton : Qt::NoButton; + } else if (data->type == EV_KEY) { + Qt::MouseButton button = Qt::NoButton; + switch (data->code) { + case BTN_LEFT: button = Qt::LeftButton; break; + case BTN_MIDDLE: button = Qt::MidButton; break; + case BTN_RIGHT: button = Qt::RightButton; break; + } + if (data->value) + m_buttons |= button; + else + m_buttons &= ~button; + + Qt::KeyboardModifiers modifiers = Qt::NoModifier; //### + QMouseEvent m(data->value ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease, + QPoint(m_x, m_y), QPoint(m_x, m_y), button, m_buttons, modifiers); + QApplicationPrivate::handleMouseEvent(0, m); + } else if (data->type == EV_SYN && data->code == SYN_REPORT) { + QPoint pos(m_x, m_y); + + Qt::KeyboardModifiers modifiers = Qt::NoModifier; //### + QMouseEvent m(QEvent::MouseMove, QPoint(m_x, m_y), QPoint(m_x, m_y), + Qt::NoButton, m_buttons, modifiers); + QApplicationPrivate::handleMouseEvent(0, m); + + // pos = m_handler->transform(pos); + //m_handler->limitToScreen(pos); + //m_handler->mouseChanged(pos, m_buttons); + + } else if (data->type == EV_MSC && data->code == MSC_SCAN) { + // kernel encountered an unmapped key - just ignore it + continue; + } else { + unknown = true; + } + if (unknown) { + qWarning("unknown mouse event type=%x, code=%x, value=%x", data->type, data->code, data->value); + } + } +} + + + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +//Keyboard handler + + + + +class QWSLinuxInputKeyboardHandler : public QWSKeyboardHandler +{ +public: + QWSLinuxInputKeyboardHandler(const QString&); + ~QWSLinuxInputKeyboardHandler(); + + virtual bool filterInputEvent(quint16 &input_code, qint32 &input_value); + +//private: +// QWSLinuxInputKbPrivate *d; +}; + + +QWSLinuxInputKeyboardHandler::QWSLinuxInputKeyboardHandler(const QString &device) + : QWSKeyboardHandler(device) +{ +} + +QWSLinuxInputKeyboardHandler::~QWSLinuxInputKeyboardHandler() +{ +} + +bool QWSLinuxInputKeyboardHandler::filterInputEvent(quint16 &, qint32 &) +{ + return false; +} + + +QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(const QString &key, const QString &specification) + : m_handler(0), m_fd(-1), m_tty_fd(-1), m_orig_kbmode(K_XLATE) +{ + setObjectName(QLatin1String("LinuxInputSubsystem Keyboard Handler")); + + QString dev = QLatin1String("/dev/input/event1"); + int repeat_delay = -1; + int repeat_rate = -1; + + QStringList args = specification.split(QLatin1Char(':')); + foreach (const QString &arg, args) { + if (arg.startsWith(QLatin1String("repeat-delay="))) + repeat_delay = arg.mid(13).toInt(); + else if (arg.startsWith(QLatin1String("repeat-rate="))) + repeat_rate = arg.mid(12).toInt(); + else if (arg.startsWith(QLatin1String("/dev/"))) + dev = arg; + } + + m_handler = new QWSLinuxInputKeyboardHandler(dev); //This is a hack to avoid copying all the QWS code + + m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0); + if (m_fd >= 0) { + if (repeat_delay > 0 && repeat_rate > 0) { + int kbdrep[2] = { repeat_delay, repeat_rate }; + ::ioctl(m_fd, EVIOCSREP, kbdrep); + } + + QSocketNotifier *notifier; + notifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); + connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode())); + + // play nice in case we are started from a shell (e.g. for debugging) + m_tty_fd = isatty(0) ? 0 : -1; + + if (m_tty_fd >= 0) { + // save tty config for restore. + tcgetattr(m_tty_fd, &m_tty_attr); + + struct ::termios termdata; + tcgetattr(m_tty_fd, &termdata); + + // record the original mode so we can restore it again in the destructor. + ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode); + + // setting this tranlation mode is even needed in INPUT mode to prevent + // the shell from also interpreting codes, if the process has a tty + // attached: e.g. Ctrl+C wouldn't copy, but kill the application. + ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW); + + // set the tty layer to pass-through + termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); + termdata.c_oflag = 0; + termdata.c_cflag = CREAD | CS8; + termdata.c_lflag = 0; + termdata.c_cc[VTIME]=0; + termdata.c_cc[VMIN]=1; + cfsetispeed(&termdata, 9600); + cfsetospeed(&termdata, 9600); + tcsetattr(m_tty_fd, TCSANOW, &termdata); + } + } else { + qWarning("Cannot open keyboard input device '%s': %s", qPrintable(dev), strerror(errno)); + return; + } +} + +QLinuxInputKeyboardHandler::~QLinuxInputKeyboardHandler() +{ + if (m_tty_fd >= 0) { + ::ioctl(m_tty_fd, KDSKBMODE, m_orig_kbmode); + tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr); + } + if (m_fd >= 0) + QT_CLOSE(m_fd); + delete m_handler; +} + +void QLinuxInputKeyboardHandler::switchLed(int led, bool state) +{ + struct ::input_event led_ie; + ::gettimeofday(&led_ie.time, 0); + led_ie.type = EV_LED; + led_ie.code = led; + led_ie.value = state; + + QT_WRITE(m_fd, &led_ie, sizeof(led_ie)); +} + + + +void QLinuxInputKeyboardHandler::readKeycode() +{ + struct ::input_event buffer[32]; + int n = 0; + + forever { + n = QT_READ(m_fd, reinterpret_cast(buffer) + n, sizeof(buffer) - n); + + if (n == 0) { + qWarning("Got EOF from the input device."); + return; + } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) { + qWarning("Could not read from input device: %s", strerror(errno)); + return; + } else if (n % sizeof(buffer[0]) == 0) { + break; + } + } + + n /= sizeof(buffer[0]); + + for (int i = 0; i < n; ++i) { + if (buffer[i].type != EV_KEY) + continue; + + quint16 code = buffer[i].code; + qint32 value = buffer[i].value; + + if (m_handler->filterInputEvent(code, value)) + continue; + + QWSKeyboardHandler::KeycodeAction ka; + ka = m_handler->processKeycode(code, value != 0, value == 2); + + switch (ka) { + case QWSKeyboardHandler::CapsLockOn: + case QWSKeyboardHandler::CapsLockOff: + switchLed(LED_CAPSL, ka == QWSKeyboardHandler::CapsLockOn); + break; + + case QWSKeyboardHandler::NumLockOn: + case QWSKeyboardHandler::NumLockOff: + switchLed(LED_NUML, ka == QWSKeyboardHandler::NumLockOn); + break; + + case QWSKeyboardHandler::ScrollLockOn: + case QWSKeyboardHandler::ScrollLockOff: + switchLed(LED_SCROLLL, ka == QWSKeyboardHandler::ScrollLockOn); + break; + + default: + // ignore console switching and reboot + break; + } + } +} + + + + + +QT_END_NAMESPACE diff --git a/src/plugins/generic/linuxinput/qlinuxinput.h b/src/plugins/generic/linuxinput/qlinuxinput.h new file mode 100644 index 0000000..5a90c8f --- /dev/null +++ b/src/plugins/generic/linuxinput/qlinuxinput.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 QLINUXINPUT_H +#define QLINUXINPUT_H + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QSocketNotifier; + +class QLinuxInputMouseHandler : public QObject +{ + Q_OBJECT +public: + QLinuxInputMouseHandler(const QString &key, const QString &specification); + ~QLinuxInputMouseHandler(); + +private slots: + void readMouseData(); + +private: + QSocketNotifier * m_notify; + int m_fd; + int m_x, m_y; + Qt::MouseButtons m_buttons; +}; + + +class QWSLinuxInputKeyboardHandler; + +class QLinuxInputKeyboardHandler : public QObject +{ + Q_OBJECT +public: + QLinuxInputKeyboardHandler(const QString &key, const QString &specification); + ~QLinuxInputKeyboardHandler(); + + +private: + void switchLed(int, bool); + +private slots: + void readKeycode(); + +private: + QWSLinuxInputKeyboardHandler *m_handler; + int m_fd; + int m_tty_fd; + struct termios m_tty_attr; + int m_orig_kbmode; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QLINUXINPUT_H diff --git a/src/plugins/graphicssystems/graphicssystems.pro b/src/plugins/graphicssystems/graphicssystems.pro index 14e3cfc..12b2c51 100644 --- a/src/plugins/graphicssystems/graphicssystems.pro +++ b/src/plugins/graphicssystems/graphicssystems.pro @@ -1,9 +1,23 @@ TEMPLATE = subdirs SUBDIRS += trace contains(QT_CONFIG, opengl):SUBDIRS += opengl -contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl):SUBDIRS += openvg +contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl) { + embedded_lite { + SUBDIRS += openvglite + } else { + SUBDIRS += openvg + } +} contains(QT_CONFIG, shivavg) { # Only works under X11 at present !win32:!embedded:!mac:SUBDIRS += shivavg } + +embedded_lite: { + SUBDIRS += minimal +} + +embedded_lite:x11 { + SUBDIRS += linuxfb +} \ No newline at end of file diff --git a/src/plugins/graphicssystems/linuxfb/linuxfb.pro b/src/plugins/graphicssystems/linuxfb/linuxfb.pro new file mode 100644 index 0000000..1251d2f --- /dev/null +++ b/src/plugins/graphicssystems/linuxfb/linuxfb.pro @@ -0,0 +1,10 @@ +TARGET = qlinuxfbgraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp qgraphicssystem_linuxfb.cpp qwindowsurface_linuxfb.cpp +HEADERS = qgraphicssystem_linuxfb.h qwindowsurface_linuxfb.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/graphicssystems/linuxfb/main.cpp b/src/plugins/graphicssystems/linuxfb/main.cpp new file mode 100644 index 0000000..ef6234d --- /dev/null +++ b/src/plugins/graphicssystems/linuxfb/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 +#include "qgraphicssystem_linuxfb.h" + +QT_BEGIN_NAMESPACE + +class QLinuxFbGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QLinuxFbGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "LinuxFb"; + return list; +} + +QGraphicsSystem* QLinuxFbGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "linuxfb") + return new QLinuxFbGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(linuxfb, QLinuxFbGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp new file mode 100644 index 0000000..cd0ced2 --- /dev/null +++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp @@ -0,0 +1,797 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 "qgraphicssystem_linuxfb.h" +#include "qwindowsurface_linuxfb.h" +#include +#include // overrides QT_OPEN + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if !defined(Q_OS_DARWIN) && !defined(Q_OS_FREEBSD) +#include + +#ifdef __i386__ +#include +#endif +#endif + +QT_BEGIN_NAMESPACE + +class QLinuxFbGraphicsSystemPrivate +{ +public: + QLinuxFbGraphicsSystemPrivate(); + ~QLinuxFbGraphicsSystemPrivate(); + + void openTty(); + void closeTty(); + + int fd; + int startupw; + int startuph; + int startupd; + bool blank; + + bool doGraphicsMode; +#ifdef QT_QWS_DEPTH_GENERIC + bool doGenericColors; +#endif + int ttyfd; + long oldKdMode; + QString ttyDevice; + QString displaySpec; +}; + +QLinuxFbGraphicsSystemPrivate::QLinuxFbGraphicsSystemPrivate() + : fd(-1), blank(true), doGraphicsMode(true), +#ifdef QT_QWS_DEPTH_GENERIC + doGenericColors(false), +#endif + ttyfd(-1), oldKdMode(KD_TEXT) +{ +} + +QLinuxFbGraphicsSystemPrivate::~QLinuxFbGraphicsSystemPrivate() +{ + closeTty(); +} + +void QLinuxFbGraphicsSystemPrivate::openTty() +{ + const char *const devs[] = {"/dev/tty0", "/dev/tty", "/dev/console", 0}; + + if (ttyDevice.isEmpty()) { + for (const char * const *dev = devs; *dev; ++dev) { + ttyfd = QT_OPEN(*dev, O_RDWR); + if (ttyfd != -1) + break; + } + } else { + ttyfd = QT_OPEN(ttyDevice.toAscii().constData(), O_RDWR); + } + + if (ttyfd == -1) + return; + + if (doGraphicsMode) { + ioctl(ttyfd, KDGETMODE, &oldKdMode); + if (oldKdMode != KD_GRAPHICS) { + int ret = ioctl(ttyfd, KDSETMODE, KD_GRAPHICS); + if (ret == -1) + doGraphicsMode = false; + } + } + + // No blankin' screen, no blinkin' cursor!, no cursor! + const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c"; + QT_WRITE(ttyfd, termctl, sizeof(termctl)); +} + +void QLinuxFbGraphicsSystemPrivate::closeTty() +{ + if (ttyfd == -1) + return; + + if (doGraphicsMode) + ioctl(ttyfd, KDSETMODE, oldKdMode); + + // Blankin' screen, blinkin' cursor! + const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c"; + QT_WRITE(ttyfd, termctl, sizeof(termctl)); + + QT_CLOSE(ttyfd); + ttyfd = -1; +} + +QLinuxFbGraphicsSystem::QLinuxFbGraphicsSystem() +{ + d_ptr = new QLinuxFbGraphicsSystemPrivate(); + + // XXX + QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY")); + + if (!connect(displaySpec)) + qFatal("QLinuxFbGraphicsSystem: could not initialize screen"); + + mPrimaryScreen = new QLinuxFbGraphicsSystemScreen(); + mPrimaryScreen->mGeometry = QRect(0, 0, w, h); + mPrimaryScreen->mDepth = d; + mPrimaryScreen->mFormat = screenFormat; + mPrimaryScreen->mPhysicalSize = QSize(physWidth, physHeight); + + // Create a QImage directly on the screen's framebuffer. + // This is the blit target for copying windows to the screen. + mPrimaryScreen->mScreenImage = new QImage(data, w, h, lstep, screenFormat); + + mScreens.append(mPrimaryScreen); +} + +QLinuxFbGraphicsSystem::~QLinuxFbGraphicsSystem() +{ + delete mPrimaryScreen; + delete d_ptr; +} + +bool QLinuxFbGraphicsSystem::connect(const QString &displaySpec) +{ + const QStringList args = displaySpec.split(QLatin1Char(':')); + + if (args.contains(QLatin1String("nographicsmodeswitch"))) + d_ptr->doGraphicsMode = false; + +#ifdef QT_QWS_DEPTH_GENERIC + if (args.contains(QLatin1String("genericcolors"))) + d_ptr->doGenericColors = true; +#endif + + QRegExp ttyRegExp(QLatin1String("tty=(.*)")); + if (args.indexOf(ttyRegExp) != -1) + d_ptr->ttyDevice = ttyRegExp.cap(1); + +#if 0 +#if Q_BYTE_ORDER == Q_BIG_ENDIAN +#ifndef QT_QWS_FRAMEBUFFER_LITTLE_ENDIAN + if (args.contains(QLatin1String("littleendian"))) +#endif + QScreen::setFrameBufferLittleEndian(true); +#endif +#endif + + // Check for explicitly specified device + const int len = 8; // "/dev/fbx" + int m = displaySpec.indexOf(QLatin1String("/dev/fb")); + + QString dev; + if (m > 0) + dev = displaySpec.mid(m, len); + else + dev = QLatin1String("/dev/fb0"); + + if (access(dev.toLatin1().constData(), R_OK|W_OK) == 0) + d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDWR); + if (d_ptr->fd == -1) { + if (access(dev.toLatin1().constData(), R_OK) == 0) + d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDONLY); + if (d_ptr->fd == 1) { + qWarning("Error opening framebuffer device %s", qPrintable(dev)); + return false; + } + } + + fb_fix_screeninfo finfo; + fb_var_screeninfo vinfo; + //####################### + // Shut up Valgrind + memset(&vinfo, 0, sizeof(vinfo)); + memset(&finfo, 0, sizeof(finfo)); + //####################### + + /* Get fixed screen information */ + if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) { + perror("QLinuxFbGraphicsSystem::connect"); + qWarning("Error reading fixed information"); + return false; + } + + if (finfo.type == FB_TYPE_VGA_PLANES) { + qWarning("VGA16 video mode not supported"); + return false; + } + + /* Get variable screen information */ + if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) { + perror("QLinuxFbGraphicsSystem::connect"); + qWarning("Error reading variable information"); + return false; + } + + grayscale = vinfo.grayscale; + d = vinfo.bits_per_pixel; + if (d == 24) { + d = vinfo.red.length + vinfo.green.length + vinfo.blue.length; + if (d <= 0) + d = 24; // reset if color component lengths are not reported + } else if (d == 16) { + d = vinfo.red.length + vinfo.green.length + vinfo.blue.length; + if (d <= 0) + d = 16; + } + lstep = finfo.line_length; + + int xoff = vinfo.xoffset; + int yoff = vinfo.yoffset; + const char* qwssize; + if((qwssize=::getenv("QWS_SIZE")) && sscanf(qwssize,"%dx%d",&w,&h)==2) { + if (d_ptr->fd != -1) { + if ((uint)w > vinfo.xres) w = vinfo.xres; + if ((uint)h > vinfo.yres) h = vinfo.yres; + } + dw=w; + dh=h; + int xxoff, yyoff; + if (sscanf(qwssize, "%*dx%*d+%d+%d", &xxoff, &yyoff) == 2) { + if (xxoff < 0 || xxoff + w > (int)(vinfo.xres)) + xxoff = vinfo.xres - w; + if (yyoff < 0 || yyoff + h > (int)(vinfo.yres)) + yyoff = vinfo.yres - h; + xoff += xxoff; + yoff += yyoff; + } else { + xoff += (vinfo.xres - w)/2; + yoff += (vinfo.yres - h)/2; + } + } else { + dw=w=vinfo.xres; + dh=h=vinfo.yres; + } + + if (w == 0 || h == 0) { + qWarning("QLinuxFbGraphicsSystem::connect(): Unable to find screen geometry, " + "will use 320x240."); + dw = w = 320; + dh = h = 240; + } + + setPixelFormat(vinfo); + + // Handle display physical size spec. + QStringList displayArgs = displaySpec.split(QLatin1Char(':')); + QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)")); + int dimIdxW = displayArgs.indexOf(mmWidthRx); + QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)")); + int dimIdxH = displayArgs.indexOf(mmHeightRx); + if (dimIdxW >= 0) { + mmWidthRx.exactMatch(displayArgs.at(dimIdxW)); + physWidth = mmWidthRx.cap(1).toInt(); + if (dimIdxH < 0) + physHeight = dh*physWidth/dw; + } + if (dimIdxH >= 0) { + mmHeightRx.exactMatch(displayArgs.at(dimIdxH)); + physHeight = mmHeightRx.cap(1).toInt(); + if (dimIdxW < 0) + physWidth = dw*physHeight/dh; + } + if (dimIdxW < 0 && dimIdxH < 0) { + if (vinfo.width != 0 && vinfo.height != 0 + && vinfo.width != UINT_MAX && vinfo.height != UINT_MAX) { + physWidth = vinfo.width; + physHeight = vinfo.height; + } else { + const int dpi = 72; + physWidth = qRound(dw * 25.4 / dpi); + physHeight = qRound(dh * 25.4 / dpi); + } + } + + dataoffset = yoff * lstep + xoff * d / 8; + //qDebug("Using %dx%dx%d screen",w,h,d); + + /* Figure out the size of the screen in bytes */ + size = h * lstep; + + mapsize = finfo.smem_len; + + data = (unsigned char *)-1; + if (d_ptr->fd != -1) + data = (unsigned char *)mmap(0, mapsize, PROT_READ | PROT_WRITE, + MAP_SHARED, d_ptr->fd, 0); + + if ((long)data == -1) { + perror("QLinuxFbGraphicsSystem::connect"); + qWarning("Error: failed to map framebuffer device to memory."); + return false; + } else { + data += dataoffset; + } + +#if 0 + canaccel = useOffscreen(); + if(canaccel) + setupOffScreen(); +#endif + canaccel = false; + + // Now read in palette + if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { + screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; + int loopc; + fb_cmap startcmap; + startcmap.start=0; + startcmap.len=screencols; + startcmap.red=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + startcmap.green=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + startcmap.blue=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + startcmap.transp=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + if (d_ptr->fd == -1 || ioctl(d_ptr->fd, FBIOGETCMAP, &startcmap)) { + perror("QLinuxFbGraphicsSystem::connect"); + qWarning("Error reading palette from framebuffer, using default palette"); + createPalette(startcmap, vinfo, finfo); + } + int bits_used = 0; + for(loopc=0;loopc> 8, + startcmap.green[loopc] >> 8, + startcmap.blue[loopc] >> 8); + bits_used |= startcmap.red[loopc] + | startcmap.green[loopc] + | startcmap.blue[loopc]; + } + // WORKAROUND: Some framebuffer drivers only return 8 bit + // color values, so we need to not bit shift them.. + if ((bits_used & 0x00ff) && !(bits_used & 0xff00)) { + for(loopc=0;loopcopenTty(); + + // Grab current mode so we can reset it + fb_var_screeninfo vinfo; + fb_fix_screeninfo finfo; + //####################### + // Shut up Valgrind + memset(&vinfo, 0, sizeof(vinfo)); + memset(&finfo, 0, sizeof(finfo)); + //####################### + + if (ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) { + perror("QLinuxFbScreen::initDevice"); + qFatal("Error reading variable information in card init"); + return false; + } + +#ifdef DEBUG_VINFO + qDebug("Greyscale %d",vinfo.grayscale); + qDebug("Nonstd %d",vinfo.nonstd); + qDebug("Red %d %d %d",vinfo.red.offset,vinfo.red.length, + vinfo.red.msb_right); + qDebug("Green %d %d %d",vinfo.green.offset,vinfo.green.length, + vinfo.green.msb_right); + qDebug("Blue %d %d %d",vinfo.blue.offset,vinfo.blue.length, + vinfo.blue.msb_right); + qDebug("Transparent %d %d %d",vinfo.transp.offset,vinfo.transp.length, + vinfo.transp.msb_right); +#endif + + d_ptr->startupw=vinfo.xres; + d_ptr->startuph=vinfo.yres; + d_ptr->startupd=vinfo.bits_per_pixel; + grayscale = vinfo.grayscale; + + if (ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) { + perror("QLinuxFbScreen::initDevice"); + qCritical("Error reading fixed information in card init"); + // It's not an /error/ as such, though definitely a bad sign + // so we return true + return true; + } + +#ifdef __i386__ + // Now init mtrr + if(!::getenv("QWS_NOMTRR")) { + int mfd=QT_OPEN("/proc/mtrr",O_WRONLY,0); + // MTRR entry goes away when file is closed - i.e. + // hopefully when QWS is killed + if(mfd != -1) { + mtrr_sentry sentry; + sentry.base=(unsigned long int)finfo.smem_start; + //qDebug("Physical framebuffer address %p",(void*)finfo.smem_start); + // Size needs to be in 4k chunks, but that's not always + // what we get thanks to graphics card registers. Write combining + // these is Not Good, so we write combine what we can + // (which is not much - 4 megs on an 8 meg card, it seems) + unsigned int size=finfo.smem_len; + size=size >> 22; + size=size << 22; + sentry.size=size; + sentry.type=MTRR_TYPE_WRCOMB; + if(ioctl(mfd,MTRRIOC_ADD_ENTRY,&sentry)==-1) { + //printf("Couldn't add mtrr entry for %lx %lx, %s\n", + //sentry.base,sentry.size,strerror(errno)); + } + } + + // Should we close mfd here? + //QT_CLOSE(mfd); + } +#endif + if ((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4) || (finfo.visual==FB_VISUAL_DIRECTCOLOR)) + { + fb_cmap cmap; + createPalette(cmap, vinfo, finfo); + if (ioctl(d_ptr->fd, FBIOPUTCMAP, &cmap)) { + perror("QLinuxFbScreen::initDevice"); + qWarning("Error writing palette to framebuffer"); + } + free(cmap.red); + free(cmap.green); + free(cmap.blue); + free(cmap.transp); + } + +#if 0 + if (canaccel) { + *entryp=0; + *lowest = mapsize; + insert_entry(*entryp, *lowest, *lowest); // dummy entry to mark start + } + + shared->fifocount = 0; + shared->buffer_offset = 0xffffffff; // 0 would be a sensible offset (screen) + shared->linestep = 0; + shared->cliptop = 0xffffffff; + shared->clipleft = 0xffffffff; + shared->clipright = 0xffffffff; + shared->clipbottom = 0xffffffff; + shared->rop = 0xffffffff; +#endif + +#ifdef QT_QWS_DEPTH_GENERIC + if (pixelFormat() == QImage::Format_Invalid && screencols == 0 + && d_ptr->doGenericColors) + { + qt_set_generic_blit(this, vinfo.bits_per_pixel, + vinfo.red.length, vinfo.green.length, + vinfo.blue.length, vinfo.transp.length, + vinfo.red.offset, vinfo.green.offset, + vinfo.blue.offset, vinfo.transp.offset); + } +#endif + +#if 0 +#ifndef QT_NO_QWS_CURSOR + QScreenCursor::initSoftwareCursor(); +#endif +#endif + blank(false); + + return true; +} + +void QLinuxFbGraphicsSystem::setPixelFormat(struct fb_var_screeninfo info) +{ + const fb_bitfield rgba[4] = { info.red, info.green, + info.blue, info.transp }; + + QImage::Format format = QImage::Format_Invalid; + + switch (d) { + case 32: { + const fb_bitfield argb8888[4] = {{16, 8, 0}, {8, 8, 0}, + {0, 8, 0}, {24, 8, 0}}; + const fb_bitfield abgr8888[4] = {{0, 8, 0}, {8, 8, 0}, + {16, 8, 0}, {24, 8, 0}}; + if (memcmp(rgba, argb8888, 4 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_ARGB32; + } else if (memcmp(rgba, argb8888, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB32; + } else if (memcmp(rgba, abgr8888, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB32; + pixeltype = BGRPixel; + } + break; + } + case 24: { + const fb_bitfield rgb888[4] = {{16, 8, 0}, {8, 8, 0}, + {0, 8, 0}, {0, 0, 0}}; + const fb_bitfield bgr888[4] = {{0, 8, 0}, {8, 8, 0}, + {16, 8, 0}, {0, 0, 0}}; + if (memcmp(rgba, rgb888, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB888; + } else if (memcmp(rgba, bgr888, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB888; + pixeltype = BGRPixel; + } + break; + } + case 18: { + const fb_bitfield rgb666[4] = {{12, 6, 0}, {6, 6, 0}, + {0, 6, 0}, {0, 0, 0}}; + if (memcmp(rgba, rgb666, 3 * sizeof(fb_bitfield)) == 0) + format = QImage::Format_RGB666; + break; + } + case 16: { + const fb_bitfield rgb565[4] = {{11, 5, 0}, {5, 6, 0}, + {0, 5, 0}, {0, 0, 0}}; + const fb_bitfield bgr565[4] = {{0, 5, 0}, {5, 6, 0}, + {11, 5, 0}, {0, 0, 0}}; + if (memcmp(rgba, rgb565, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB16; + } else if (memcmp(rgba, bgr565, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB16; + pixeltype = BGRPixel; + } + break; + } + case 15: { + const fb_bitfield rgb1555[4] = {{10, 5, 0}, {5, 5, 0}, + {0, 5, 0}, {15, 1, 0}}; + const fb_bitfield bgr1555[4] = {{0, 5, 0}, {5, 5, 0}, + {10, 5, 0}, {15, 1, 0}}; + if (memcmp(rgba, rgb1555, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB555; + } else if (memcmp(rgba, bgr1555, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB555; + pixeltype = BGRPixel; + } + break; + } + case 12: { + const fb_bitfield rgb444[4] = {{8, 4, 0}, {4, 4, 0}, + {0, 4, 0}, {0, 0, 0}}; + if (memcmp(rgba, rgb444, 3 * sizeof(fb_bitfield)) == 0) + format = QImage::Format_RGB444; + break; + } + case 8: + break; + case 1: + format = QImage::Format_Mono; //###: LSB??? + break; + default: + break; + } + + screenFormat = format; +} + +void QLinuxFbGraphicsSystem::createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo) +{ + if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { + screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; + cmap.start=0; + cmap.len=screencols; + cmap.red=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + cmap.green=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + cmap.blue=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + cmap.transp=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + + if (screencols==16) { + if (finfo.type == FB_TYPE_PACKED_PIXELS) { + // We'll setup a grayscale cmap for 4bpp linear + int val = 0; + for (int idx = 0; idx < 16; ++idx, val += 17) { + cmap.red[idx] = (val<<8)|val; + cmap.green[idx] = (val<<8)|val; + cmap.blue[idx] = (val<<8)|val; + screenclut[idx]=qRgb(val, val, val); + } + } else { + // Default 16 colour palette + // Green is now trolltech green so certain images look nicer + // black d_gray l_gray white red green blue cyan magenta yellow + unsigned char reds[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0xFF, 0xA2, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x82 }; + unsigned char greens[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0xC5, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F }; + unsigned char blues[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0x11, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00 }; + + for (int idx = 0; idx < 16; ++idx) { + cmap.red[idx] = ((reds[idx]) << 8)|reds[idx]; + cmap.green[idx] = ((greens[idx]) << 8)|greens[idx]; + cmap.blue[idx] = ((blues[idx]) << 8)|blues[idx]; + cmap.transp[idx] = 0; + screenclut[idx]=qRgb(reds[idx], greens[idx], blues[idx]); + } + } + } else { + if (grayscale) { + // Build grayscale palette + int i; + for(i=0;iblank == on) + return; + +#if defined(QT_QWS_IPAQ) + if (on) + system("apm -suspend"); +#else + if (d_ptr->fd == -1) + return; +// Some old kernel versions don't have this. These defines should go +// away eventually +#if defined(FBIOBLANK) +#if defined(VESA_POWERDOWN) && defined(VESA_NO_BLANKING) + ioctl(d_ptr->fd, FBIOBLANK, on ? VESA_POWERDOWN : VESA_NO_BLANKING); +#else + ioctl(d_ptr->fd, FBIOBLANK, on ? 1 : 0); +#endif +#endif +#endif + + d_ptr->blank = on; +} + +QPixmapData *QLinuxFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QLinuxFbGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + if (widget->windowType() == Qt::Desktop) + return 0; // Don't create an explicit window surface for the destkop. + return new QLinuxFbWindowSurface(mPrimaryScreen, widget); +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h new file mode 100644 index 0000000..3446008 --- /dev/null +++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QGRAPHICSSYSTEM_LINUXFB_H +#define QGRAPHICSSYSTEM_LINUXFB_H + +#include + +QT_BEGIN_NAMESPACE + +class QLinuxFbGraphicsSystemScreen : public QGraphicsSystemScreen +{ +public: + QLinuxFbGraphicsSystemScreen() + : mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0) {} + ~QLinuxFbGraphicsSystemScreen() { delete mScreenImage; } + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; + QImage *mScreenImage; + +}; + +class QLinuxFbGraphicsSystemPrivate; +struct fb_cmap; +struct fb_var_screeninfo; +struct fb_fix_screeninfo; + +class QLinuxFbGraphicsSystem : public QGraphicsSystem +{ +public: + QLinuxFbGraphicsSystem(); + ~QLinuxFbGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList screens() const { return mScreens; } + +private: + QLinuxFbGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; + QLinuxFbGraphicsSystemPrivate *d_ptr; + + enum PixelType { NormalPixel, BGRPixel }; + + QRgb screenclut[256]; + int screencols; + + uchar * data; + + QImage::Format screenFormat; + int w; + int lstep; + int h; + int d; + PixelType pixeltype; + bool grayscale; + + int dw; + int dh; + + int size; // Screen size + int mapsize; // Total mapped memory + + int displayId; + + int physWidth; + int physHeight; + + bool canaccel; + int dataoffset; + int cacheStart; + + bool connect(const QString &displaySpec); + bool initDevice(); + void setPixelFormat(struct fb_var_screeninfo); + void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo); + void blank(bool on); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp new file mode 100644 index 0000000..bfc2f83 --- /dev/null +++ b/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 "qwindowsurface_linuxfb.h" +#include "qgraphicssystem_linuxfb.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QLinuxFbWindowSurface::QLinuxFbWindowSurface + (QLinuxFbGraphicsSystemScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen) +{ +} + +QLinuxFbWindowSurface::~QLinuxFbWindowSurface() +{ +} + +QPaintDevice *QLinuxFbWindowSurface::paintDevice() +{ + return &mImage; +} + +void QLinuxFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(offset); + + QRect rect = geometry(); + QPoint topLeft = rect.topLeft(); + + QPainter painter(mScreen->mScreenImage); + if (region.numRects() == 1) { + QRect wrect = region.boundingRect(); + painter.drawImage(wrect.topLeft() + topLeft, mImage, wrect); + } else { + QVector rects = region.rects(); + foreach (QRect wrect, rects) + painter.drawImage(wrect.topLeft() + topLeft, mImage, wrect); + } +} + +void QLinuxFbWindowSurface::setGeometry(const QRect &r) +{ +#ifdef QT_LITE_FORCE_FULLSCREEN +// any size you like as long as it's full-screen... + QRect rect(mScreen->availableGeometry()); + QApplicationPrivate::handleGeometryChange(this->window(), rect); +#else + QRect rect(r); +#endif + QWindowSurface::setGeometry(rect); + if (mImage.size() != rect.size()) + mImage = QImage(rect.size(), mScreen->format()); +} + +bool QLinuxFbWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QLinuxFbWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QLinuxFbWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h b/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h new file mode 100644 index 0000000..763f362 --- /dev/null +++ b/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_LINUXFB_H +#define QWINDOWSURFACE_LINUXFB_H + +#include + +QT_BEGIN_NAMESPACE + +class QLinuxFbGraphicsSystemScreen; + +class QLinuxFbWindowSurface : public QWindowSurface +{ +public: + QLinuxFbWindowSurface + (QLinuxFbGraphicsSystemScreen *screen, QWidget *window); + ~QLinuxFbWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + +private: + QLinuxFbGraphicsSystemScreen *mScreen; + QImage mImage; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/minimal/main.cpp b/src/plugins/graphicssystems/minimal/main.cpp new file mode 100644 index 0000000..f7d5eef --- /dev/null +++ b/src/plugins/graphicssystems/minimal/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 +#include "qgraphicssystem_minimal.h" + +QT_BEGIN_NAMESPACE + +class QMinimalGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QMinimalGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "Minimal"; + return list; +} + +QGraphicsSystem* QMinimalGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "minimal") + return new QMinimalGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(minimal, QMinimalGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimal/minimal.pro b/src/plugins/graphicssystems/minimal/minimal.pro new file mode 100644 index 0000000..11604dd --- /dev/null +++ b/src/plugins/graphicssystems/minimal/minimal.pro @@ -0,0 +1,10 @@ +TARGET = qminimalgraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp qgraphicssystem_minimal.cpp qwindowsurface_minimal.cpp +HEADERS = qgraphicssystem_minimal.h qwindowsurface_minimal.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp b/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp new file mode 100644 index 0000000..31023fc --- /dev/null +++ b/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 "qgraphicssystem_minimal.h" +#include "qwindowsurface_minimal.h" +#include + +QT_BEGIN_NAMESPACE + +QMinimalGraphicsSystem::QMinimalGraphicsSystem() +{ + mPrimaryScreen = new QMinimalGraphicsSystemScreen(); + + mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320); + mPrimaryScreen->mDepth = 16; + mPrimaryScreen->mFormat = QImage::Format_RGB16; + mPrimaryScreen->mPhysicalSize = QSize(40, 54); + + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QMinimalGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QMinimalGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + return new QMinimalWindowSurface(mPrimaryScreen, widget); +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h b/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h new file mode 100644 index 0000000..b15f6f6 --- /dev/null +++ b/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QGRAPHICSSYSTEM_MINIMAL_H +#define QGRAPHICSSYSTEM_MINIMAL_H + +#include + +QT_BEGIN_NAMESPACE + +class QMinimalGraphicsSystemScreen : public QGraphicsSystemScreen +{ +public: + QMinimalGraphicsSystemScreen() + : mDepth(16), mFormat(QImage::Format_RGB16) {} + ~QMinimalGraphicsSystemScreen() {} + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; +}; + +class QMinimalGraphicsSystem : public QGraphicsSystem +{ +public: + QMinimalGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList screens() const { return mScreens; } + +private: + QMinimalGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp b/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp new file mode 100644 index 0000000..e9d7d69 --- /dev/null +++ b/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 "qwindowsurface_minimal.h" +#include "qgraphicssystem_minimal.h" +#include + +QT_BEGIN_NAMESPACE + +QMinimalWindowSurface::QMinimalWindowSurface + (QMinimalGraphicsSystemScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen) +{ + //qDebug() << "QMinimalWindowSurface::QMinimalWindowSurface:" << (long)this; +} + +QMinimalWindowSurface::~QMinimalWindowSurface() +{ +} + +QPaintDevice *QMinimalWindowSurface::paintDevice() +{ + //qDebug() << "QMinimalWindowSurface::paintDevice"; + return &mImage; +} + +void QMinimalWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); + + static int c = 0; + QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0')); + qDebug() << "QMinimalWindowSurface::flush() saving contents to" << filename.toLocal8Bit().constData(); + mImage.save(filename); +} + +void QMinimalWindowSurface::setGeometry(const QRect &rect) +{ + //qDebug() << "QMinimalWindowSurface::setGeometry:" << (long)this << rect; + QWindowSurface::setGeometry(rect); + if (mImage.size() != rect.size()) + mImage = QImage(rect.size(), mScreen->format()); +} + +bool QMinimalWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QMinimalWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QMinimalWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h b/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h new file mode 100644 index 0000000..89dc860 --- /dev/null +++ b/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_MINIMAL_H +#define QWINDOWSURFACE_MINIMAL_H + +#include + +QT_BEGIN_NAMESPACE + +class QMinimalGraphicsSystemScreen; + +class QMinimalWindowSurface : public QWindowSurface +{ +public: + QMinimalWindowSurface + (QMinimalGraphicsSystemScreen *screen, QWidget *window); + ~QMinimalWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + +private: + QMinimalGraphicsSystemScreen *mScreen; + QImage mImage; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/openvglite/main.cpp b/src/plugins/graphicssystems/openvglite/main.cpp new file mode 100644 index 0000000..3a73f5c --- /dev/null +++ b/src/plugins/graphicssystems/openvglite/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 +#include "qgraphicssystem_vglite.h" + +QT_BEGIN_NAMESPACE + +class QVGGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QVGGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "OpenVG"; + return list; +} + +QGraphicsSystem* QVGGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "openvg") + return new QVGLiteGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(openvg, QVGGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openvglite/openvglite.pro b/src/plugins/graphicssystems/openvglite/openvglite.pro new file mode 100644 index 0000000..9d7860a --- /dev/null +++ b/src/plugins/graphicssystems/openvglite/openvglite.pro @@ -0,0 +1,12 @@ +TARGET = qvglitegraphicssystem +include(../../qpluginbase.pri) + +QT += openvg + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp qgraphicssystem_vglite.cpp qwindowsurface_vglite.cpp +HEADERS = qgraphicssystem_vglite.h qwindowsurface_vglite.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp b/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp new file mode 100644 index 0000000..cc5b012 --- /dev/null +++ b/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 "qgraphicssystem_vglite.h" +#include "qwindowsurface_vglite.h" +#include +#include +#include +#ifdef OPENVG_USBHP_INIT +extern "C" { +#include +}; +#endif + +QT_BEGIN_NAMESPACE + +QVGLiteGraphicsSystem::QVGLiteGraphicsSystem() + : w(0), h(0), d(0), dw(0), dh(0), physWidth(0), physHeight(0), + surface(0), context(0), rootWindow(0), + screenFormat(QImage::Format_RGB16), preservedSwap(false) +{ +#ifdef OPENVG_USBHP_INIT + initLibrary(); +#endif + + // The graphics system is also the screen definition. + mScreens.append(this); + + QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY")); + QStringList displayArgs = displaySpec.split(QLatin1Char(':')); + + // Initialize EGL and create the global EGL context. + context = qt_vg_create_context(0); + if (!context) { + qFatal("QVGLiteGraphicsSystem: could not initialize EGL"); + return; + } + + // Get the root window handle to use. Default to zero. + QRegExp winidRx(QLatin1String("winid=?(\\d+)")); + int winidIdx = displayArgs.indexOf(winidRx); + int handle = 0; + if (winidIdx >= 0) { + winidRx.exactMatch(displayArgs.at(winidIdx)); + handle = winidRx.cap(1).toInt(); + } + + // Create a full-screen window based on the native handle. + // If the context is premultiplied, the window should be too. + QEglProperties props; +#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT + EGLint surfaceType = 0; + if (context->configAttrib(EGL_SURFACE_TYPE, &surfaceType) && + (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) != 0) + props.setValue(EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE); +#endif + rootWindow = eglCreateWindowSurface + (context->display(), context->config(), + (EGLNativeWindowType)handle, props.properties()); + if (rootWindow == EGL_NO_SURFACE) { + delete context; + context = 0; + qFatal("QVGLiteGraphicsSystem: could not create full-screen window"); + return; + } + + // Try to turn on preserved swap behaviour on the root window. + // This will allow us to optimize compositing to focus on just + // the screen region that has changed. Otherwise we must + // re-composite the entire screen every frame. +#if !defined(QVG_NO_PRESERVED_SWAP) + eglGetError(); // Clear error state first. + eglSurfaceAttrib(context->display(), rootWindow, + EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); + preservedSwap = (eglGetError() == EGL_SUCCESS); +#else + preservedSwap = false; +#endif + + // Fetch the root window properties. + eglQuerySurface(context->display(), rootWindow, EGL_WIDTH, &w); + eglQuerySurface(context->display(), rootWindow, EGL_HEIGHT, &h); + screenFormat = qt_vg_config_to_image_format(context); + switch (screenFormat) { + case QImage::Format_ARGB32_Premultiplied: + case QImage::Format_ARGB32: + case QImage::Format_RGB32: + default: + d = 32; + break; + case QImage::Format_RGB16: + case QImage::Format_ARGB4444_Premultiplied: + d = 16; + break; + } + dw = w; + dh = h; + qDebug("screen size: %dx%dx%d", w, h, d); + + // Handle display physical size spec. From qscreenlinuxfb_qws.cpp. + QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)")); + int dimIdxW = displayArgs.indexOf(mmWidthRx); + QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)")); + int dimIdxH = displayArgs.indexOf(mmHeightRx); + if (dimIdxW >= 0) { + mmWidthRx.exactMatch(displayArgs.at(dimIdxW)); + physWidth = mmWidthRx.cap(1).toInt(); + if (dimIdxH < 0) + physHeight = dh*physWidth/dw; + } + if (dimIdxH >= 0) { + mmHeightRx.exactMatch(displayArgs.at(dimIdxH)); + physHeight = mmHeightRx.cap(1).toInt(); + if (dimIdxW < 0) + physWidth = dw*physHeight/dh; + } + if (dimIdxW < 0 && dimIdxH < 0) { + const int dpi = 72; + physWidth = qRound(dw * 25.4 / dpi); + physHeight = qRound(dh * 25.4 / dpi); + } +} + +QVGLiteGraphicsSystem::~QVGLiteGraphicsSystem() +{ +} + +QPixmapData *QVGLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ +#if !defined(QVGLite_NO_SINGLE_CONTEXT) && !defined(QVGLite_NO_PIXMAP_DATA) + // Pixmaps can use QVGLitePixmapData; bitmaps must use raster. + if (type == QPixmapData::PixmapType) + return new QVGPixmapData(type); + else + return new QRasterPixmapData(type); +#else + return new QRasterPixmapData(type); +#endif +} + +QWindowSurface *QVGLiteGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + if (widget->windowType() == Qt::Desktop) + return 0; // Don't create an explicit window surface for the destkop. + if (surface) { + qWarning() << "QVGLiteGraphicsSystem: only one window surface " + "is supported at a time"; + return 0; + } + surface = new QVGLiteWindowSurface + (const_cast(this), widget); + return surface; +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h b/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h new file mode 100644 index 0000000..74fc41e --- /dev/null +++ b/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QGRAPHICSSYSTEM_VGLITE_H +#define QGRAPHICSSYSTEM_VGLITE_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QVGLiteWindowSurface; + +class QVGLiteGraphicsSystem : public QGraphicsSystem, + public QGraphicsSystemScreen +{ +public: + QVGLiteGraphicsSystem(); + ~QVGLiteGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + QList screens() const { return mScreens; } + + QRect geometry() const { return QRect(0, 0, w, h); } + int depth() const { return d; } + QImage::Format format() const { return screenFormat; } + QSize physicalSize() const { return QSize(physWidth, physHeight); } + +private: + friend class QVGLiteWindowSurface; + + int w; + int h; + int d; + + int dw; + int dh; + + int physWidth; + int physHeight; + + mutable QVGLiteWindowSurface *surface; + QEglContext *context; + EGLSurface rootWindow; + QImage::Format screenFormat; + bool preservedSwap; + + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp b/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp new file mode 100644 index 0000000..d250a8e --- /dev/null +++ b/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 "qwindowsurface_vglite.h" +#include "qgraphicssystem_vglite.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QVGLiteWindowSurface::QVGLiteWindowSurface + (QVGLiteGraphicsSystem *gs, QWidget *window) + : QWindowSurface(window), graphicsSystem(gs), + isPaintingActive(false), engine(0) +{ +} + +QVGLiteWindowSurface::~QVGLiteWindowSurface() +{ + graphicsSystem->surface = 0; + if (engine) + qt_vg_destroy_paint_engine(engine); +} + +QPaintDevice *QVGLiteWindowSurface::paintDevice() +{ + qt_vg_make_current(graphicsSystem->context, graphicsSystem->rootWindow); + isPaintingActive = true; + // TODO: clear the parts of the back buffer that are not + // covered by the window surface to black. + return this; +} + +void QVGLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); + QEglContext *context = graphicsSystem->context; + if (context) { + if (!isPaintingActive) + qt_vg_make_current(context, graphicsSystem->rootWindow); + context->swapBuffers(); + qt_vg_done_current(context); + context->setSurface(EGL_NO_SURFACE); + isPaintingActive = false; + } +} + +void QVGLiteWindowSurface::setGeometry(const QRect &rect) +{ + QWindowSurface::setGeometry(rect); +} + +bool QVGLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QVGLiteWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QVGLiteWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +QPaintEngine *QVGLiteWindowSurface::paintEngine() const +{ + if (!engine) + engine = qt_vg_create_paint_engine(); + return engine; +} + +// We need to get access to QWidget::metric() from QVGLiteWindowSurface::metric, +// but it is not a friend of QWidget. To get around this, we create a +// fake QX11PaintEngine class, which is a friend. +class QX11PaintEngine +{ +public: + static int metric(const QWidget *widget, QPaintDevice::PaintDeviceMetric met) + { + return widget->metric(met); + } +}; + +int QVGLiteWindowSurface::metric(PaintDeviceMetric met) const +{ + return QX11PaintEngine::metric(window(), met); +} diff --git a/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h b/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h new file mode 100644 index 0000000..c1ae02e --- /dev/null +++ b/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_VGLITE_H +#define QWINDOWSURFACE_VGLITE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QVGLiteGraphicsSystem; +class QVGPaintEngine; + +class Q_OPENVG_EXPORT QVGLiteWindowSurface : public QWindowSurface, public QPaintDevice +{ +public: + QVGLiteWindowSurface(QVGLiteGraphicsSystem *gs, QWidget *window); + ~QVGLiteWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + + QPaintEngine *paintEngine() const; + +protected: + int metric(PaintDeviceMetric metric) const; + +private: + QVGLiteGraphicsSystem *graphicsSystem; + bool isPaintingActive; + mutable QVGPaintEngine *engine; +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSURFACE_VGLITE_H diff --git a/src/plugins/graphicssystems/testlite/main.cpp b/src/plugins/graphicssystems/testlite/main.cpp new file mode 100644 index 0000000..6271829 --- /dev/null +++ b/src/plugins/graphicssystems/testlite/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 +#include "qgraphicssystem_testlite.h" + +QT_BEGIN_NAMESPACE + +class QTestLiteGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QTestLiteGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "TestLite"; + return list; +} + +QGraphicsSystem* QTestLiteGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "testlite") + return new QTestLiteGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(testlite, QTestLiteGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp new file mode 100644 index 0000000..b1948b9 --- /dev/null +++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 "qgraphicssystem_testlite.h" +#include "qwindowsurface_testlite.h" +#include +#include + +#include "x11util.h" + +QT_BEGIN_NAMESPACE + +QTestLiteGraphicsSystem::QTestLiteGraphicsSystem() +{ + xd = new MyDisplay; + + mPrimaryScreen = new QTestLiteGraphicsSystemScreen(); + + mPrimaryScreen->mGeometry = QRect + (0, 0, xd->width, xd->height); + mPrimaryScreen->mDepth = 32; + mPrimaryScreen->mFormat = QImage::Format_RGB32; + mPrimaryScreen->mPhysicalSize = + QSize(xd->physicalWidth, xd->physicalHeight); + + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QTestLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QTestLiteGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + if (widget->windowType() == Qt::Desktop) + return 0; // Don't create an explicit window surface for the destkop. + return new QTestLiteWindowSurface + (const_cast(this), mPrimaryScreen, widget); +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h new file mode 100644 index 0000000..cb88ee8 --- /dev/null +++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QGRAPHICSSYSTEM_TESTLITE_H +#define QGRAPHICSSYSTEM_TESTLITE_H + +#include + +QT_BEGIN_NAMESPACE + +class MyDisplay; + +class QTestLiteGraphicsSystemScreen : public QGraphicsSystemScreen +{ +public: + QTestLiteGraphicsSystemScreen() + : mDepth(16), mFormat(QImage::Format_RGB16) {} + ~QTestLiteGraphicsSystemScreen() {} + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; +}; + +class QTestLiteGraphicsSystem : public QGraphicsSystem +{ +public: + QTestLiteGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList screens() const { return mScreens; } + + MyDisplay *xd; + +private: + QTestLiteGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp new file mode 100644 index 0000000..6996809 --- /dev/null +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -0,0 +1,528 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 "qwindowsurface_testlite.h" +#include "qgraphicssystem_testlite.h" + +#include +#include + +#include "x11util.h" + +QT_BEGIN_NAMESPACE + +QTestLiteWindowSurface::QTestLiteWindowSurface + (QTestLiteGraphicsSystem *graphicsSystem, + QTestLiteGraphicsSystemScreen *screen, QWidget *window) + : QWindowSurface(window), + mGraphicsSystem(graphicsSystem), + mScreen(screen), + xw(0) +{ + + + xw = new MyWindow(graphicsSystem->xd, 0,0,300,300); + xw->windowSurface = this; + + qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window; + + setWindowFlags(window->windowFlags()); //##### This should not be the plugin's responsibility +} + +QTestLiteWindowSurface::~QTestLiteWindowSurface() +{ + qDebug() << "~QTestLiteWindowSurface" << xw->window; + delete xw; +} + +QPaintDevice *QTestLiteWindowSurface::paintDevice() +{ + return &xw->img; +} + +void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); + + // qDebug() << "QTestLiteWindowSurface::flush:" << (long)this; + + xw->paintEvent(); +} + +void QTestLiteWindowSurface::setGeometry(const QRect &rect) +{ + //qDebug() << "QTestLiteWindowSurface::setGeometry:" << rect << xw->window; + QWindowSurface::setGeometry(rect); + + if (xw->img.size() != rect.size()) + xw->img = QImage(rect.size(), mScreen->format()); + + //if unchanged ### +// xw->setSize(rect.width(), rect.height()); + xw->setGeometry(rect.x(), rect.y(), rect.width(), rect.height()); +} + +bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QTestLiteWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QTestLiteWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Mouse event stuff + + + + +static Qt::MouseButtons translateMouseButtons(int s) +{ + Qt::MouseButtons ret = 0; + if (s & Button1Mask) + ret |= Qt::LeftButton; + if (s & Button2Mask) + ret |= Qt::MidButton; + if (s & Button3Mask) + ret |= Qt::RightButton; + return ret; +} + + +static Qt::KeyboardModifiers translateModifiers(int s) +{ + const uchar qt_alt_mask = Mod1Mask; + const uchar qt_meta_mask = Mod4Mask; + + + Qt::KeyboardModifiers ret = 0; + if (s & ShiftMask) + ret |= Qt::ShiftModifier; + if (s & ControlMask) + ret |= Qt::ControlModifier; + if (s & qt_alt_mask) + ret |= Qt::AltModifier; + if (s & qt_meta_mask) + ret |= Qt::MetaModifier; +#if 0 + if (s & qt_mode_switch_mask) + ret |= Qt::GroupSwitchModifier; +#endif + return ret; +} + +void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) +{ + static QPoint mousePoint; + + XButtonEvent *e = static_cast(ev); + + Qt::MouseButton button = Qt::NoButton; + Qt::MouseButtons buttons = translateMouseButtons(e->state); + Qt::KeyboardModifiers modifiers = translateModifiers(e->state); + if (type != QEvent::MouseMove) { + switch (e->button) { + case Button1: button = Qt::LeftButton; break; + case Button2: button = Qt::MidButton; break; + case Button3: button = Qt::RightButton; break; + default: break; + } + } + + if (type == QEvent::MouseButtonPress && mousePoint != QPoint(e->x_root, e->y_root)) { + //we've missed a mouse move event somewhere (maybe because we + //haven't implemented mouse tracking yet); let's synthesize it. + QMouseEvent me(QEvent::MouseMove, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), + Qt::NoButton, buttons, modifiers); + QApplicationPrivate::handleMouseEvent(window(), me); + } + + buttons ^= button; // X event uses state *before*, Qt uses state *after* + + QMouseEvent me(type, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), button, buttons, modifiers); + QApplicationPrivate::handleMouseEvent(window(), me); + mousePoint = QPoint(e->x_root, e->y_root); +} + +void QTestLiteWindowSurface::handleGeometryChange(int x, int y, int w, int h) +{ + QApplicationPrivate::handleGeometryChange(window(), QRect(x,y,w,h)); +} + + + + + + + + + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Key event stuff -- not pretty either +// +// What we want to do is to port Robert's keytable code properly + + + + + + + +// keyboard mapping table +static const unsigned int keyTbl[] = { + + // misc keys + + XK_Escape, Qt::Key_Escape, + XK_Tab, Qt::Key_Tab, + XK_ISO_Left_Tab, Qt::Key_Backtab, + XK_BackSpace, Qt::Key_Backspace, + XK_Return, Qt::Key_Return, + XK_Insert, Qt::Key_Insert, + XK_Delete, Qt::Key_Delete, + XK_Clear, Qt::Key_Delete, + XK_Pause, Qt::Key_Pause, + XK_Print, Qt::Key_Print, + 0x1005FF60, Qt::Key_SysReq, // hardcoded Sun SysReq + 0x1007ff00, Qt::Key_SysReq, // hardcoded X386 SysReq + + // cursor movement + + XK_Home, Qt::Key_Home, + XK_End, Qt::Key_End, + XK_Left, Qt::Key_Left, + XK_Up, Qt::Key_Up, + XK_Right, Qt::Key_Right, + XK_Down, Qt::Key_Down, + XK_Prior, Qt::Key_PageUp, + XK_Next, Qt::Key_PageDown, + + // modifiers + + XK_Shift_L, Qt::Key_Shift, + XK_Shift_R, Qt::Key_Shift, + XK_Shift_Lock, Qt::Key_Shift, + XK_Control_L, Qt::Key_Control, + XK_Control_R, Qt::Key_Control, + XK_Meta_L, Qt::Key_Meta, + XK_Meta_R, Qt::Key_Meta, + XK_Alt_L, Qt::Key_Alt, + XK_Alt_R, Qt::Key_Alt, + XK_Caps_Lock, Qt::Key_CapsLock, + XK_Num_Lock, Qt::Key_NumLock, + XK_Scroll_Lock, Qt::Key_ScrollLock, + XK_Super_L, Qt::Key_Super_L, + XK_Super_R, Qt::Key_Super_R, + XK_Menu, Qt::Key_Menu, + XK_Hyper_L, Qt::Key_Hyper_L, + XK_Hyper_R, Qt::Key_Hyper_R, + XK_Help, Qt::Key_Help, + 0x1000FF74, Qt::Key_Backtab, // hardcoded HP backtab + 0x1005FF10, Qt::Key_F11, // hardcoded Sun F36 (labeled F11) + 0x1005FF11, Qt::Key_F12, // hardcoded Sun F37 (labeled F12) + + // numeric and function keypad keys + + XK_KP_Space, Qt::Key_Space, + XK_KP_Tab, Qt::Key_Tab, + XK_KP_Enter, Qt::Key_Enter, + //XK_KP_F1, Qt::Key_F1, + //XK_KP_F2, Qt::Key_F2, + //XK_KP_F3, Qt::Key_F3, + //XK_KP_F4, Qt::Key_F4, + XK_KP_Home, Qt::Key_Home, + XK_KP_Left, Qt::Key_Left, + XK_KP_Up, Qt::Key_Up, + XK_KP_Right, Qt::Key_Right, + XK_KP_Down, Qt::Key_Down, + XK_KP_Prior, Qt::Key_PageUp, + XK_KP_Next, Qt::Key_PageDown, + XK_KP_End, Qt::Key_End, + XK_KP_Begin, Qt::Key_Clear, + XK_KP_Insert, Qt::Key_Insert, + XK_KP_Delete, Qt::Key_Delete, + XK_KP_Equal, Qt::Key_Equal, + XK_KP_Multiply, Qt::Key_Asterisk, + XK_KP_Add, Qt::Key_Plus, + XK_KP_Separator, Qt::Key_Comma, + XK_KP_Subtract, Qt::Key_Minus, + XK_KP_Decimal, Qt::Key_Period, + XK_KP_Divide, Qt::Key_Slash, + + // International input method support keys + + // International & multi-key character composition + XK_ISO_Level3_Shift, Qt::Key_AltGr, + XK_Multi_key, Qt::Key_Multi_key, + XK_Codeinput, Qt::Key_Codeinput, + XK_SingleCandidate, Qt::Key_SingleCandidate, + XK_MultipleCandidate, Qt::Key_MultipleCandidate, + XK_PreviousCandidate, Qt::Key_PreviousCandidate, + + // Misc Functions + XK_Mode_switch, Qt::Key_Mode_switch, + XK_script_switch, Qt::Key_Mode_switch, + + // Japanese keyboard support + XK_Kanji, Qt::Key_Kanji, + XK_Muhenkan, Qt::Key_Muhenkan, + //XK_Henkan_Mode, Qt::Key_Henkan_Mode, + XK_Henkan_Mode, Qt::Key_Henkan, + XK_Henkan, Qt::Key_Henkan, + XK_Romaji, Qt::Key_Romaji, + XK_Hiragana, Qt::Key_Hiragana, + XK_Katakana, Qt::Key_Katakana, + XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana, + XK_Zenkaku, Qt::Key_Zenkaku, + XK_Hankaku, Qt::Key_Hankaku, + XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku, + XK_Touroku, Qt::Key_Touroku, + XK_Massyo, Qt::Key_Massyo, + XK_Kana_Lock, Qt::Key_Kana_Lock, + XK_Kana_Shift, Qt::Key_Kana_Shift, + XK_Eisu_Shift, Qt::Key_Eisu_Shift, + XK_Eisu_toggle, Qt::Key_Eisu_toggle, + //XK_Kanji_Bangou, Qt::Key_Kanji_Bangou, + //XK_Zen_Koho, Qt::Key_Zen_Koho, + //XK_Mae_Koho, Qt::Key_Mae_Koho, + XK_Kanji_Bangou, Qt::Key_Codeinput, + XK_Zen_Koho, Qt::Key_MultipleCandidate, + XK_Mae_Koho, Qt::Key_PreviousCandidate, + +#ifdef XK_KOREAN + // Korean keyboard support + XK_Hangul, Qt::Key_Hangul, + XK_Hangul_Start, Qt::Key_Hangul_Start, + XK_Hangul_End, Qt::Key_Hangul_End, + XK_Hangul_Hanja, Qt::Key_Hangul_Hanja, + XK_Hangul_Jamo, Qt::Key_Hangul_Jamo, + XK_Hangul_Romaja, Qt::Key_Hangul_Romaja, + //XK_Hangul_Codeinput, Qt::Key_Hangul_Codeinput, + XK_Hangul_Codeinput, Qt::Key_Codeinput, + XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja, + XK_Hangul_Banja, Qt::Key_Hangul_Banja, + XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja, + XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja, + //XK_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate, + //XK_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate, + //XK_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate, + XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate, + XK_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate, + XK_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate, + XK_Hangul_Special, Qt::Key_Hangul_Special, + //XK_Hangul_switch, Qt::Key_Hangul_switch, + XK_Hangul_switch, Qt::Key_Mode_switch, +#endif // XK_KOREAN + + // dead keys + XK_dead_grave, Qt::Key_Dead_Grave, + XK_dead_acute, Qt::Key_Dead_Acute, + XK_dead_circumflex, Qt::Key_Dead_Circumflex, + XK_dead_tilde, Qt::Key_Dead_Tilde, + XK_dead_macron, Qt::Key_Dead_Macron, + XK_dead_breve, Qt::Key_Dead_Breve, + XK_dead_abovedot, Qt::Key_Dead_Abovedot, + XK_dead_diaeresis, Qt::Key_Dead_Diaeresis, + XK_dead_abovering, Qt::Key_Dead_Abovering, + XK_dead_doubleacute, Qt::Key_Dead_Doubleacute, + XK_dead_caron, Qt::Key_Dead_Caron, + XK_dead_cedilla, Qt::Key_Dead_Cedilla, + XK_dead_ogonek, Qt::Key_Dead_Ogonek, + XK_dead_iota, Qt::Key_Dead_Iota, + XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound, + XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound, + XK_dead_belowdot, Qt::Key_Dead_Belowdot, + XK_dead_hook, Qt::Key_Dead_Hook, + XK_dead_horn, Qt::Key_Dead_Horn, + +#if 0 + // Special multimedia keys + // currently only tested with MS internet keyboard + + // browsing keys + XF86XK_Back, Qt::Key_Back, + XF86XK_Forward, Qt::Key_Forward, + XF86XK_Stop, Qt::Key_Stop, + XF86XK_Refresh, Qt::Key_Refresh, + XF86XK_Favorites, Qt::Key_Favorites, + XF86XK_AudioMedia, Qt::Key_LaunchMedia, + XF86XK_OpenURL, Qt::Key_OpenUrl, + XF86XK_HomePage, Qt::Key_HomePage, + XF86XK_Search, Qt::Key_Search, + + // media keys + XF86XK_AudioLowerVolume, Qt::Key_VolumeDown, + XF86XK_AudioMute, Qt::Key_VolumeMute, + XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp, + XF86XK_AudioPlay, Qt::Key_MediaPlay, + XF86XK_AudioStop, Qt::Key_MediaStop, + XF86XK_AudioPrev, Qt::Key_MediaPrevious, + XF86XK_AudioNext, Qt::Key_MediaNext, + XF86XK_AudioRecord, Qt::Key_MediaRecord, + + // launch keys + XF86XK_Mail, Qt::Key_LaunchMail, + XF86XK_MyComputer, Qt::Key_Launch0, + XF86XK_Calculator, Qt::Key_Launch1, + XF86XK_Standby, Qt::Key_Standby, + + XF86XK_Launch0, Qt::Key_Launch2, + XF86XK_Launch1, Qt::Key_Launch3, + XF86XK_Launch2, Qt::Key_Launch4, + XF86XK_Launch3, Qt::Key_Launch5, + XF86XK_Launch4, Qt::Key_Launch6, + XF86XK_Launch5, Qt::Key_Launch7, + XF86XK_Launch6, Qt::Key_Launch8, + XF86XK_Launch7, Qt::Key_Launch9, + XF86XK_Launch8, Qt::Key_LaunchA, + XF86XK_Launch9, Qt::Key_LaunchB, + XF86XK_LaunchA, Qt::Key_LaunchC, + XF86XK_LaunchB, Qt::Key_LaunchD, + XF86XK_LaunchC, Qt::Key_LaunchE, + XF86XK_LaunchD, Qt::Key_LaunchF, +#endif + +#if 0 + // Qtopia keys + QTOPIAXK_Select, Qt::Key_Select, + QTOPIAXK_Yes, Qt::Key_Yes, + QTOPIAXK_No, Qt::Key_No, + QTOPIAXK_Cancel, Qt::Key_Cancel, + QTOPIAXK_Printer, Qt::Key_Printer, + QTOPIAXK_Execute, Qt::Key_Execute, + QTOPIAXK_Sleep, Qt::Key_Sleep, + QTOPIAXK_Play, Qt::Key_Play, + QTOPIAXK_Zoom, Qt::Key_Zoom, + QTOPIAXK_Context1, Qt::Key_Context1, + QTOPIAXK_Context2, Qt::Key_Context2, + QTOPIAXK_Context3, Qt::Key_Context3, + QTOPIAXK_Context4, Qt::Key_Context4, + QTOPIAXK_Call, Qt::Key_Call, + QTOPIAXK_Hangup, Qt::Key_Hangup, + QTOPIAXK_Flip, Qt::Key_Flip, +#endif + 0, 0 +}; + + +static int lookupCode(unsigned int xkeycode) +{ + const unsigned int *p = keyTbl; + while (*p) { + if (*p == xkeycode) + return *++p; + p += 2; + } + + return 0; +} + + +void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) +{ + XKeyEvent *e = static_cast(ev); + + KeySym keySym; + QByteArray chars; + chars.resize(513); + + int count = XLookupString(e, chars.data(), chars.size(), &keySym, 0); + +// qDebug() << "QTLWS::handleKeyEvent" << count << hex << "XKeysym:" << keySym; +// if (count) +// qDebug() << hex << int(chars[0]) << "String:" << chars; + + Qt::KeyboardModifiers modifiers = translateModifiers(e->state); + + int qtcode = lookupCode(keySym); +// qDebug() << "lookup: " << hex << keySym << qtcode; + + if (qtcode) { + QKeyEvent keyEvent(type, qtcode, modifiers); + QApplicationPrivate::handleKeyEvent(window(), &keyEvent); + } else if (chars[0]) { + int qtcode = chars.toUpper()[0]; //Not exactly right... + QKeyEvent keyEvent(type, qtcode, modifiers, QString::fromLatin1(chars)); + QApplicationPrivate::handleKeyEvent(window(), &keyEvent); + } else { + qWarning() << "unknown X keycode" << hex << e->keycode << keySym; + } +} + + + +Qt::WindowFlags QTestLiteWindowSurface::setWindowFlags(Qt::WindowFlags flags) +{ + Q_ASSERT(flags & Qt::Window); + + window_flags = flags; + + xw->setWindowFlags(flags); + + return window_flags; + +} + +Qt::WindowFlags QTestLiteWindowSurface::windowFlags() const +{ + return window_flags; +} + +void QTestLiteWindowSurface::setVisible(bool visible) +{ + //qDebug() << "QTestLiteWindowSurface::setVisible" << visible << xw->window; + xw->setVisible(visible); +} + + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h new file mode 100644 index 0000000..33b55e9 --- /dev/null +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_TESTLITE_H +#define QWINDOWSURFACE_TESTLITE_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class MyWindow; +class QTestLiteGraphicsSystem; +class QTestLiteGraphicsSystemScreen; + +class QTestLiteWindowSurface : public QWindowSurface +{ +public: + QTestLiteWindowSurface + (QTestLiteGraphicsSystem *graphicsSystem, + QTestLiteGraphicsSystemScreen *screen, QWidget *window); + ~QTestLiteWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + + void handleMouseEvent(QEvent::Type, void *); //forwarding X types is apparently impossible :( + void handleKeyEvent(QEvent::Type, void *); + void handleGeometryChange(int x, int y, int w, int h); + + + Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); + Qt::WindowFlags windowFlags() const; + void setVisible(bool visible); + +private: + QTestLiteGraphicsSystem *mGraphicsSystem; + QTestLiteGraphicsSystemScreen *mScreen; + Qt::WindowFlags window_flags; + MyWindow *xw; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/testlite/testlite.pro b/src/plugins/graphicssystems/testlite/testlite.pro new file mode 100644 index 0000000..af8a437 --- /dev/null +++ b/src/plugins/graphicssystems/testlite/testlite.pro @@ -0,0 +1,17 @@ +TARGET = qtestlitegraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp qgraphicssystem_testlite.cpp qwindowsurface_testlite.cpp +HEADERS = qgraphicssystem_testlite.h qwindowsurface_testlite.h + + +HEADERS += x11util.h +SOURCES += x11util.cpp + +LIBS += -lX11 + + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp new file mode 100644 index 0000000..f77356a --- /dev/null +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -0,0 +1,684 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 +#include + +#include +#include + +#include "x11util.h" +#include "qwindowsurface_testlite.h" + +#include +#include + + +#include + + + +//### remove stuff we don't want from qt_x11_p.h +#undef ATOM +#undef X11 + + + + + +static int (*original_x_errhandler)(Display *dpy, XErrorEvent *); +static bool seen_badwindow; + + +//### copied from qapplication_x11.cpp + +static int qt_x_errhandler(Display *dpy, XErrorEvent *err) +{ + +qDebug() << "qt_x_errhandler" << err->error_code; + + switch (err->error_code) { + case BadAtom: +#if 0 + if (err->request_code == 20 /* X_GetProperty */ + && (err->resourceid == XA_RESOURCE_MANAGER + || err->resourceid == XA_RGB_DEFAULT_MAP + || err->resourceid == ATOM(_NET_SUPPORTED) + || err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK) + || err->resourceid == ATOM(KDE_FULL_SESSION) + || err->resourceid == ATOM(KWIN_RUNNING) + || err->resourceid == ATOM(XdndProxy) + || err->resourceid == ATOM(XdndAware)) + + + ) { + // Perhaps we're running under SECURITY reduction? :/ + return 0; + } +#endif + qDebug() << "BadAtom"; + break; + + case BadWindow: + if (err->request_code == 2 /* X_ChangeWindowAttributes */ + || err->request_code == 38 /* X_QueryPointer */) { + for (int i = 0; i < ScreenCount(dpy); ++i) { + if (err->resourceid == RootWindow(dpy, i)) { + // Perhaps we're running under SECURITY reduction? :/ + return 0; + } + } + } + seen_badwindow = true; + if (err->request_code == 25 /* X_SendEvent */) { + for (int i = 0; i < ScreenCount(dpy); ++i) { + if (err->resourceid == RootWindow(dpy, i)) { + // Perhaps we're running under SECURITY reduction? :/ + return 0; + } + } +#if 0 + if (X11->xdndHandleBadwindow()) { + qDebug("xdndHandleBadwindow returned true"); + return 0; + } +#endif + } +#if 0 + if (X11->ignore_badwindow) + return 0; +#endif + break; + + case BadMatch: + if (err->request_code == 42 /* X_SetInputFocus */) + return 0; + break; + + default: +#if 0 //!defined(QT_NO_XINPUT) + if (err->request_code == X11->xinput_major + && err->error_code == (X11->xinput_errorbase + XI_BadDevice) + && err->minor_code == 3 /* X_OpenDevice */) { + return 0; + } +#endif + break; + } + + char errstr[256]; + XGetErrorText( dpy, err->error_code, errstr, 256 ); + char buffer[256]; + char request_str[256]; + qsnprintf(buffer, 256, "%d", err->request_code); + XGetErrorDatabaseText(dpy, "XRequest", buffer, "", request_str, 256); + if (err->request_code < 128) { + // X error for a normal protocol request + qWarning( "X Error: %s %d\n" + " Major opcode: %d (%s)\n" + " Resource id: 0x%lx", + errstr, err->error_code, + err->request_code, + request_str, + err->resourceid ); + } else { + // X error for an extension request + const char *extensionName = 0; +#if 0 + if (err->request_code == X11->xrender_major) + extensionName = "RENDER"; + else if (err->request_code == X11->xrandr_major) + extensionName = "RANDR"; + else if (err->request_code == X11->xinput_major) + extensionName = "XInputExtension"; + else if (err->request_code == X11->mitshm_major) + extensionName = "MIT-SHM"; +#endif + char minor_str[256]; + if (extensionName) { + qsnprintf(buffer, 256, "%s.%d", extensionName, err->minor_code); + XGetErrorDatabaseText(dpy, "XRequest", buffer, "", minor_str, 256); + } else { + extensionName = "Uknown extension"; + qsnprintf(minor_str, 256, "Unknown request"); + } + qWarning( "X Error: %s %d\n" + " Extension: %d (%s)\n" + " Minor opcode: %d (%s)\n" + " Resource id: 0x%lx", + errstr, err->error_code, + err->request_code, + extensionName, + err->minor_code, + minor_str, + err->resourceid ); + } + + // ### we really should distinguish between severe, non-severe and + // ### application specific errors + + return 0; +} + + + + + + + + + +bool MyDisplay::handleEvent(XEvent *xe) +{ + //qDebug() << "handleEvent" << xe->xany.type << xe->xany.window; + int quit = false; + MyWindow *xw = 0; + foreach (MyWindow *w, windowList) { + if (w->window == xe->xany.window) { + xw = w; + break; + } + } + if (!xw) { + qWarning() << "Unknown window" << xe->xany.window << "received event" << hex << xe->type; + return quit; + } + + switch (xe->type) { + case Expose: + if (xw) + if (xe->xexpose.count == 0) + xw->paintEvent(); + break; + case ConfigureNotify: + if (xw) + xw->resizeEvent(&xe->xconfigure); + break; +#if 1 + + case ButtonPress: + xw->mousePressEvent(&xe->xbutton); + break; + + case ButtonRelease: + xw->mouseReleaseEvent(&xe->xbutton); + break; + + case MotionNotify: + xw->mouseMoveEvent(&xe->xbutton); + break; + + case XKeyPress: + xw->keyPressEvent(&xe->xkey); + break; + + case XKeyRelease: + xw->keyReleaseEvent(&xe->xkey); + break; +#endif + + default: + qDebug() << "Other X event" << hex << xe->type; + break; + } + return quit; +}; + + +MyDisplay::MyDisplay() +{ + char *display_name = getenv("DISPLAY"); + display = XOpenDisplay(display_name); + if (!display) { + fprintf(stderr, "Cannot connect to X server: %s\n", + display_name); + exit(1); + } + + original_x_errhandler = XSetErrorHandler(qt_x_errhandler); + + if (qgetenv("DO_X_SYNCHRONIZE").toInt()) + XSynchronize(display, true); + + + screen = DefaultScreen(display); + width = DisplayWidth(display, screen); + height = DisplayHeight(display, screen); + physicalWidth = DisplayWidthMM(display, screen); + physicalHeight = DisplayHeightMM(display, screen); + + int xSocketNumber = XConnectionNumber(display); + qDebug() << "X socket:"<< xSocketNumber; + + QSocketNotifier *sock = new QSocketNotifier(xSocketNumber, QSocketNotifier::Read, this); + connect(sock, SIGNAL(activated(int)), this, SLOT(eventDispatcher())); +} + + +MyDisplay::~MyDisplay() +{ + XCloseDisplay(display); +} + + +void MyDisplay::eventDispatcher() +{ +// qDebug() << "eventDispatcher"; + + + ulong marker = XNextRequest(display); +// int i = 0; + while (XPending(display)) { + XEvent event; + XNextEvent(display, &event); + /* done = */ + handleEvent(&event); + + if (event.xany.serial >= marker) { + qDebug() << "potential livelock averted"; +#if 0 + if (XEventsQueued(display, QueuedAfterFlush)) { + qDebug() << " with events queued"; + QTimer::singleShot(0, this, SLOT(eventDispatcher())); + } +#endif + break; + } + } +} + + +MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) +{ + xd = display; + + xd->windowList.append(this); + + qDebug() << "MyWindow::MyWindow"; + + window = XCreateSimpleWindow(xd->display, xd->rootWindow(), + x, y, w, h, 0 /*border_width*/, + xd->blackPixel(), xd->whitePixel()); + + width = -1; + height = -1; + xpos = -1; + ypos = -1; + + XSetWindowBackgroundPixmap(xd->display, window, XNone); + + XSelectInput(xd->display, window, ExposureMask | KeyPressMask | KeyReleaseMask | + ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | StructureNotifyMask); + + gc = createGC(); +} + +MyWindow::~MyWindow() +{ + XFreeGC(xd->display, gc); + XDestroyWindow(xd->display, window); + + xd->windowList.removeAll(this); +} + +GC MyWindow::createGC() +{ + GC gc; + + gc = XCreateGC(xd->display, window, 0, 0); + if (gc < 0) { + qWarning("MyWindow::createGC() could not create GC"); + } + return gc; +} + + + +void MyWindow::paintEvent() +{ + Visual *visual = DefaultVisual(xd->display, xd->screen); + + if (!img.isNull()) { + QImage image = img.convertToFormat(QImage::Format_RGB32); + XImage *xi = XCreateImage(xd->display, visual, 24, ZPixmap, + 0, (char *) image.scanLine(0), image.width(), image.height(), + 32, image.bytesPerLine()); + + int x = 0; + int y = 0; + + /*int r =*/ XPutImage(xd->display, window, gc, xi, 0, 0, x, y, image.width(), image.height()); + + xi->data = 0; // QImage owns these bits + XDestroyImage(xi); + } +} + +void MyWindow::resizeEvent(XConfigureEvent *e) +{ + + if ((e->width != width || e->height != height) && e->x == 0 && e->y == 0) { + //qDebug() << "resize with bogus pos" << e->x << e->y << e->width << e->height << "window"<< hex << window; + } else { + //qDebug() << "geometry change" << e->x << e->y << e->width << e->height << "window"<< hex << window; + xpos = e->x; + ypos = e->y; + } + width = e->width; + height = e->height; + + windowSurface->handleGeometryChange(xpos, ypos, width, height); +} + + +void MyWindow::setSize(int w, int h) +{ + XResizeWindow(xd->display, window, w, h); +} + +void MyWindow::setGeometry(int x, int y, int w, int h) +{ + XMoveResizeWindow(xd->display, window, x, y, w, h); +} + + +void MyWindow::mousePressEvent(XButtonEvent *e) +{ + windowSurface->handleMouseEvent(QEvent::MouseButtonPress, e); +} + +void MyWindow::mouseReleaseEvent(XButtonEvent *e) +{ + windowSurface->handleMouseEvent(QEvent::MouseButtonRelease, e); +} + +void MyWindow::mouseMoveEvent(XButtonEvent *e) +{ + windowSurface->handleMouseEvent(QEvent::MouseMove, e); +} + +#ifdef KeyPress +#undef KeyPress +#endif + +void MyWindow::keyPressEvent(XKeyEvent *e) +{ + windowSurface->handleKeyEvent(QEvent::KeyPress, e); +} + +#ifdef KeyRelease +#undef KeyRelease +#endif + +void MyWindow::keyReleaseEvent(XKeyEvent *e) +{ + windowSurface->handleKeyEvent(QEvent::KeyRelease, e); +} + + +// WindowFlag stuff, lots of copied code from qwidget_x11.cpp... + +//We're hacking here... + + +// MWM support +struct QtMWMHints { + ulong flags, functions, decorations; + long input_mode; + ulong status; +}; + +enum { + MWM_HINTS_FUNCTIONS = (1L << 0), + + MWM_FUNC_ALL = (1L << 0), + MWM_FUNC_RESIZE = (1L << 1), + MWM_FUNC_MOVE = (1L << 2), + MWM_FUNC_MINIMIZE = (1L << 3), + MWM_FUNC_MAXIMIZE = (1L << 4), + MWM_FUNC_CLOSE = (1L << 5), + + MWM_HINTS_DECORATIONS = (1L << 1), + + MWM_DECOR_ALL = (1L << 0), + MWM_DECOR_BORDER = (1L << 1), + MWM_DECOR_RESIZEH = (1L << 2), + MWM_DECOR_TITLE = (1L << 3), + MWM_DECOR_MENU = (1L << 4), + MWM_DECOR_MINIMIZE = (1L << 5), + MWM_DECOR_MAXIMIZE = (1L << 6), + + MWM_HINTS_INPUT_MODE = (1L << 2), + + MWM_INPUT_MODELESS = 0L, + MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L, + MWM_INPUT_FULL_APPLICATION_MODAL = 3L +}; + +static Atom mwm_hint_atom = XNone; + +static QtMWMHints GetMWMHints(Display *display, Window window) +{ + QtMWMHints mwmhints; + + Atom type; + int format; + ulong nitems, bytesLeft; + uchar *data = 0; + if ((XGetWindowProperty(display, window, mwm_hint_atom, 0, 5, false, + mwm_hint_atom, &type, &format, &nitems, &bytesLeft, + &data) == Success) + && (type == mwm_hint_atom + && format == 32 + && nitems >= 5)) { + mwmhints = *(reinterpret_cast(data)); + } else { + mwmhints.flags = 0L; + mwmhints.functions = MWM_FUNC_ALL; + mwmhints.decorations = MWM_DECOR_ALL; + mwmhints.input_mode = 0L; + mwmhints.status = 0L; + } + + if (data) + XFree(data); + + return mwmhints; +} + +static void SetMWMHints(Display *display, Window window, const QtMWMHints &mwmhints) +{ + if (mwmhints.flags != 0l) { + XChangeProperty(display, window, mwm_hint_atom, mwm_hint_atom, 32, + PropModeReplace, (unsigned char *) &mwmhints, 5); + } else { + XDeleteProperty(display, window, mwm_hint_atom); + } +} + +// 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)); +} + + + +Qt::WindowFlags MyWindow::setWindowFlags(Qt::WindowFlags flags) +{ + + if (mwm_hint_atom == XNone) { + mwm_hint_atom = XInternAtom(xd->display, "_MOTIF_WM_HINTS\0", False); + } + + qDebug() << "MyWindow::setWindowFlags" << hex << mwm_hint_atom << "flags" << flags; + + Qt::WindowType type = static_cast(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); + + + XSetWindowAttributes wsa; + + QtMWMHints mwmhints; + mwmhints.flags = 0L; + mwmhints.functions = 0L; + mwmhints.decorations = 0; + mwmhints.input_mode = 0L; + mwmhints.status = 0L; + + + ulong wsa_mask = 0; + if (type != Qt::SplashScreen) { // && customize) { + 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 (tool) { + wsa.save_under = True; + wsa_mask |= CWSaveUnder; + } + + if (flags & Qt::X11BypassWindowManagerHint) { + wsa.override_redirect = True; + wsa_mask |= CWOverrideRedirect; + } +#if 0 + if (wsa_mask && initializeWindow) { + Q_ASSERT(id); + XChangeWindowAttributes(dpy, id, wsa_mask, &wsa); + } +#endif + 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; + } + + SetMWMHints(xd->display, window, mwmhints); + +//##### only if initializeWindow??? + + if (popup) { // popup widget + qDebug() << "Doing XChangeWindowAttributes for popup" << wsa.override_redirect; + // set EWMH window types + // setNetWmWindowTypes(); + + wsa.override_redirect = True; + wsa.save_under = True; + XChangeWindowAttributes(xd->display, window, CWOverrideRedirect | CWSaveUnder, + &wsa); + } else { + + qDebug() << "Doing XChangeWindowAttributes for non-popup"; + + } + + return flags; +} + +void MyWindow::setVisible(bool visible) +{ +// qDebug() << "MyWindow::setVisible" << visible << hex << window; + if (visible) + XMapWindow(xd->display, window); + else + XUnmapWindow(xd->display, window); +} diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h new file mode 100644 index 0000000..3d813c0 --- /dev/null +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 MYX11UTIL_H +#define MYX11UTIL_H + +#include +#include + +#include + +#include +#include + + +class MyWindow; + +class MyDisplay : public QObject +{ + Q_OBJECT; +public: + MyDisplay(); + ~MyDisplay(); + + Window rootWindow() { return RootWindow(display, screen); } + unsigned long blackPixel() { return BlackPixel(display, screen); } + unsigned long whitePixel() { return WhitePixel(display, screen); } + + bool handleEvent(XEvent *xe); + +public slots: + void eventDispatcher(); + +public: //### + Display * display; + int screen; + int width, height; + int physicalWidth; + int physicalHeight; + + QList windowList; +}; + +class QTestLiteWindowSurface; //### abstract callback interface, anyone? + +class MyWindow : public QObject +{ + Q_OBJECT; +public: + MyWindow(MyDisplay *xd, int x, int y, int w, int h); + ~MyWindow(); + + + void mousePressEvent(XButtonEvent*); + void mouseReleaseEvent(XButtonEvent*); + void mouseMoveEvent(XButtonEvent*); + + void keyPressEvent(XKeyEvent*); + void keyReleaseEvent(XKeyEvent*); + + + void paintEvent(); + void resizeEvent(XConfigureEvent *configure_event); + void setSize(int w, int h); + void setGeometry(int x, int y, int w, int h); + + GC createGC(); + + Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); + void setVisible(bool visible); + +public: //### + + int xpos, ypos; + int width, height; + QImage img; + Window window; + MyDisplay *xd; + GC gc; + + QTestLiteWindowSurface *windowSurface; +}; + + + + + +#endif // MYX11UTIL_H diff --git a/src/plugins/graphicssystems/vnc/main.cpp b/src/plugins/graphicssystems/vnc/main.cpp new file mode 100644 index 0000000..7deb91a --- /dev/null +++ b/src/plugins/graphicssystems/vnc/main.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 +#include "qgraphicssystem_vnc.h" +#include + +QT_BEGIN_NAMESPACE + +class QVNCGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QVNCGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "VNC"; + return list; +} + +QGraphicsSystem* QVNCGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "vnc") + return new QVNCGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(vnc, QVNCGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp new file mode 100644 index 0000000..4890e09 --- /dev/null +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 "qgraphicssystem_vnc.h" +#include "qwindowsurface_vnc.h" +#include +#include + +#include + + + + +QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() + : mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0) +{ + mGeometry = QRect(0,0,800, 600); + + mDepth = 32; + mFormat = QImage::Format_RGB32; + mPhysicalSize = (mGeometry.size()*254)/720; + + + mScreenImage = new QImage(mGeometry.size(), mFormat); + d_ptr = new QVNCGraphicsSystemScreenPrivate(this); +} + + +QVNCGraphicsSystemScreen::~QVNCGraphicsSystemScreen() +{ + delete mScreenImage; +} + +QVNCDirtyMap *QVNCGraphicsSystemScreen::dirtyMap() +{ + return d_ptr->dirty; +} + + +void QVNCGraphicsSystemScreen::setDirty(const QRect &rect) +{ + d_ptr->setDirty(rect); +} + + +QVNCGraphicsSystem::QVNCGraphicsSystem() +{ +//////// xd = new MyDisplay; + + mPrimaryScreen = new QVNCGraphicsSystemScreen(); + + + int dw = mPrimaryScreen->geometry().width(); + int dh = mPrimaryScreen->geometry().height(); + + + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QVNCGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QVNCGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + if (widget->windowType() == Qt::Desktop) + return 0; // Don't create an explicit window surface for the destkop. + return new QVNCWindowSurface + (const_cast(this), mPrimaryScreen, widget); +} diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h new file mode 100644 index 0000000..d9b4375 --- /dev/null +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QGRAPHICSSYSTEM_VNC_H +#define QGRAPHICSSYSTEM_VNC_H + +#include + +QT_BEGIN_NAMESPACE + +class QVNCServer; +class QVNCDirtyMap; + + +class QVNCGraphicsSystemScreenPrivate; + +class QVNCGraphicsSystemScreen : public QGraphicsSystemScreen +{ +public: + QVNCGraphicsSystemScreen(); + ~QVNCGraphicsSystemScreen(); + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + int linestep() const { return mScreenImage ? mScreenImage->bytesPerLine() : 0; } + uchar *base() const { return mScreenImage ? mScreenImage->bits() : 0; } + QVNCDirtyMap *dirtyMap(); + + void setDirty(const QRect &rect); + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; + QImage *mScreenImage; + QVNCServer *server; + + QVNCGraphicsSystemScreenPrivate *d_ptr; +}; + +class QVNCGraphicsSystemPrivate; + + +class QVNCGraphicsSystem : public QGraphicsSystem +{ +public: + QVNCGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList screens() const { return mScreens; } + +private: + QVNCGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; +}; + + + +QT_END_NAMESPACE + +#endif //QGRAPHICSSYSTEM_VNC_H + diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp new file mode 100644 index 0000000..c3677a0 --- /dev/null +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -0,0 +1,1912 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 "qvncserver.h" + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#include + + +#define QT_QWS_VNC_DEBUG +#define QT_NO_QWS_CURSOR //### + + +QT_BEGIN_NAMESPACE + + + +//copied from qscreen_qws.h +#ifndef QT_QWS_DEPTH16_RGB +#define QT_QWS_DEPTH16_RGB 565 +#endif +static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100); +static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10); +static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10); +static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits); +static const int qt_green_shift = qt_bbits-(8-qt_gbits); +static const int qt_neg_blue_shift = 8-qt_bbits; +static const int qt_blue_mask = (1<> qt_red_shift | r >> qt_red_rounding_shift; + const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift; + const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift; + + return qRgb(tr,tg,tb); +} + + + +//=========================================================================== + +static const struct { + int keysym; + int keycode; +} keyMap[] = { + { 0xff08, Qt::Key_Backspace }, + { 0xff09, Qt::Key_Tab }, + { 0xff0d, Qt::Key_Return }, + { 0xff1b, Qt::Key_Escape }, + { 0xff63, Qt::Key_Insert }, + { 0xffff, Qt::Key_Delete }, + { 0xff50, Qt::Key_Home }, + { 0xff57, Qt::Key_End }, + { 0xff55, Qt::Key_PageUp }, + { 0xff56, Qt::Key_PageDown }, + { 0xff51, Qt::Key_Left }, + { 0xff52, Qt::Key_Up }, + { 0xff53, Qt::Key_Right }, + { 0xff54, Qt::Key_Down }, + { 0xffbe, Qt::Key_F1 }, + { 0xffbf, Qt::Key_F2 }, + { 0xffc0, Qt::Key_F3 }, + { 0xffc1, Qt::Key_F4 }, + { 0xffc2, Qt::Key_F5 }, + { 0xffc3, Qt::Key_F6 }, + { 0xffc4, Qt::Key_F7 }, + { 0xffc5, Qt::Key_F8 }, + { 0xffc6, Qt::Key_F9 }, + { 0xffc7, Qt::Key_F10 }, + { 0xffc8, Qt::Key_F11 }, + { 0xffc9, Qt::Key_F12 }, + { 0xffe1, Qt::Key_Shift }, + { 0xffe2, Qt::Key_Shift }, + { 0xffe3, Qt::Key_Control }, + { 0xffe4, Qt::Key_Control }, + { 0xffe7, Qt::Key_Meta }, + { 0xffe8, Qt::Key_Meta }, + { 0xffe9, Qt::Key_Alt }, + { 0xffea, Qt::Key_Alt }, + { 0, 0 } +}; + +void QRfbRect::read(QTcpSocket *s) +{ + quint16 buf[4]; + s->read((char*)buf, 8); + x = ntohs(buf[0]); + y = ntohs(buf[1]); + w = ntohs(buf[2]); + h = ntohs(buf[3]); +} + +void QRfbRect::write(QTcpSocket *s) const +{ + quint16 buf[4]; + buf[0] = htons(x); + buf[1] = htons(y); + buf[2] = htons(w); + buf[3] = htons(h); + s->write((char*)buf, 8); +} + +void QRfbPixelFormat::read(QTcpSocket *s) +{ + char buf[16]; + s->read(buf, 16); + bitsPerPixel = buf[0]; + depth = buf[1]; + bigEndian = buf[2]; + trueColor = buf[3]; + + quint16 a = ntohs(*(quint16 *)(buf + 4)); + redBits = 0; + while (a) { a >>= 1; redBits++; } + + a = ntohs(*(quint16 *)(buf + 6)); + greenBits = 0; + while (a) { a >>= 1; greenBits++; } + + a = ntohs(*(quint16 *)(buf + 8)); + blueBits = 0; + while (a) { a >>= 1; blueBits++; } + + redShift = buf[10]; + greenShift = buf[11]; + blueShift = buf[12]; +} + +void QRfbPixelFormat::write(QTcpSocket *s) +{ + char buf[16]; + buf[0] = bitsPerPixel; + buf[1] = depth; + buf[2] = bigEndian; + buf[3] = trueColor; + + quint16 a = 0; + for (int i = 0; i < redBits; i++) a = (a << 1) | 1; + *(quint16 *)(buf + 4) = htons(a); + + a = 0; + for (int i = 0; i < greenBits; i++) a = (a << 1) | 1; + *(quint16 *)(buf + 6) = htons(a); + + a = 0; + for (int i = 0; i < blueBits; i++) a = (a << 1) | 1; + *(quint16 *)(buf + 8) = htons(a); + + buf[10] = redShift; + buf[11] = greenShift; + buf[12] = blueShift; + s->write(buf, 16); +} + + +void QRfbServerInit::setName(const char *n) +{ + delete[] name; + name = new char [strlen(n) + 1]; + strcpy(name, n); +} + +void QRfbServerInit::read(QTcpSocket *s) +{ + s->read((char *)&width, 2); + width = ntohs(width); + s->read((char *)&height, 2); + height = ntohs(height); + format.read(s); + + quint32 len; + s->read((char *)&len, 4); + len = ntohl(len); + + name = new char [len + 1]; + s->read(name, len); + name[len] = '\0'; +} + +void QRfbServerInit::write(QTcpSocket *s) +{ + quint16 t = htons(width); + s->write((char *)&t, 2); + t = htons(height); + s->write((char *)&t, 2); + format.write(s); + quint32 len = strlen(name); + len = htonl(len); + s->write((char *)&len, 4); + s->write(name, strlen(name)); +} + +bool QRfbSetEncodings::read(QTcpSocket *s) +{ + if (s->bytesAvailable() < 3) + return false; + + char tmp; + s->read(&tmp, 1); // padding + s->read((char *)&count, 2); + count = ntohs(count); + + return true; +} + +bool QRfbFrameBufferUpdateRequest::read(QTcpSocket *s) +{ + if (s->bytesAvailable() < 9) + return false; + + s->read(&incremental, 1); + rect.read(s); + + return true; +} + +bool QRfbKeyEvent::read(QTcpSocket *s) +{ + if (s->bytesAvailable() < 7) + return false; + + s->read(&down, 1); + quint16 tmp; + s->read((char *)&tmp, 2); // padding + + quint32 key; + s->read((char *)&key, 4); + key = ntohl(key); + + unicode = 0; + keycode = 0; + int i = 0; + while (keyMap[i].keysym && !keycode) { + if (keyMap[i].keysym == (int)key) + keycode = keyMap[i].keycode; + i++; + } + if (!keycode) { + if (key <= 0xff) { + unicode = key; + if (key >= 'a' && key <= 'z') + keycode = Qt::Key_A + key - 'a'; + else if (key >= ' ' && key <= '~') + keycode = Qt::Key_Space + key - ' '; + } + } + + return true; +} + +bool QRfbPointerEvent::read(QTcpSocket *s) +{ + if (s->bytesAvailable() < 5) + return false; + + char buttonMask; + s->read(&buttonMask, 1); + buttons = Qt::NoButton; + if (buttonMask & 1) + buttons |= Qt::LeftButton; + if (buttonMask & 2) + buttons |= Qt::MidButton; + if (buttonMask & 4) + buttons |= Qt::RightButton; + + quint16 tmp; + s->read((char *)&tmp, 2); + x = ntohs(tmp); + s->read((char *)&tmp, 2); + y = ntohs(tmp); + + return true; +} + +bool QRfbClientCutText::read(QTcpSocket *s) +{ + if (s->bytesAvailable() < 7) + return false; + + char tmp[3]; + s->read(tmp, 3); // padding + s->read((char *)&length, 4); + length = ntohl(length); + + return true; +} + +//=========================================================================== + +QVNCServer::QVNCServer(QVNCGraphicsSystemScreen *screen) + : qvnc_screen(screen) +{ + init(5900); +} + +QVNCServer::QVNCServer(QVNCGraphicsSystemScreen *screen, int id) + : qvnc_screen(screen) +{ + init(5900 + id); +} + +void QVNCServer::init(uint port) +{ + qDebug() << "QVNCServer::init" << port; + + handleMsg = false; + client = 0; + encodingsPending = 0; + cutTextPending = 0; + keymod = 0; + state = Unconnected; + dirtyCursor = false; + + refreshRate = 25; + timer = new QTimer(this); + timer->setSingleShot(true); + connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); + + serverSocket = new QTcpServer(this); + if (!serverSocket->listen(QHostAddress::Any, port)) + qDebug() << "QVNCServer could not connect:" << serverSocket->errorString(); + else + qDebug("QVNCServer created on port %d", port); + + connect(serverSocket, SIGNAL(newConnection()), this, SLOT(newConnection())); + +#ifndef QT_NO_QWS_CURSOR + qvnc_cursor = 0; +#endif + encoder = 0; +} + +QVNCServer::~QVNCServer() +{ + delete encoder; + encoder = 0; + delete client; + client = 0; +#ifndef QT_NO_QWS_CURSOR + delete qvnc_cursor; + qvnc_cursor = 0; +#endif +} + +void QVNCServer::setDirty() +{ + if (state == Connected && !timer->isActive() && + ((dirtyMap()->numDirty > 0) || dirtyCursor)) { + timer->start(); + } +} + +void QVNCServer::newConnection() +{ + if (client) + delete client; + + client = serverSocket->nextPendingConnection(); + connect(client,SIGNAL(readyRead()),this,SLOT(readClient())); + connect(client,SIGNAL(disconnected()),this,SLOT(discardClient())); + handleMsg = false; + encodingsPending = 0; + cutTextPending = 0; + supportHextile = false; + wantUpdate = false; + + timer->start(1000 / refreshRate); + dirtyMap()->reset(); + + // send protocol version + const char *proto = "RFB 003.003\n"; + client->write(proto, 12); + state = Protocol; + +// if (!qvnc_screen->screen()) +// QWSServer::instance()->enablePainting(true); +} + +void QVNCServer::readClient() +{ + switch (state) { + case Protocol: + if (client->bytesAvailable() >= 12) { + char proto[13]; + client->read(proto, 12); + proto[12] = '\0'; + qDebug("Client protocol version %s", proto); + // No authentication + quint32 auth = htonl(1); + client->write((char *) &auth, sizeof(auth)); + state = Init; + } + break; + + case Init: + if (client->bytesAvailable() >= 1) { + quint8 shared; + client->read((char *) &shared, 1); + + // Server Init msg + QRfbServerInit sim; + QRfbPixelFormat &format = sim.format; + switch (qvnc_screen->depth()) { + case 32: + format.bitsPerPixel = 32; + format.depth = 32; + format.bigEndian = 0; + format.trueColor = true; + format.redBits = 8; + format.greenBits = 8; + format.blueBits = 8; + format.redShift = 16; + format.greenShift = 8; + format.blueShift = 0; + break; + + case 24: + format.bitsPerPixel = 24; + format.depth = 24; + format.bigEndian = 0; + format.trueColor = true; + format.redBits = 8; + format.greenBits = 8; + format.blueBits = 8; + format.redShift = 16; + format.greenShift = 8; + format.blueShift = 0; + break; + + case 18: + format.bitsPerPixel = 24; + format.depth = 18; + format.bigEndian = 0; + format.trueColor = true; + format.redBits = 6; + format.greenBits = 6; + format.blueBits = 6; + format.redShift = 12; + format.greenShift = 6; + format.blueShift = 0; + break; + + case 16: + format.bitsPerPixel = 16; + format.depth = 16; + format.bigEndian = 0; + format.trueColor = true; + format.redBits = 5; + format.greenBits = 6; + format.blueBits = 5; + format.redShift = 11; + format.greenShift = 5; + format.blueShift = 0; + break; + + case 15: + format.bitsPerPixel = 16; + format.depth = 15; + format.bigEndian = 0; + format.trueColor = true; + format.redBits = 5; + format.greenBits = 5; + format.blueBits = 5; + format.redShift = 10; + format.greenShift = 5; + format.blueShift = 0; + break; + + case 12: + format.bitsPerPixel = 16; + format.depth = 12; + format.bigEndian = 0; + format.trueColor = true; + format.redBits = 4; + format.greenBits = 4; + format.blueBits = 4; + format.redShift = 8; + format.greenShift = 4; + format.blueShift = 0; + break; + + case 8: + case 4: + format.bitsPerPixel = 8; + format.depth = 8; + format.bigEndian = 0; + format.trueColor = false; + format.redBits = 0; + format.greenBits = 0; + format.blueBits = 0; + format.redShift = 0; + format.greenShift = 0; + format.blueShift = 0; + break; + + default: + qDebug("QVNC cannot drive depth %d", qvnc_screen->depth()); + discardClient(); + return; + } + sim.width = qvnc_screen->geometry().width(); + sim.height = qvnc_screen->geometry().height(); + sim.setName("Qt for Embedded Linux VNC Server"); + sim.write(client); + state = Connected; + } + break; + + case Connected: + do { + if (!handleMsg) { + client->read((char *)&msgType, 1); + handleMsg = true; + } + if (handleMsg) { + switch (msgType ) { + case SetPixelFormat: + setPixelFormat(); + break; + case FixColourMapEntries: + qDebug("Not supported: FixColourMapEntries"); + handleMsg = false; + break; + case SetEncodings: + setEncodings(); + break; + case FramebufferUpdateRequest: + frameBufferUpdateRequest(); + break; + case KeyEvent: + keyEvent(); + break; + case PointerEvent: + pointerEvent(); + break; + case ClientCutText: + clientCutText(); + break; + default: + qDebug("Unknown message type: %d", (int)msgType); + handleMsg = false; + } + } + } while (!handleMsg && client->bytesAvailable()); + break; + default: + break; + } +} + +#if 0//Q_BYTE_ORDER == Q_BIG_ENDIAN +bool QVNCGraphicsSystemScreen::swapBytes() const +{ + if (depth() != 16) + return false; + + if (screen()) + return screen()->frameBufferLittleEndian(); + return frameBufferLittleEndian(); +} +#endif + +void QVNCServer::setPixelFormat() +{ + if (client->bytesAvailable() >= 19) { + char buf[3]; + client->read(buf, 3); // just padding + pixelFormat.read(client); +#ifdef QT_QWS_VNC_DEBUG + qDebug("Want format: %d %d %d %d %d %d %d %d %d %d", + int(pixelFormat.bitsPerPixel), + int(pixelFormat.depth), + int(pixelFormat.bigEndian), + int(pixelFormat.trueColor), + int(pixelFormat.redBits), + int(pixelFormat.greenBits), + int(pixelFormat.blueBits), + int(pixelFormat.redShift), + int(pixelFormat.greenShift), + int(pixelFormat.blueShift)); +#endif + if (!pixelFormat.trueColor) { + qDebug("Can only handle true color clients"); + discardClient(); + } + handleMsg = false; + sameEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) == !!pixelFormat.bigEndian; + needConversion = pixelConversionNeeded(); +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + swapBytes = qvnc_screen->swapBytes(); +#endif + } +} + +void QVNCServer::setEncodings() +{ + QRfbSetEncodings enc; + + if (!encodingsPending && enc.read(client)) { + encodingsPending = enc.count; + if (!encodingsPending) + handleMsg = false; + } + + if (encoder) { + delete encoder; + encoder = 0; + } + + enum Encodings { + Raw = 0, + CopyRect = 1, + RRE = 2, + CoRRE = 4, + Hextile = 5, + ZRLE = 16, + Cursor = -239, + DesktopSize = -223 + }; + + if (encodingsPending && (unsigned)client->bytesAvailable() >= + encodingsPending * sizeof(quint32)) { + for (int i = 0; i < encodingsPending; ++i) { + qint32 enc; + client->read((char *)&enc, sizeof(qint32)); + enc = ntohl(enc); +#ifdef QT_QWS_VNC_DEBUG + qDebug("QVNCServer::setEncodings: %d", enc); +#endif + switch (enc) { + case Raw: + if (!encoder) { + encoder = new QRfbRawEncoder(this); +#ifdef QT_QWS_VNC_DEBUG + qDebug("QVNCServer::setEncodings: using raw"); +#endif + } + break; + case CopyRect: + supportCopyRect = true; + break; + case RRE: + supportRRE = true; + break; + case CoRRE: + supportCoRRE = true; + break; + case Hextile: + supportHextile = true; + if (encoder) + break; + switch (qvnc_screen->depth()) { +#ifdef QT_QWS_DEPTH_8 + case 8: + encoder = new QRfbHextileEncoder(this); + break; +#endif +#ifdef QT_QWS_DEPTH_12 + case 12: + encoder = new QRfbHextileEncoder(this); + break; +#endif +#ifdef QT_QWS_DEPTH_15 + case 15: + encoder = new QRfbHextileEncoder(this); + break; +#endif +#ifdef QT_QWS_DEPTH_16 + case 16: + encoder = new QRfbHextileEncoder(this); + break; +#endif +#ifdef QT_QWS_DEPTH_18 + case 18: + encoder = new QRfbHextileEncoder(this); + break; +#endif +#ifdef QT_QWS_DEPTH_24 + case 24: + encoder = new QRfbHextileEncoder(this); + break; +#endif +#ifdef QT_QWS_DEPTH_32 + case 32: + encoder = new QRfbHextileEncoder(this); + break; +#endif + default: + break; + } +#ifdef QT_QWS_VNC_DEBUG + qDebug("QVNCServer::setEncodings: using hextile"); +#endif + break; + case ZRLE: + supportZRLE = true; + break; + case Cursor: + supportCursor = true; +#ifndef QT_NO_QWS_CURSOR + if (!qvnc_screen->screen() || qt_screencursor->isAccelerated()) { + delete qvnc_cursor; + qvnc_cursor = new QVNCClientCursor(this); + } +#endif + break; + case DesktopSize: + supportDesktopSize = true; + break; + default: + break; + } + } + handleMsg = false; + encodingsPending = 0; + } + + if (!encoder) { + encoder = new QRfbRawEncoder(this); +#ifdef QT_QWS_VNC_DEBUG + qDebug("QVNCServer::setEncodings: fallback using raw"); +#endif + } +} + +void QVNCServer::frameBufferUpdateRequest() +{ + QRfbFrameBufferUpdateRequest ev; + + if (ev.read(client)) { + if (!ev.incremental) { + QRect r(ev.rect.x, ev.rect.y, ev.rect.w, ev.rect.h); +////### r.translate(qvnc_screen->offset()); + qvnc_screen->d_ptr->setDirty(r, true); + } + wantUpdate = true; + checkUpdate(); + handleMsg = false; + } +} + +static bool buttonChange(Qt::MouseButtons before, Qt::MouseButtons after, Qt::MouseButton *button, bool *isPress) +{ + if (before == after) + return false; + for (int b = Qt::LeftButton; b <= Qt::MidButton; b<<=1) { + if ((before & b) != (after & b)) { + *button = static_cast(b); + *isPress = (after & b); + return true; + } + } + return false; +} + +void QVNCServer::pointerEvent() +{ + QRfbPointerEvent ev; + if (ev.read(client)) { +// const QPoint offset = qvnc_screen->offset(); +// QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons); + + + //qDebug() << "pointerEvent" << ev.x << ev.y << hex << ev.buttons; + + QEvent::Type type = QEvent::MouseMove; + Qt::MouseButton button = Qt::NoButton; + bool isPress; + if (buttonChange(buttons, ev.buttons, &button, &isPress)) + type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; + QMouseEvent me(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); + QApplicationPrivate::handleMouseEvent(0, me); + buttons = ev.buttons; + handleMsg = false; + } +} + +void QVNCServer::keyEvent() +{ + QRfbKeyEvent ev; + + if (ev.read(client)) { + if (ev.keycode == Qt::Key_Shift) + keymod = ev.down ? keymod | Qt::ShiftModifier : + keymod & ~Qt::ShiftModifier; + else if (ev.keycode == Qt::Key_Control) + keymod = ev.down ? keymod | Qt::ControlModifier : + keymod & ~Qt::ControlModifier; + else if (ev.keycode == Qt::Key_Alt) + keymod = ev.down ? keymod | Qt::AltModifier : + keymod & ~Qt::AltModifier; + if (ev.unicode || ev.keycode) { +// qDebug() << "keyEvent" << hex << ev.unicode << ev.keycode << keymod << ev.down; + QEvent::Type type = ev.down ? QEvent::KeyPress : QEvent::KeyRelease; + QString str; + if (ev.unicode && ev.unicode != 0xffff) + str = QString(ev.unicode); + QKeyEvent keyEvent(type, ev.keycode, keymod, str); + QApplicationPrivate::handleKeyEvent(0, &keyEvent); + } + handleMsg = false; + } +} + +void QVNCServer::clientCutText() +{ + QRfbClientCutText ev; + + if (ev.read(client)) { + cutTextPending = ev.length; + if (!cutTextPending) + handleMsg = false; + } + + if (cutTextPending && client->bytesAvailable() >= cutTextPending) { + char *text = new char [cutTextPending+1]; + client->read(text, cutTextPending); + delete [] text; + cutTextPending = 0; + handleMsg = false; + } +} + +// stride in bytes +template +bool QRfbSingleColorHextile::read(const uchar *data, + int width, int height, int stride) +{ + const int depth = encoder->server->screen()->depth(); + if (width % (depth / 8)) // hw: should rather fallback to simple loop + return false; + + static int alwaysFalse = qgetenv("QT_VNC_NOCHECKFILL").toInt(); + if (alwaysFalse) + return false; + + switch (depth) { + case 4: { + const quint8 *data8 = reinterpret_cast(data); + if ((data8[0] & 0xf) != (data8[0] >> 4)) + return false; + width /= 2; + } // fallthrough + case 8: { + const quint8 *data8 = reinterpret_cast(data); + if (data8[0] != data8[1]) + return false; + width /= 2; + } // fallthrough + case 12: + case 15: + case 16: { + const quint16 *data16 = reinterpret_cast(data); + if (data16[0] != data16[1]) + return false; + width /= 2; + } // fallthrough + case 18: + case 24: + case 32: { + const quint32 *data32 = reinterpret_cast(data); + const quint32 first = data32[0]; + const int linestep = (stride / sizeof(quint32)) - width; + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x) { + if (*(data32++) != first) + return false; + } + data32 += linestep; + } + break; + } + default: + return false; + } + + SRC color = reinterpret_cast(data)[0]; + encoder->newBg |= (color != encoder->bg); + encoder->bg = color; + return true; +} + +template +void QRfbSingleColorHextile::write(QTcpSocket *socket) const +{ + if (true || encoder->newBg) { + const int bpp = encoder->server->clientBytesPerPixel(); + const int padding = 3; + QVarLengthArray buffer(padding + 1 + bpp); + buffer[padding] = 2; // BackgroundSpecified + encoder->server->convertPixels(buffer.data() + padding + 1, + reinterpret_cast(&encoder->bg), + 1); + socket->write(buffer.data() + padding, bpp + 1); +// encoder->newBg = false; + } else { + char subenc = 0; + socket->write(&subenc, 1); + } +} + +template +bool QRfbDualColorHextile::read(const uchar *data, + int width, int height, int stride) +{ + const SRC *ptr = reinterpret_cast(data); + const int linestep = (stride / sizeof(SRC)) - width; + + SRC c1; + SRC c2 = 0; + int n1 = 0; + int n2 = 0; + int x = 0; + int y = 0; + + c1 = *ptr; + + // find second color + while (y < height) { + while (x < width) { + if (*ptr == c1) { + ++n1; + } else { + c2 = *ptr; + goto found_second_color; + } + ++ptr; + ++x; + } + x = 0; + ptr += linestep; + ++y; + } + +found_second_color: + // finish counting + while (y < height) { + while (x < width) { + if (*ptr == c1) { + ++n1; + } else if (*ptr == c2) { + ++n2; + } else { + return false; + } + ++ptr; + ++x; + } + x = 0; + ptr += linestep; + ++y; + } + + if (n2 > n1) { + const quint32 tmpC = c1; + c1 = c2; + c2 = tmpC; + } + + encoder->newBg |= (c1 != encoder->bg); + encoder->newFg |= (c2 != encoder->fg); + + encoder->bg = c1; + encoder->fg = c2; + + // create map + bool inRect = false; + numRects = 0; + ptr = reinterpret_cast(data); + for (y = 0; y < height; ++y) { + for (x = 0; x < width; ++x) { + if (inRect && *ptr == encoder->bg) { + // rect finished + setWidth(x - lastx()); + next(); + inRect = false; + } else if (!inRect && *ptr == encoder->fg) { + // rect start + setX(x); + setY(y); + setHeight(1); + inRect = true; + } + ++ptr; + } + if (inRect) { + // finish rect + setWidth(width - lastx()); + next(); + inRect = false; + } + ptr += linestep; + } + + return true; +} + +template +void QRfbDualColorHextile::write(QTcpSocket *socket) const +{ + const int bpp = encoder->server->clientBytesPerPixel(); + const int padding = 3; + QVarLengthArray buffer(padding + 2 * bpp + sizeof(char) + sizeof(numRects)); + char &subenc = buffer[padding]; + int n = padding + sizeof(subenc); + + subenc = 0x8; // AnySubrects + + if (encoder->newBg) { + subenc |= 0x2; // Background + encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->bg, 1); + n += bpp; +// encoder->newBg = false; + } + + if (encoder->newFg) { + subenc |= 0x4; // Foreground + encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->fg, 1); + n += bpp; +// encoder->newFg = false; + } + buffer[n] = numRects; + n += sizeof(numRects); + + socket->write(buffer.data() + padding, n - padding); + socket->write((char*)rects, numRects * sizeof(Rect)); +} + +template +void QRfbDualColorHextile::next() +{ + for (int r = numRects - 1; r >= 0; --r) { + if (recty(r) == lasty()) + continue; + if (recty(r) < lasty() - 1) // only search previous scanline + break; + if (rectx(r) == lastx() && width(r) == width(numRects)) { + ++rects[r].wh; + return; + } + } + ++numRects; +} + +template +inline void QRfbMultiColorHextile::setColor(SRC color) +{ + encoder->server->convertPixels(reinterpret_cast(rect(numRects)), + (const char*)&color, 1); +} + +template +inline bool QRfbMultiColorHextile::beginRect() +{ + if ((rects.size() + bpp + 2) > maxRectsSize) + return false; + rects.resize(rects.size() + bpp + 2); + return true; +} + +template +inline void QRfbMultiColorHextile::endRect() +{ + setHeight(numRects, 1); + ++numRects; +} + +template +bool QRfbMultiColorHextile::read(const uchar *data, + int width, int height, int stride) +{ + const SRC *ptr = reinterpret_cast(data); + const int linestep = (stride / sizeof(SRC)) - width; + + bpp = encoder->server->clientBytesPerPixel(); + + if (encoder->newBg) + encoder->bg = ptr[0]; + + const SRC bg = encoder->bg; + SRC color = bg; + bool inRect = false; + + numRects = 0; + rects.clear(); + + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x) { + if (inRect && *ptr != color) { // end rect + setWidth(numRects, x - rectx(numRects)); + endRect(); + inRect = false; + } + + if (!inRect && *ptr != bg) { // begin rect + if (!beginRect()) + return false; + inRect = true; + color = *ptr; + setColor(color); + setX(numRects, x); + setY(numRects, y); + } + ++ptr; + } + if (inRect) { // end rect + setWidth(numRects, width - rectx(numRects)); + endRect(); + inRect = false; + } + ptr += linestep; + } + + return true; +} + +template +void QRfbMultiColorHextile::write(QTcpSocket *socket) const +{ + const int padding = 3; + QVarLengthArray buffer(bpp + padding + sizeof(quint8) + sizeof(numRects)); + + quint8 &subenc = buffer[padding]; + int n = padding + sizeof(quint8); + + subenc = 8 | 16; // AnySubrects | SubrectsColoured + + if (encoder->newBg) { + subenc |= 0x2; // Background + encoder->server->convertPixels(reinterpret_cast(buffer.data() + n), + reinterpret_cast(&encoder->bg), + 1); + n += bpp; +// encoder->newBg = false; + } + + buffer[n] = numRects; + n += sizeof(numRects); + + socket->write(reinterpret_cast(buffer.data() + padding), + n - padding); + socket->write(reinterpret_cast(rects.constData()), + rects.size()); +} + +bool QVNCServer::pixelConversionNeeded() const +{ + if (!sameEndian) + return true; + +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + if (qvnc_screen->swapBytes()) + return true; +#endif + + const int screendepth = qvnc_screen->depth(); + if (screendepth != pixelFormat.bitsPerPixel) + return true; + + switch (screendepth) { + case 32: + case 24: + return false; + case 18: + return (pixelFormat.redBits == 6 + && pixelFormat.greenBits == 6 + && pixelFormat.blueBits == 6); + case 16: + return (pixelFormat.redBits == 5 + && pixelFormat.greenBits == 6 + && pixelFormat.blueBits == 5); + case 15: + return (pixelFormat.redBits == 5 + && pixelFormat.greenBits == 5 + && pixelFormat.blueBits == 5); + case 12: + return (pixelFormat.redBits == 4 + && pixelFormat.greenBits == 4 + && pixelFormat.blueBits == 4); + } + return true; +} + +// count: number of pixels +void QVNCServer::convertPixels(char *dst, const char *src, int count) const +{ + const int screendepth = qvnc_screen->depth(); + const bool isBgr = false; //### qvnc_screen->pixelType() == QScreen::BGRPixel; + + // cutoffs +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + if (!swapBytes) +#endif + if (sameEndian) { + if (screendepth == pixelFormat.bitsPerPixel) { // memcpy cutoffs + + switch (screendepth) { + case 32: + memcpy(dst, src, count * sizeof(quint32)); + return; + case 16: + if (pixelFormat.redBits == 5 + && pixelFormat.greenBits == 6 + && pixelFormat.blueBits == 5) + { + memcpy(dst, src, count * sizeof(quint16)); + return; + } + } + } else if (screendepth == 16 && pixelFormat.bitsPerPixel == 32) { +#if defined(__i386__) // Currently fails on ARM if dst is not 4 byte aligned + const quint32 *src32 = reinterpret_cast(src); + quint32 *dst32 = reinterpret_cast(dst); + int count32 = count * sizeof(quint16) / sizeof(quint32); + while (count32--) { + const quint32 s = *src32++; + quint32 result1; + quint32 result2; + + // red + result1 = ((s & 0xf8000000) | ((s & 0xe0000000) >> 5)) >> 8; + result2 = ((s & 0x0000f800) | ((s & 0x0000e000) >> 5)) << 8; + + // green + result1 |= ((s & 0x07e00000) | ((s & 0x06000000) >> 6)) >> 11; + result2 |= ((s & 0x000007e0) | ((s & 0x00000600) >> 6)) << 5; + + // blue + result1 |= ((s & 0x001f0000) | ((s & 0x001c0000) >> 5)) >> 13; + result2 |= ((s & 0x0000001f) | ((s & 0x0000001c) >> 5)) << 3; + + *dst32++ = result2; + *dst32++ = result1; + } + if (count & 0x1) { + const quint16 *src16 = reinterpret_cast(src); + dst32[count - 1] = qt_conv16ToRgb(src16[count - 1]); + } + return; +#endif + } + } + + const int bytesPerPixel = (pixelFormat.bitsPerPixel + 7) / 8; + +// nibble = 0; + + for (int i = 0; i < count; ++i) { + int r, g, b; + + switch (screendepth) { +#if 0 + case 4: { + if (!nibble) { + r = ((*src) & 0x0f) << 4; + } else { + r = (*src) & 0xf0; + src++; + } + nibble = !nibble; + g = b = r; + break; + } +#endif +#if 0 + case 8: { + QRgb rgb = qvnc_screen->clut()[int(*src)]; + r = qRed(rgb); + g = qGreen(rgb); + b = qBlue(rgb); + src++; + break; + } +#endif +#ifdef QT_QWS_DEPTH_12 + case 12: { + quint32 p = quint32(*reinterpret_cast(src)); + r = qRed(p); + g = qGreen(p); + b = qBlue(p); + src += sizeof(qrgb444); + break; + } +#endif +#ifdef QT_QWS_DEPTH_15 + case 15: { + quint32 p = quint32(*reinterpret_cast(src)); + r = qRed(p); + g = qGreen(p); + b = qBlue(p); + src += sizeof(qrgb555); + break; + } +#endif + case 16: { + quint16 p = *reinterpret_cast(src); +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + if (swapBytes) + p = ((p & 0xff) << 8) | ((p & 0xff00) >> 8); +#endif + r = (p >> 11) & 0x1f; + g = (p >> 5) & 0x3f; + b = p & 0x1f; + r <<= 3; + g <<= 2; + b <<= 3; + src += sizeof(quint16); + break; + } +#ifdef QT_QWS_DEPTH_18 + case 18: { + quint32 p = quint32(*reinterpret_cast(src)); + r = qRed(p); + g = qGreen(p); + b = qBlue(p); + src += sizeof(qrgb666); + break; + } +#endif +#ifdef QT_QWS_DEPTH_24 + case 24: { + quint32 p = quint32(*reinterpret_cast(src)); + r = qRed(p); + g = qGreen(p); + b = qBlue(p); + src += sizeof(qrgb888); + break; + } +#endif + case 32: { + quint32 p = *reinterpret_cast(src); + r = (p >> 16) & 0xff; + g = (p >> 8) & 0xff; + b = p & 0xff; + src += sizeof(quint32); + break; + } + default: { + r = g = b = 0; + qDebug("QVNCServer: don't support %dbpp display", screendepth); + return; + } + } + +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + if (swapBytes ^ isBgr) +#else + if (isBgr) +#endif + qSwap(r, b); + + r >>= (8 - pixelFormat.redBits); + g >>= (8 - pixelFormat.greenBits); + b >>= (8 - pixelFormat.blueBits); + + int pixel = (r << pixelFormat.redShift) | + (g << pixelFormat.greenShift) | + (b << pixelFormat.blueShift); + + if (sameEndian || pixelFormat.bitsPerPixel == 8) { + memcpy(dst, &pixel, bytesPerPixel); // XXX: do a simple for-loop instead? + dst += bytesPerPixel; + continue; + } + + + if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { + switch (pixelFormat.bitsPerPixel) { + case 16: + pixel = (((pixel & 0x0000ff00) << 8) | + ((pixel & 0x000000ff) << 24)); + break; + case 32: + pixel = (((pixel & 0xff000000) >> 24) | + ((pixel & 0x00ff0000) >> 8) | + ((pixel & 0x0000ff00) << 8) | + ((pixel & 0x000000ff) << 24)); + break; + default: + qDebug("Cannot handle %d bpp client", pixelFormat.bitsPerPixel); + } + } else { // QSysInfo::ByteOrder == QSysInfo::LittleEndian + switch (pixelFormat.bitsPerPixel) { + case 16: + pixel = (((pixel & 0xff000000) >> 8) | + ((pixel & 0x00ff0000) << 8)); + break; + case 32: + pixel = (((pixel & 0xff000000) >> 24) | + ((pixel & 0x00ff0000) >> 8) | + ((pixel & 0x0000ff00) << 8) | + ((pixel & 0x000000ff) << 24)); + break; + default: + qDebug("Cannot handle %d bpp client", + pixelFormat.bitsPerPixel); + break; + } + } + memcpy(dst, &pixel, bytesPerPixel); // XXX: simple for-loop instead? + dst += bytesPerPixel; + } +} + +#ifndef QT_NO_QWS_CURSOR +static void blendCursor(QImage &image, const QRect &imageRect) +{ + const QRect cursorRect = qt_screencursor->boundingRect(); + const QRect intersection = (cursorRect & imageRect); + const QRect destRect = intersection.translated(-imageRect.topLeft()); + const QRect srcRect = intersection.translated(-cursorRect.topLeft()); + + QPainter painter(&image); + painter.drawImage(destRect, qt_screencursor->image(), srcRect); + painter.end(); +} +#endif // QT_NO_QWS_CURSOR + +QVNCDirtyMap::QVNCDirtyMap(QVNCGraphicsSystemScreen *s) + : bytesPerPixel(0), numDirty(0), screen(s) +{ + bytesPerPixel = (screen->depth() + 7) / 8; + QSize screenSize = screen->geometry().size(); + bufferWidth = screenSize.width(); + bufferHeight = screenSize.height(); + bufferStride = bufferWidth * bytesPerPixel; + buffer = new uchar[bufferHeight * bufferStride]; + + mapWidth = (bufferWidth + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE; + mapHeight = (bufferHeight + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE; + numTiles = mapWidth * mapHeight; + map = new uchar[numTiles]; +} + +QVNCDirtyMap::~QVNCDirtyMap() +{ + delete[] map; + delete[] buffer; +} + +void QVNCDirtyMap::reset() +{ + memset(map, 1, numTiles); + memset(buffer, 0, bufferHeight * bufferStride); + numDirty = numTiles; +} + +inline bool QVNCDirtyMap::dirty(int x, int y) const +{ + return map[y * mapWidth + x]; +} + +inline void QVNCDirtyMap::setClean(int x, int y) +{ + map[y * mapWidth + x] = 0; + --numDirty; +} + +template +void QVNCDirtyMapOptimized::setDirty(int tileX, int tileY, bool force) +{ + static bool alwaysForce = qgetenv("QT_VNC_NO_COMPAREBUFFER").toInt(); + if (alwaysForce) + force = true; + + bool changed = false; + + if (!force) { + const int lstep = screen->linestep(); + const int startX = tileX * MAP_TILE_SIZE; + const int startY = tileY * MAP_TILE_SIZE; + const uchar *scrn = screen->base() + + startY * lstep + startX * bytesPerPixel; + uchar *old = buffer + startY * bufferStride + startX * sizeof(T); + + const int tileHeight = (startY + MAP_TILE_SIZE > bufferHeight ? + bufferHeight - startY : MAP_TILE_SIZE); + const int tileWidth = (startX + MAP_TILE_SIZE > bufferWidth ? + bufferWidth - startX : MAP_TILE_SIZE); + const bool doInlines = (tileWidth == MAP_TILE_SIZE); + + int y = tileHeight; + + if (doInlines) { // hw: memcmp/memcpy is inlined when using constants + while (y) { + if (memcmp(old, scrn, sizeof(T) * MAP_TILE_SIZE)) { + changed = true; + break; + } + scrn += lstep; + old += bufferStride; + --y; + } + + while (y) { + memcpy(old, scrn, sizeof(T) * MAP_TILE_SIZE); + scrn += lstep; + old += bufferStride; + --y; + } + } else { + while (y) { + if (memcmp(old, scrn, sizeof(T) * tileWidth)) { + changed = true; + break; + } + scrn += lstep; + old += bufferStride; + --y; + } + + while (y) { + memcpy(old, scrn, sizeof(T) * tileWidth); + scrn += lstep; + old += bufferStride; + --y; + } + } + } + + const int mapIndex = tileY * mapWidth + tileX; + if ((force || changed) && !map[mapIndex]) { + map[mapIndex] = 1; + ++numDirty; + } +} + +template +QRfbHextileEncoder::QRfbHextileEncoder(QVNCServer *s) + : QRfbEncoder(s), + singleColorHextile(this), dualColorHextile(this), multiColorHextile(this) +{ +} + +/* + \internal + Send dirty rects using hextile encoding. +*/ +template +void QRfbHextileEncoder::write() +{ +// QWSDisplay::grab(true); + + QVNCDirtyMap *map = server->dirtyMap(); + QTcpSocket *socket = server->clientSocket(); + + const quint32 encoding = htonl(5); // hextile encoding + const int bytesPerPixel = server->clientBytesPerPixel(); + + { + const char tmp[2] = { 0, 0 }; // msg type, padding + socket->write(tmp, sizeof(tmp)); + } + { + const quint16 count = htons(map->numDirty); + socket->write((char *)&count, sizeof(count)); + } + + if (map->numDirty <= 0) { +// QWSDisplay::ungrab(); + return; + } + + newBg = true; + newFg = true; + + const QImage screenImage = server->screenImage(); + QRfbRect rect(0, 0, MAP_TILE_SIZE, MAP_TILE_SIZE); + + QSize screenSize = server->screen()->geometry().size(); + + for (int y = 0; y < map->mapHeight; ++y) { + if (rect.y + MAP_TILE_SIZE > screenSize.height()) + rect.h = screenSize.height() - rect.y; + rect.w = MAP_TILE_SIZE; + for (int x = 0; x < map->mapWidth; ++x) { + if (!map->dirty(x, y)) + continue; + map->setClean(x, y); + + rect.x = x * MAP_TILE_SIZE; + if (rect.x + MAP_TILE_SIZE > screenSize.width()) //###deviceWidth ??? + rect.w = screenSize.width() - rect.x; + rect.write(socket); + + socket->write((char *)&encoding, sizeof(encoding)); + + const uchar *screendata = screenImage.scanLine(rect.y) + + rect.x * screenImage.depth() / 8; + int linestep = screenImage.bytesPerLine(); + +#ifndef QT_NO_QWS_CURSOR + // hardware cursors must be blended with the screen memory + const bool doBlendCursor = qt_screencursor + && !server->hasClientCursor() + && qt_screencursor->isAccelerated(); + QImage tileImage; + if (doBlendCursor) { + const QRect tileRect(rect.x, rect.y, rect.w, rect.h); + const QRect cursorRect = qt_screencursor->boundingRect() + .translated(-server->screen()->offset()); + if (tileRect.intersects(cursorRect)) { + tileImage = screenImage.copy(tileRect); + blendCursor(tileImage, + tileRect.translated(server->screen()->offset())); + screendata = tileImage.bits(); + linestep = tileImage.bytesPerLine(); + } + } +#endif // QT_NO_QWS_CURSOR + + if (singleColorHextile.read(screendata, rect.w, rect.h, linestep)) { + singleColorHextile.write(socket); + } else if (dualColorHextile.read(screendata, rect.w, rect.h, linestep)) { + dualColorHextile.write(socket); + } else if (multiColorHextile.read(screendata, rect.w, rect.h, linestep)) { + multiColorHextile.write(socket); + } else if (server->doPixelConversion()) { + const int bufferSize = rect.w * rect.h * bytesPerPixel + 1; + const int padding = sizeof(quint32) - sizeof(char); + buffer.resize(bufferSize + padding); + + buffer[padding] = 1; // Raw subencoding + + // convert pixels + char *b = buffer.data() + padding + 1; + const int bstep = rect.w * bytesPerPixel; + for (int i = 0; i < rect.h; ++i) { + server->convertPixels(b, (const char*)screendata, rect.w); + screendata += linestep; + b += bstep; + } + socket->write(buffer.constData() + padding, bufferSize); + } else { + quint8 subenc = 1; // Raw subencoding + socket->write((char *)&subenc, 1); + + // send pixels + for (int i = 0; i < rect.h; ++i) { + socket->write((const char*)screendata, + rect.w * bytesPerPixel); + screendata += linestep; + } + } + } + if (socket->state() == QAbstractSocket::UnconnectedState) + break; + rect.y += MAP_TILE_SIZE; + } + socket->flush(); + Q_ASSERT(map->numDirty == 0); + +// QWSDisplay::ungrab(); +} + +void QRfbRawEncoder::write() +{ +// QWSDisplay::grab(false); + + QVNCDirtyMap *map = server->dirtyMap(); + QTcpSocket *socket = server->clientSocket(); + + const int bytesPerPixel = server->clientBytesPerPixel(); + QSize screenSize = server->screen()->geometry().size(); + + // create a region from the dirty rects and send the region's merged rects. + QRegion rgn; + if (map) { + for (int y = 0; y < map->mapHeight; ++y) { + for (int x = 0; x < map->mapWidth; ++x) { + if (!map->dirty(x, y)) + continue; + rgn += QRect(x * MAP_TILE_SIZE, y * MAP_TILE_SIZE, + MAP_TILE_SIZE, MAP_TILE_SIZE); + map->setClean(x, y); + } + } + + rgn &= QRect(0, 0, screenSize.width(), + screenSize.height()); + } + const QVector rects = rgn.rects(); + + { + const char tmp[2] = { 0, 0 }; // msg type, padding + socket->write(tmp, sizeof(tmp)); + } + + { + const quint16 count = htons(rects.size()); + socket->write((char *)&count, sizeof(count)); + } + + if (rects.size() <= 0) { +// QWSDisplay::ungrab(); + return; + } + + const QImage *screenImage = server->screenImage(); + + for (int i = 0; i < rects.size(); ++i) { + const QRect tileRect = rects.at(i); + const QRfbRect rect(tileRect.x(), tileRect.y(), + tileRect.width(), tileRect.height()); + rect.write(socket); + + const quint32 encoding = htonl(0); // raw encoding + socket->write((char *)&encoding, sizeof(encoding)); + + int linestep = screenImage->bytesPerLine(); + const uchar *screendata = screenImage->scanLine(rect.y) + + rect.x * screenImage->depth() / 8; + +#ifndef QT_NO_QWS_CURSOR + // hardware cursors must be blended with the screen memory + const bool doBlendCursor = qt_screencursor + && !server->hasClientCursor() + && qt_screencursor->isAccelerated(); + QImage tileImage; + if (doBlendCursor) { + const QRect cursorRect = qt_screencursor->boundingRect() + .translated(-server->screen()->offset()); + if (tileRect.intersects(cursorRect)) { + tileImage = screenImage->copy(tileRect); + blendCursor(tileImage, + tileRect.translated(server->screen()->offset())); + screendata = tileImage.bits(); + linestep = tileImage.bytesPerLine(); + } + } +#endif // QT_NO_QWS_CURSOR + + if (server->doPixelConversion()) { + const int bufferSize = rect.w * rect.h * bytesPerPixel; + if (bufferSize > buffer.size()) + buffer.resize(bufferSize); + + // convert pixels + char *b = buffer.data(); + const int bstep = rect.w * bytesPerPixel; + for (int i = 0; i < rect.h; ++i) { + server->convertPixels(b, (const char*)screendata, rect.w); + screendata += linestep; + b += bstep; + } + socket->write(buffer.constData(), bufferSize); + } else { + for (int i = 0; i < rect.h; ++i) { + socket->write((const char*)screendata, rect.w * bytesPerPixel); + screendata += linestep; + } + } + if (socket->state() == QAbstractSocket::UnconnectedState) + break; + } + socket->flush(); + +// QWSDisplay::ungrab(); +} + +inline QImage *QVNCServer::screenImage() const +{ + return qvnc_screen->mScreenImage; +} + +void QVNCServer::checkUpdate() +{ + if (!wantUpdate) + return; + + if (dirtyCursor) { +#ifndef QT_NO_QWS_CURSOR + Q_ASSERT(qvnc_cursor); + qvnc_cursor->write(); +#endif + dirtyCursor = false; + wantUpdate = false; + return; + } + + if (dirtyMap()->numDirty > 0) { + if (encoder) + encoder->write(); + wantUpdate = false; + } +} + +void QVNCServer::discardClient() +{ + timer->stop(); + state = Unconnected; + delete encoder; + encoder = 0; +#ifndef QT_NO_QWS_CURSOR + delete qvnc_cursor; + qvnc_cursor = 0; +#endif +// if (!qvnc_screen->screen()) +// QWSServer::instance()->enablePainting(false); +} + + + +QVNCGraphicsSystemScreenPrivate::QVNCGraphicsSystemScreenPrivate(QVNCGraphicsSystemScreen *parent) + : dpiX(72), dpiY(72), doOnScreenSurface(false), refreshRate(25), + vncServer(0), q_ptr(parent) +{ +#if 0//ndef QT_NO_QWS_SIGNALHANDLER + QWSSignalHandler::instance()->addObject(this); +#endif + + vncServer = new QVNCServer(q_ptr); + vncServer->setRefreshRate(refreshRate); + + + Q_ASSERT(q_ptr->depth() == 32); + + dirty = new QVNCDirtyMapOptimized(q_ptr); +} + +QVNCGraphicsSystemScreenPrivate::~QVNCGraphicsSystemScreenPrivate() +{ +} + + +void QVNCGraphicsSystemScreenPrivate::setDirty(const QRect& rect, bool force) +{ + if (rect.isEmpty()) + return; + +// if (q_ptr->screen()) +// q_ptr->screen()->setDirty(rect); + + if (!vncServer || !vncServer->isConnected()) { +// qDebug() << "QVNCGraphicsSystemScreenPrivate::setDirty() - Not connected"; + return; + } + const QRect r = rect; // .translated(-q_ptr->offset()); + const int x1 = r.x() / MAP_TILE_SIZE; + int y = r.y() / MAP_TILE_SIZE; + for (; (y <= r.bottom() / MAP_TILE_SIZE) && y < dirty->mapHeight; y++) + for (int x = x1; (x <= r.right() / MAP_TILE_SIZE) && x < dirty->mapWidth; x++) + dirty->setDirty(x, y, force); + + vncServer->setDirty(); +} + + + + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/vnc/qvncserver.h b/src/plugins/graphicssystems/vnc/qvncserver.h new file mode 100644 index 0000000..e7eb531 --- /dev/null +++ b/src/plugins/graphicssystems/vnc/qvncserver.h @@ -0,0 +1,524 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QSCREENVNC_P_H +#define QSCREENVNC_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include "qgraphicssystem_vnc.h" +#define QT_NO_QWS_CURSOR + +#ifndef QT_NO_QWS_VNC + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QVNCServer; + +#ifndef QT_NO_QWS_CURSOR +class QVNCCursor : public QProxyScreenCursor +{ +public: + QVNCCursor(QVNCGraphicsSystemScreen *s); + ~QVNCCursor(); + + void hide(); + void show(); + void set(const QImage &image, int hotx, int hoty); + void move(int x, int y); + +private: + void setDirty(const QRect &r) const; + QVNCGraphicsSystemScreen *screen; +}; + +class QVNCClientCursor : public QProxyScreenCursor +{ +public: + QVNCClientCursor(QVNCServer *s); + ~QVNCClientCursor(); + + void set(const QImage &image, int hotx, int hoty); + void write() const; + +private: + QVNCServer *server; +}; +#endif // QT_NO_QWS_CURSOR + +#define MAP_TILE_SIZE 16 +#define MAP_WIDTH 1280 / MAP_TILE_SIZE +#define MAP_HEIGHT 1024 / MAP_TILE_SIZE + +class QVNCDirtyMap +{ +public: + QVNCDirtyMap(QVNCGraphicsSystemScreen *screen); + virtual ~QVNCDirtyMap(); + + void reset(); + bool dirty(int x, int y) const; + virtual void setDirty(int x, int y, bool force = false) = 0; + void setClean(int x, int y); + + int bytesPerPixel; + + int numDirty; + int mapWidth; + int mapHeight; + +protected: + uchar *map; + QVNCGraphicsSystemScreen *screen; + uchar *buffer; + int bufferWidth; + int bufferHeight; + int bufferStride; + int numTiles; +}; + +template +class QVNCDirtyMapOptimized : public QVNCDirtyMap +{ +public: + QVNCDirtyMapOptimized(QVNCGraphicsSystemScreen *screen) : QVNCDirtyMap(screen) {} + ~QVNCDirtyMapOptimized() {} + + void setDirty(int x, int y, bool force = false); +}; + +class QRfbRect +{ +public: + QRfbRect() {} + QRfbRect(quint16 _x, quint16 _y, quint16 _w, quint16 _h) { + x = _x; y = _y; w = _w; h = _h; + } + + void read(QTcpSocket *s); + void write(QTcpSocket *s) const; + + quint16 x; + quint16 y; + quint16 w; + quint16 h; +}; + +class QRfbPixelFormat +{ +public: + static int size() { return 16; } + + void read(QTcpSocket *s); + void write(QTcpSocket *s); + + int bitsPerPixel; + int depth; + bool bigEndian; + bool trueColor; + int redBits; + int greenBits; + int blueBits; + int redShift; + int greenShift; + int blueShift; +}; + +class QRfbServerInit +{ +public: + QRfbServerInit() { name = 0; } + ~QRfbServerInit() { delete[] name; } + + int size() const { return QRfbPixelFormat::size() + 8 + strlen(name); } + void setName(const char *n); + + void read(QTcpSocket *s); + void write(QTcpSocket *s); + + quint16 width; + quint16 height; + QRfbPixelFormat format; + char *name; +}; + +class QRfbSetEncodings +{ +public: + bool read(QTcpSocket *s); + + quint16 count; +}; + +class QRfbFrameBufferUpdateRequest +{ +public: + bool read(QTcpSocket *s); + + char incremental; + QRfbRect rect; +}; + +class QRfbKeyEvent +{ +public: + bool read(QTcpSocket *s); + + char down; + int keycode; + int unicode; +}; + +class QRfbPointerEvent +{ +public: + bool read(QTcpSocket *s); + + Qt::MouseButtons buttons; + quint16 x; + quint16 y; +}; + +class QRfbClientCutText +{ +public: + bool read(QTcpSocket *s); + + quint32 length; +}; + +class QVNCGraphicsSystemScreenPrivate : public QObject +{ +public: + QVNCGraphicsSystemScreenPrivate(QVNCGraphicsSystemScreen *parent); + ~QVNCGraphicsSystemScreenPrivate(); + + void setDirty(const QRect &rect, bool force = false); + void configure(); + + qreal dpiX; + qreal dpiY; + bool doOnScreenSurface; + QVNCDirtyMap *dirty; + int refreshRate; + QVNCServer *vncServer; + +#if !defined(QT_NO_QWS_MULTIPROCESS) && !defined(QT_NO_SHAREDMEMORY) + QSharedMemory shm; +#endif + + QVNCGraphicsSystemScreen *q_ptr; +}; + +class QRfbEncoder +{ +public: + QRfbEncoder(QVNCServer *s) : server(s) {} + virtual ~QRfbEncoder() {} + + virtual void write() = 0; + +protected: + QVNCServer *server; +}; + +class QRfbRawEncoder : public QRfbEncoder +{ +public: + QRfbRawEncoder(QVNCServer *s) : QRfbEncoder(s) {} + + void write(); + +private: + QByteArray buffer; +}; + +template class QRfbHextileEncoder; + +template +class QRfbSingleColorHextile +{ +public: + QRfbSingleColorHextile(QRfbHextileEncoder *e) : encoder(e) {} + bool read(const uchar *data, int width, int height, int stride); + void write(QTcpSocket *socket) const; + +private: + QRfbHextileEncoder *encoder; +}; + +template +class QRfbDualColorHextile +{ +public: + QRfbDualColorHextile(QRfbHextileEncoder *e) : encoder(e) {} + bool read(const uchar *data, int width, int height, int stride); + void write(QTcpSocket *socket) const; + +private: + struct Rect { + quint8 xy; + quint8 wh; + } Q_PACKED rects[8 * 16]; + + quint8 numRects; + QRfbHextileEncoder *encoder; + +private: + inline int lastx() const { return rectx(numRects); } + inline int lasty() const { return recty(numRects); } + inline int rectx(int r) const { return rects[r].xy >> 4; } + inline int recty(int r) const { return rects[r].xy & 0x0f; } + inline int width(int r) const { return (rects[r].wh >> 4) + 1; } + inline int height(int r) const { return (rects[r].wh & 0x0f) + 1; } + + inline void setX(int r, int x) { + rects[r].xy = (x << 4) | (rects[r].xy & 0x0f); + } + inline void setY(int r, int y) { + rects[r].xy = (rects[r].xy & 0xf0) | y; + } + inline void setWidth(int r, int width) { + rects[r].wh = ((width - 1) << 4) | (rects[r].wh & 0x0f); + } + inline void setHeight(int r, int height) { + rects[r].wh = (rects[r].wh & 0xf0) | (height - 1); + } + + inline void setWidth(int width) { setWidth(numRects, width); } + inline void setHeight(int height) { setHeight(numRects, height); } + inline void setX(int x) { setX(numRects, x); } + inline void setY(int y) { setY(numRects, y); } + void next(); +}; + +template +class QRfbMultiColorHextile +{ +public: + QRfbMultiColorHextile(QRfbHextileEncoder *e) : encoder(e) {} + bool read(const uchar *data, int width, int height, int stride); + void write(QTcpSocket *socket) const; + +private: + inline quint8* rect(int r) { + return rects.data() + r * (bpp + 2); + } + inline const quint8* rect(int r) const { + return rects.constData() + r * (bpp + 2); + } + inline void setX(int r, int x) { + quint8 *ptr = rect(r) + bpp; + *ptr = (x << 4) | (*ptr & 0x0f); + } + inline void setY(int r, int y) { + quint8 *ptr = rect(r) + bpp; + *ptr = (*ptr & 0xf0) | y; + } + void setColor(SRC color); + inline int rectx(int r) const { + const quint8 *ptr = rect(r) + bpp; + return *ptr >> 4; + } + inline int recty(int r) const { + const quint8 *ptr = rect(r) + bpp; + return *ptr & 0x0f; + } + inline void setWidth(int r, int width) { + quint8 *ptr = rect(r) + bpp + 1; + *ptr = ((width - 1) << 4) | (*ptr & 0x0f); + } + inline void setHeight(int r, int height) { + quint8 *ptr = rect(r) + bpp + 1; + *ptr = (*ptr & 0xf0) | (height - 1); + } + + bool beginRect(); + void endRect(); + + static const int maxRectsSize = 16 * 16; + QVarLengthArray rects; + + quint8 bpp; + quint8 numRects; + QRfbHextileEncoder *encoder; +}; + +template +class QRfbHextileEncoder : public QRfbEncoder +{ +public: + QRfbHextileEncoder(QVNCServer *s); + void write(); + +private: + enum SubEncoding { + Raw = 1, + BackgroundSpecified = 2, + ForegroundSpecified = 4, + AnySubrects = 8, + SubrectsColoured = 16 + }; + + QByteArray buffer; + QRfbSingleColorHextile singleColorHextile; + QRfbDualColorHextile dualColorHextile; + QRfbMultiColorHextile multiColorHextile; + + SRC bg; + SRC fg; + bool newBg; + bool newFg; + + friend class QRfbSingleColorHextile; + friend class QRfbDualColorHextile; + friend class QRfbMultiColorHextile; +}; + +class QVNCServer : public QObject +{ + Q_OBJECT +public: + QVNCServer(QVNCGraphicsSystemScreen *screen); + QVNCServer(QVNCGraphicsSystemScreen *screen, int id); + ~QVNCServer(); + + void setDirty(); + void setDirtyCursor() { dirtyCursor = true; setDirty(); } + inline bool isConnected() const { return state == Connected; } + inline void setRefreshRate(int rate) { refreshRate = rate; } + + enum ClientMsg { SetPixelFormat = 0, + FixColourMapEntries = 1, + SetEncodings = 2, + FramebufferUpdateRequest = 3, + KeyEvent = 4, + PointerEvent = 5, + ClientCutText = 6 }; + + enum ServerMsg { FramebufferUpdate = 0, + SetColourMapEntries = 1 }; + + void convertPixels(char *dst, const char *src, int count) const; + + inline int clientBytesPerPixel() const { + return pixelFormat.bitsPerPixel / 8; + } + + inline QVNCGraphicsSystemScreen* screen() const { return qvnc_screen; } + inline QVNCDirtyMap* dirtyMap() const { return qvnc_screen->dirtyMap(); } + inline QTcpSocket* clientSocket() const { return client; } + QImage *screenImage() const; + inline bool doPixelConversion() const { return needConversion; } +#ifndef QT_NO_QWS_CURSOR + inline bool hasClientCursor() const { return qvnc_cursor != 0; } +#endif + +private: + void setPixelFormat(); + void setEncodings(); + void frameBufferUpdateRequest(); + void pointerEvent(); + void keyEvent(); + void clientCutText(); + bool pixelConversionNeeded() const; + +private slots: + void newConnection(); + void readClient(); + void checkUpdate(); + void discardClient(); + +private: + void init(uint port); + enum ClientState { Unconnected, Protocol, Init, Connected }; + QTimer *timer; + QTcpServer *serverSocket; + QTcpSocket *client; + ClientState state; + quint8 msgType; + bool handleMsg; + QRfbPixelFormat pixelFormat; + Qt::KeyboardModifiers keymod; + Qt::MouseButtons buttons; + int encodingsPending; + int cutTextPending; + uint supportCopyRect : 1; + uint supportRRE : 1; + uint supportCoRRE : 1; + uint supportHextile : 1; + uint supportZRLE : 1; + uint supportCursor : 1; + uint supportDesktopSize : 1; + bool wantUpdate; + bool sameEndian; + bool needConversion; +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + bool swapBytes; +#endif + bool dirtyCursor; + int refreshRate; + QVNCGraphicsSystemScreen *qvnc_screen; +#ifndef QT_NO_QWS_CURSOR + QVNCClientCursor *qvnc_cursor; +#endif + + QRfbEncoder *encoder; +}; + + +QT_END_NAMESPACE +#endif // QT_NO_QWS_VNC +#endif // QSCREENVNC_P_H diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp new file mode 100644 index 0000000..9429eb2 --- /dev/null +++ b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 "qwindowsurface_vnc.h" +#include "qgraphicssystem_vnc.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QVNCWindowSurface::QVNCWindowSurface(QVNCGraphicsSystem *graphicsSystem, + QVNCGraphicsSystemScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen) +{ +} + +QVNCWindowSurface::~QVNCWindowSurface() +{ +} + +QPaintDevice *QVNCWindowSurface::paintDevice() +{ + return mScreen->mScreenImage; +} + +void QVNCWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(offset); + + QRect rect = geometry(); + QPoint topLeft = rect.topLeft(); + + mScreen->setDirty(region.boundingRect()); + // server->flush(region); + +} + +void QVNCWindowSurface::setGeometry(const QRect &) +{ + +// any size you like as long as it's full-screen... + + QRect rect(mScreen->availableGeometry()); + QApplicationPrivate::handleGeometryChange(this->window(), rect); + + QWindowSurface::setGeometry(rect); +} + +bool QVNCWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QVNCWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QVNCWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h new file mode 100644 index 0000000..3a85db3 --- /dev/null +++ b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_TESTLITE_H +#define QWINDOWSURFACE_TESTLITE_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class MyWindow; +class QVNCGraphicsSystem; +class QVNCGraphicsSystemScreen; + +class QVNCWindowSurface : public QWindowSurface +{ +public: + QVNCWindowSurface(QVNCGraphicsSystem *graphicsSystem, + QVNCGraphicsSystemScreen *screen, QWidget *window); + ~QVNCWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + +private: + QVNCGraphicsSystem *mGraphicsSystem; + QVNCGraphicsSystemScreen *mScreen; + MyWindow *xw; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/vnc/vnc.pro b/src/plugins/graphicssystems/vnc/vnc.pro new file mode 100644 index 0000000..20e48ad --- /dev/null +++ b/src/plugins/graphicssystems/vnc/vnc.pro @@ -0,0 +1,16 @@ +TARGET = qvncgraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + + + +SOURCES = main.cpp qgraphicssystem_vnc.cpp qwindowsurface_vnc.cpp +HEADERS = qgraphicssystem_vnc.h qwindowsurface_vnc.h + +HEADERS += qvncserver.h +SOURCES += qvncserver.cpp + + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/tools/tools.pro b/tools/tools.pro index 4b36115..f079357 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -16,7 +16,7 @@ no-png { SUBDIRS += linguist symbian: SUBDIRS = designer wince*: SUBDIRS = qtestlib designer - unix:!mac:!embedded:contains(QT_CONFIG, qt3support):SUBDIRS += qtconfig + unix:!mac:!embedded:!embedded_lite:contains(QT_CONFIG, qt3support):SUBDIRS += qtconfig win32:!wince*:SUBDIRS += activeqt } -- cgit v0.12 From 7f808c0b4b640ee0f0d7e5f6ace98bda7de5730c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 30 Sep 2009 16:45:16 +0200 Subject: Update to the latest version of the copyright headers. --- src/gui/egl/qegl_lite.cpp | 8 ++++---- src/gui/image/qpixmap_lite.cpp | 8 ++++---- src/gui/kernel/qapplication_lite.cpp | 8 ++++---- src/gui/kernel/qclipboard_lite.cpp | 8 ++++---- src/gui/kernel/qcursor_lite.cpp | 8 ++++---- src/gui/kernel/qdesktopwidget_lite.cpp | 8 ++++---- src/gui/kernel/qgenericplugin_lite.cpp | 8 ++++---- src/gui/kernel/qgenericplugin_lite.h | 8 ++++---- src/gui/kernel/qgenericpluginfactory_lite.cpp | 8 ++++---- src/gui/kernel/qgenericpluginfactory_lite.h | 8 ++++---- src/gui/kernel/qsound_lite.cpp | 8 ++++---- src/gui/kernel/qwidget_lite.cpp | 8 ++++---- src/gui/painting/qcolormap_lite.cpp | 8 ++++---- src/gui/painting/qpaintdevice_lite.cpp | 8 ++++---- src/plugins/generic/linuxinput/main.cpp | 8 ++++---- src/plugins/generic/linuxinput/qlinuxinput.cpp | 8 ++++---- src/plugins/generic/linuxinput/qlinuxinput.h | 8 ++++---- src/plugins/graphicssystems/linuxfb/main.cpp | 8 ++++---- src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp | 8 ++++---- src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h | 8 ++++---- src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp | 8 ++++---- src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h | 8 ++++---- src/plugins/graphicssystems/minimal/main.cpp | 8 ++++---- src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp | 8 ++++---- src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h | 8 ++++---- src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp | 8 ++++---- src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h | 8 ++++---- src/plugins/graphicssystems/openvglite/main.cpp | 8 ++++---- src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp | 8 ++++---- src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h | 8 ++++---- src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp | 8 ++++---- src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h | 8 ++++---- src/plugins/graphicssystems/testlite/main.cpp | 8 ++++---- src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp | 8 ++++---- src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h | 8 ++++---- src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp | 8 ++++---- src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h | 8 ++++---- src/plugins/graphicssystems/testlite/x11util.cpp | 8 ++++---- src/plugins/graphicssystems/testlite/x11util.h | 8 ++++---- src/plugins/graphicssystems/vnc/main.cpp | 8 ++++---- src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp | 8 ++++---- src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h | 8 ++++---- src/plugins/graphicssystems/vnc/qvncserver.cpp | 8 ++++---- src/plugins/graphicssystems/vnc/qvncserver.h | 8 ++++---- src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp | 8 ++++---- src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h | 8 ++++---- 46 files changed, 184 insertions(+), 184 deletions(-) diff --git a/src/gui/egl/qegl_lite.cpp b/src/gui/egl/qegl_lite.cpp index 784b252..40439c6 100644 --- a/src/gui/egl/qegl_lite.cpp +++ b/src/gui/egl/qegl_lite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/image/qpixmap_lite.cpp b/src/gui/image/qpixmap_lite.cpp index 4ba69fa..90761ca 100644 --- a/src/gui/image/qpixmap_lite.cpp +++ b/src/gui/image/qpixmap_lite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index eec3e6c..384c987 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/kernel/qclipboard_lite.cpp b/src/gui/kernel/qclipboard_lite.cpp index 0d9268f..92b9e83 100644 --- a/src/gui/kernel/qclipboard_lite.cpp +++ b/src/gui/kernel/qclipboard_lite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/kernel/qcursor_lite.cpp b/src/gui/kernel/qcursor_lite.cpp index 5af03fc..a6ae7d3 100644 --- a/src/gui/kernel/qcursor_lite.cpp +++ b/src/gui/kernel/qcursor_lite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/kernel/qdesktopwidget_lite.cpp b/src/gui/kernel/qdesktopwidget_lite.cpp index 7aea787..fed1f9c 100644 --- a/src/gui/kernel/qdesktopwidget_lite.cpp +++ b/src/gui/kernel/qdesktopwidget_lite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/kernel/qgenericplugin_lite.cpp b/src/gui/kernel/qgenericplugin_lite.cpp index 29d7728..6a0fdb6 100644 --- a/src/gui/kernel/qgenericplugin_lite.cpp +++ b/src/gui/kernel/qgenericplugin_lite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/kernel/qgenericplugin_lite.h b/src/gui/kernel/qgenericplugin_lite.h index 2c0ee7a..a468a9f 100644 --- a/src/gui/kernel/qgenericplugin_lite.h +++ b/src/gui/kernel/qgenericplugin_lite.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/kernel/qgenericpluginfactory_lite.cpp b/src/gui/kernel/qgenericpluginfactory_lite.cpp index 4e5b12b..76accbe 100644 --- a/src/gui/kernel/qgenericpluginfactory_lite.cpp +++ b/src/gui/kernel/qgenericpluginfactory_lite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/kernel/qgenericpluginfactory_lite.h b/src/gui/kernel/qgenericpluginfactory_lite.h index 3be4614..86886f1 100644 --- a/src/gui/kernel/qgenericpluginfactory_lite.h +++ b/src/gui/kernel/qgenericpluginfactory_lite.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/kernel/qsound_lite.cpp b/src/gui/kernel/qsound_lite.cpp index 2e2c1e8..a4c74a8 100644 --- a/src/gui/kernel/qsound_lite.cpp +++ b/src/gui/kernel/qsound_lite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index bbc7766..2eba1a1 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/painting/qcolormap_lite.cpp b/src/gui/painting/qcolormap_lite.cpp index b8ae1af..1c1e9cf 100644 --- a/src/gui/painting/qcolormap_lite.cpp +++ b/src/gui/painting/qcolormap_lite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/gui/painting/qpaintdevice_lite.cpp b/src/gui/painting/qpaintdevice_lite.cpp index 2560bf5..0d1ca92 100644 --- a/src/gui/painting/qpaintdevice_lite.cpp +++ b/src/gui/painting/qpaintdevice_lite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/generic/linuxinput/main.cpp b/src/plugins/generic/linuxinput/main.cpp index 21209b8..25e80eb 100644 --- a/src/plugins/generic/linuxinput/main.cpp +++ b/src/plugins/generic/linuxinput/main.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 2ce687d..48084d0 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/generic/linuxinput/qlinuxinput.h b/src/plugins/generic/linuxinput/qlinuxinput.h index 5a90c8f..26ba6a7 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.h +++ b/src/plugins/generic/linuxinput/qlinuxinput.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/linuxfb/main.cpp b/src/plugins/graphicssystems/linuxfb/main.cpp index ef6234d..4d03fe5 100644 --- a/src/plugins/graphicssystems/linuxfb/main.cpp +++ b/src/plugins/graphicssystems/linuxfb/main.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp index cd0ced2..95c636f 100644 --- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp +++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h index 3446008..7ceaf037 100644 --- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h +++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp index bfc2f83..dbe5dd7 100644 --- a/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp +++ b/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtOpenVG module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h b/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h index 763f362..37efcb0 100644 --- a/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h +++ b/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtOpenVG module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/minimal/main.cpp b/src/plugins/graphicssystems/minimal/main.cpp index f7d5eef..2e9d80e 100644 --- a/src/plugins/graphicssystems/minimal/main.cpp +++ b/src/plugins/graphicssystems/minimal/main.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp b/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp index 31023fc..78aff06 100644 --- a/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp +++ b/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h b/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h index b15f6f6..5bf230f 100644 --- a/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h +++ b/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp b/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp index e9d7d69..a87e690 100644 --- a/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp +++ b/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtOpenVG module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h b/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h index 89dc860..c7593e7 100644 --- a/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h +++ b/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtOpenVG module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/openvglite/main.cpp b/src/plugins/graphicssystems/openvglite/main.cpp index 3a73f5c..dc0b4a8 100644 --- a/src/plugins/graphicssystems/openvglite/main.cpp +++ b/src/plugins/graphicssystems/openvglite/main.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp b/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp index cc5b012..41b2303 100644 --- a/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp +++ b/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h b/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h index 74fc41e..512793d 100644 --- a/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h +++ b/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp b/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp index d250a8e..c73e35a 100644 --- a/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp +++ b/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtOpenVG module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h b/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h index c1ae02e..59faba8 100644 --- a/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h +++ b/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtOpenVG module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/testlite/main.cpp b/src/plugins/graphicssystems/testlite/main.cpp index 6271829..28caea7 100644 --- a/src/plugins/graphicssystems/testlite/main.cpp +++ b/src/plugins/graphicssystems/testlite/main.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp index b1948b9..9cb0424 100644 --- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h index cb88ee8..ad7f581 100644 --- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h +++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 6996809..74ccceb 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtOpenVG module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h index 33b55e9..80739b0 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtOpenVG module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index f77356a..c9ca6aa 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtOpenVG module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h index 3d813c0..3d3134f 100644 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtOpenVG module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/vnc/main.cpp b/src/plugins/graphicssystems/vnc/main.cpp index 7deb91a..f10748a 100644 --- a/src/plugins/graphicssystems/vnc/main.cpp +++ b/src/plugins/graphicssystems/vnc/main.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp index 4890e09..9a7c198 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h index d9b4375..375b467 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp index c3677a0..36d8cc6 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/vnc/qvncserver.h b/src/plugins/graphicssystems/vnc/qvncserver.h index e7eb531..ed07ce1 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.h +++ b/src/plugins/graphicssystems/vnc/qvncserver.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the plugins of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp index 9429eb2..07668fb 100644 --- a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp +++ b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtOpenVG module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h index 3a85db3..40428ef 100644 --- a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h +++ b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtOpenVG module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** 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. +** 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. -- cgit v0.12 From 1a8fc08d9cf7ceb9af3fdd48c590f65b2ad2b57b Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 1 Oct 2009 14:32:29 +0200 Subject: Use the same default style as QWS. --- src/gui/kernel/qapplication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index bceffc5..613dbb5 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -1981,7 +1981,7 @@ QString desktopstyle; desktopstyle = QLatin1String("Windows"); // default style for Symbian without S60 #elif defined(Q_WS_X11) && defined(Q_OS_IRIX) desktopstyle = QLatin1String("SGI"); // default style for X11 on IRIX -#elif defined(Q_WS_QWS) +#elif defined(Q_WS_QWS) || defined (Q_WS_LITE) desktopstyle = QLatin1String("Plastique"); // default style for X11 and small devices #elif defined(Q_WS_X11) desktopstyle = QApplicationPrivate::x11_desktop_style(); // default runtime dependant style for X11 -- cgit v0.12 From 13a0b4935900093607f2b3b7688e1452d22770fd Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 5 Oct 2009 13:27:01 +0200 Subject: check for lighthouse when configuring webkit - if so, exclude X11 Reviewed-by: Paul --- src/3rdparty/webkit/WebCore/WebCore.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 540abad..854cf5f 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -20,6 +20,7 @@ TEMPLATE = lib TARGET = QtWebKit contains(QT_CONFIG, embedded):CONFIG += embedded +contains(QT_CONFIG, embedded_lite):CONFIG += embedded CONFIG(QTDIR_build) { GENERATED_SOURCES_DIR = $$PWD/generated -- cgit v0.12 From 1c58e823cec0cea8210a83596b4c43333a5ded0c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 6 Oct 2009 17:33:04 +0200 Subject: Fix isHidden() logic in setParent_sys() -- browser demo works now! --- src/gui/kernel/qwidget_lite.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 2eba1a1..dfcbeaa 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -84,6 +84,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) { Q_Q(QWidget); + QWidget *oldParent = q->parentWidget(); Qt::WindowFlags oldFlags = data.window_flags; if (parent != newparent) { @@ -93,7 +94,14 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) if (!newparent) { f |= Qt::Window; } + + bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); + data.window_flags = f; + q->setAttribute(Qt::WA_WState_Created, false); + q->setAttribute(Qt::WA_WState_Visible, false); + q->setAttribute(Qt::WA_WState_Hidden, false); + if (f & Qt::Window) { //qDebug() << "setParent_sys" << q << newparent << hex << f; if (QWindowSurface *surface = q->windowSurface()) @@ -101,11 +109,16 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) } // XXX Reparenting child to toplevel or vice versa ### if ((f&Qt::Window) && !(oldFlags&Qt::Window)) { - qDebug() << "setParent_sys() change to toplevel"; + //qDebug() << "setParent_sys() change to toplevel"; q->create(); //### this cannot be right } else if ((f&Qt::Window) && !(oldFlags&Qt::Window)) { qDebug() << "######## setParent_sys() change from toplevel not implemented ########"; } + + if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden) + q->setAttribute(Qt::WA_WState_Hidden); + q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); + } QPoint QWidget::mapToGlobal(const QPoint &pos) const -- cgit v0.12 From cd584e3654ab8971aa9868c3375d5f26817396dc Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 6 Oct 2009 17:34:20 +0200 Subject: Remove some debug output. --- .../testlite/qwindowsurface_testlite.cpp | 4 ++-- src/plugins/graphicssystems/testlite/x11util.cpp | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 74ccceb..640e487 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -62,14 +62,14 @@ QTestLiteWindowSurface::QTestLiteWindowSurface xw = new MyWindow(graphicsSystem->xd, 0,0,300,300); xw->windowSurface = this; - qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window; +// qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window; setWindowFlags(window->windowFlags()); //##### This should not be the plugin's responsibility } QTestLiteWindowSurface::~QTestLiteWindowSurface() { - qDebug() << "~QTestLiteWindowSurface" << xw->window; +// qDebug() << "~QTestLiteWindowSurface" << xw->window; delete xw; } diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index c9ca6aa..b443e3e 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -256,7 +256,9 @@ bool MyDisplay::handleEvent(XEvent *xe) #endif default: +#ifdef MYX11_DEBUG qDebug() << "Other X event" << hex << xe->type; +#endif break; } return quit; @@ -286,8 +288,9 @@ MyDisplay::MyDisplay() physicalHeight = DisplayHeightMM(display, screen); int xSocketNumber = XConnectionNumber(display); +#ifdef MYX11_DEBUG qDebug() << "X socket:"<< xSocketNumber; - +#endif QSocketNotifier *sock = new QSocketNotifier(xSocketNumber, QSocketNotifier::Read, this); connect(sock, SIGNAL(activated(int)), this, SLOT(eventDispatcher())); } @@ -313,7 +316,9 @@ void MyDisplay::eventDispatcher() handleEvent(&event); if (event.xany.serial >= marker) { +#ifdef MYX11_DEBUG qDebug() << "potential livelock averted"; +#endif #if 0 if (XEventsQueued(display, QueuedAfterFlush)) { qDebug() << " with events queued"; @@ -332,8 +337,9 @@ MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) xd->windowList.append(this); +#ifdef MYX11_DEBUG qDebug() << "MyWindow::MyWindow"; - +#endif window = XCreateSimpleWindow(xd->display, xd->rootWindow(), x, y, w, h, 0 /*border_width*/, xd->blackPixel(), xd->whitePixel()); @@ -556,8 +562,9 @@ Qt::WindowFlags MyWindow::setWindowFlags(Qt::WindowFlags flags) mwm_hint_atom = XInternAtom(xd->display, "_MOTIF_WM_HINTS\0", False); } +#ifdef MYX11_DEBUG qDebug() << "MyWindow::setWindowFlags" << hex << mwm_hint_atom << "flags" << flags; - +#endif Qt::WindowType type = static_cast(int(flags & Qt::WindowType_Mask)); if (type == Qt::ToolTip) @@ -657,7 +664,9 @@ Qt::WindowFlags MyWindow::setWindowFlags(Qt::WindowFlags flags) //##### only if initializeWindow??? if (popup) { // popup widget +#ifdef MYX11_DEBUG qDebug() << "Doing XChangeWindowAttributes for popup" << wsa.override_redirect; +#endif // set EWMH window types // setNetWmWindowTypes(); @@ -666,9 +675,9 @@ Qt::WindowFlags MyWindow::setWindowFlags(Qt::WindowFlags flags) XChangeWindowAttributes(xd->display, window, CWOverrideRedirect | CWSaveUnder, &wsa); } else { - +#ifdef MYX11_DEBUG qDebug() << "Doing XChangeWindowAttributes for non-popup"; - +#endif } return flags; -- cgit v0.12 From 899eda0138c3899a2c8c5cfaea7d7685d4490475 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 7 Oct 2009 18:43:52 +0200 Subject: Handle closeEvent() --- src/gui/kernel/qapplication_lite.cpp | 9 +++++ src/gui/kernel/qapplication_p.h | 1 + .../testlite/qwindowsurface_testlite.cpp | 7 ++-- .../testlite/qwindowsurface_testlite.h | 2 +- src/plugins/graphicssystems/testlite/x11util.cpp | 39 +++++++++++++++++++--- src/plugins/graphicssystems/testlite/x11util.h | 2 +- 6 files changed, 51 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 384c987..6d4f30b 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -50,6 +50,8 @@ #include "private/qcursor_p.h" #endif +#include "private/qwidget_p.h" + #include "qgenericpluginfactory_lite.h" #include @@ -621,4 +623,11 @@ void QApplicationPrivate::handleGeometryChange(QWidget *tlw, const QRect &newRec QApplication::sendSpontaneousEvent(tlw, &e); } } + + +void QApplicationPrivate::handleCloseEvent(QWidget *tlw) +{ + tlw->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 784ebf6..9cd3f4c 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -581,6 +581,7 @@ public: static void handleMouseEvent(QWidget *tlw, const QMouseEvent &ev); static void handleKeyEvent(QWidget *tlw, QKeyEvent *e); static void handleGeometryChange(QWidget *tlw, const QRect &newRect); + static void handleCloseEvent(QWidget *tlw); #endif #if defined(Q_WS_S60) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 640e487..2ad3224 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -199,9 +199,10 @@ void QTestLiteWindowSurface::handleGeometryChange(int x, int y, int w, int h) } - - - +void QTestLiteWindowSurface::handleCloseEvent() +{ + QApplicationPrivate::handleCloseEvent(window()); +} diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h index 80739b0..7edc448 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h @@ -70,7 +70,7 @@ public: void handleMouseEvent(QEvent::Type, void *); //forwarding X types is apparently impossible :( void handleKeyEvent(QEvent::Type, void *); void handleGeometryChange(int x, int y, int w, int h); - + void handleCloseEvent(); Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); Qt::WindowFlags windowFlags() const; diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index b443e3e..6c8377a 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -60,14 +60,15 @@ #undef ATOM #undef X11 - - - +//#define MYX11_DEBUG static int (*original_x_errhandler)(Display *dpy, XErrorEvent *); static bool seen_badwindow; +static Atom wmProtocolsAtom; +static Atom wmDeleteWindowAtom; + //### copied from qapplication_x11.cpp static int qt_x_errhandler(Display *dpy, XErrorEvent *err) @@ -223,6 +224,22 @@ bool MyDisplay::handleEvent(XEvent *xe) } switch (xe->type) { + + case ClientMessage: + if (xe->xclient.format == 32 && xe->xclient.message_type == wmProtocolsAtom) { + Atom a = xe->xclient.data.l[0]; + if (a == wmDeleteWindowAtom) + xw->closeEvent(); +#ifdef MYX11_DEBUG + qDebug() << "ClientMessage WM_PROTOCOLS" << a; +#endif + } +#ifdef MYX11_DEBUG + else + qDebug() << "ClientMessage" << xe->xclient.format << xe->xclient.message_type; +#endif + break; + case Expose: if (xw) if (xe->xexpose.count == 0) @@ -293,6 +310,10 @@ MyDisplay::MyDisplay() #endif QSocketNotifier *sock = new QSocketNotifier(xSocketNumber, QSocketNotifier::Read, this); connect(sock, SIGNAL(activated(int)), this, SLOT(eventDispatcher())); + + wmProtocolsAtom = XInternAtom (display, "WM_PROTOCOLS", False); + wmDeleteWindowAtom = XInternAtom (display, "WM_DELETE_WINDOW", False); + } @@ -355,6 +376,13 @@ MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | StructureNotifyMask); gc = createGC(); + + XChangeProperty (xd->display, window, + wmProtocolsAtom, + XA_ATOM, 32, PropModeAppend, + (unsigned char *) &wmDeleteWindowAtom, 1); + + } MyWindow::~MyWindow() @@ -376,7 +404,10 @@ GC MyWindow::createGC() return gc; } - +void MyWindow::closeEvent() +{ + windowSurface->handleCloseEvent(); +} void MyWindow::paintEvent() { diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h index 3d3134f..fbd9ef7 100644 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -96,7 +96,7 @@ public: void keyPressEvent(XKeyEvent*); void keyReleaseEvent(XKeyEvent*); - + void closeEvent(); void paintEvent(); void resizeEvent(XConfigureEvent *configure_event); void setSize(int w, int h); -- cgit v0.12 From 281f685524eae4d015e4e9069a38ef7d30fceda1 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 9 Oct 2009 15:28:28 +0200 Subject: Small code cleanup --- src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h index 40428ef..3fd1f12 100644 --- a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h +++ b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h @@ -39,15 +39,14 @@ ** ****************************************************************************/ -#ifndef QWINDOWSURFACE_TESTLITE_H -#define QWINDOWSURFACE_TESTLITE_H +#ifndef QWINDOWSURFACE_VNC_H +#define QWINDOWSURFACE_VNC_H #include #include QT_BEGIN_NAMESPACE -class MyWindow; class QVNCGraphicsSystem; class QVNCGraphicsSystemScreen; @@ -69,7 +68,6 @@ public: private: QVNCGraphicsSystem *mGraphicsSystem; QVNCGraphicsSystemScreen *mScreen; - MyWindow *xw; }; QT_END_NAMESPACE -- cgit v0.12 From 240d918f2ebc3a7dd8b683eabc1f2c1b1b8b2143 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 9 Oct 2009 16:07:34 +0200 Subject: Simple example Lighthouse backend that connects to QVFb This is not fully functional, but should be useful for debugging purposes. Only supports one full-screen window. --- src/plugins/graphicssystems/qvfb/main.cpp | 72 ++++ .../graphicssystems/qvfb/qgraphicssystem_qvfb.cpp | 438 +++++++++++++++++++++ .../graphicssystems/qvfb/qgraphicssystem_qvfb.h | 95 +++++ src/plugins/graphicssystems/qvfb/qvfb.pro | 12 + .../graphicssystems/qvfb/qwindowsurface_qvfb.cpp | 104 +++++ .../graphicssystems/qvfb/qwindowsurface_qvfb.h | 74 ++++ 6 files changed, 795 insertions(+) create mode 100644 src/plugins/graphicssystems/qvfb/main.cpp create mode 100644 src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp create mode 100644 src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.h create mode 100644 src/plugins/graphicssystems/qvfb/qvfb.pro create mode 100644 src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp create mode 100644 src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.h diff --git a/src/plugins/graphicssystems/qvfb/main.cpp b/src/plugins/graphicssystems/qvfb/main.cpp new file mode 100644 index 0000000..b28dde8 --- /dev/null +++ b/src/plugins/graphicssystems/qvfb/main.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qgraphicssystem_qvfb.h" +#include + +QT_BEGIN_NAMESPACE + +class QVFbGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QVFbGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "QVFb"; + return list; +} + +QGraphicsSystem* QVFbGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "qvfb") + return new QVFbGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(qvfb, QVFbGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp b/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp new file mode 100644 index 0000000..10e4e53 --- /dev/null +++ b/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp @@ -0,0 +1,438 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include // overrides QT_OPEN + +#include +#include + +#include "qgraphicssystem_qvfb.h" +#include "qwindowsurface_qvfb.h" +#include +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + + +class QVFbGraphicsSystemScreenKeyboardHandler : public QObject +{ + Q_OBJECT +public: + QVFbGraphicsSystemScreenKeyboardHandler(); + ~QVFbGraphicsSystemScreenKeyboardHandler(); + +private slots: + void readKeyboardData(); + +private: + int kbdFD; + int kbdIdx; + int kbdBufferLen; + unsigned char *kbdBuffer; + QSocketNotifier *keyNotifier; +}; + +QVFbGraphicsSystemScreenKeyboardHandler::QVFbGraphicsSystemScreenKeyboardHandler() +{ + int displayId = 0; //TODO displayId + const QString keyboardDev = QString::fromLatin1(QT_VFB_KEYBOARD_PIPE) + .arg(displayId); + + + kbdFD = -1; + kbdIdx = 0; + kbdBufferLen = sizeof(QVFbKeyData) * 5; + kbdBuffer = new unsigned char [kbdBufferLen]; + + kbdFD = QT_OPEN(keyboardDev.toLatin1().constData(), O_RDWR | O_NDELAY); + + if (kbdFD == -1) { + perror("QVFbGraphicsSystemScreenKeyboardHandler"); + qWarning("QVFbGraphicsSystemScreenKeyboardHandler: Unable to open device %s", + qPrintable(keyboardDev)); + return; + } + + // Clear pending input + char buf[2]; + while (QT_READ(kbdFD, buf, 1) > 0) { } + + keyNotifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this); + connect(keyNotifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData())); + +} + +QVFbGraphicsSystemScreenKeyboardHandler::~QVFbGraphicsSystemScreenKeyboardHandler() +{ + if (kbdFD >= 0) + QT_CLOSE(kbdFD); + delete [] kbdBuffer; +} + + +void QVFbGraphicsSystemScreenKeyboardHandler::readKeyboardData() +{ + int n; + do { + n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx); + if (n > 0) + kbdIdx += n; + } while (n > 0); + + int idx = 0; + while (kbdIdx - idx >= (int)sizeof(QVFbKeyData)) { + QVFbKeyData *kd = (QVFbKeyData *)(kbdBuffer + idx); + if (kd->unicode == 0 && kd->keycode == 0 && kd->modifiers == 0 && kd->press) { + // magic exit key + qWarning("Instructed to quit by Virtual Keyboard"); + qApp->quit(); + } + + //QWSServer::processKeyEvent(kd->unicode ? kd->unicode : 0xffff, kd->keycode, kd->modifiers, kd->press, kd->repeat); + + QEvent::Type type = kd->press ? QEvent::KeyPress : QEvent::KeyRelease; + + QString text; + if (kd->unicode && kd->unicode != 0xffff) + text += QChar(kd->unicode); + +// qDebug() << "readKeyboardData" << type << hex << kd->keycode << kd->modifiers << text; + + QKeyEvent ke(type, kd->keycode, kd->modifiers, text, kd->repeat, int(text.length())); + QApplicationPrivate::handleKeyEvent(0, &ke); + idx += sizeof(QVFbKeyData); + } + + int surplus = kbdIdx - idx; + for (int i = 0; i < surplus; i++) + kbdBuffer[i] = kbdBuffer[idx+i]; + kbdIdx = surplus; +} + + + + +class QVFbGraphicsSystemScreenMouseHandler : public QObject +{ + Q_OBJECT +public: + QVFbGraphicsSystemScreenMouseHandler(); + ~QVFbGraphicsSystemScreenMouseHandler(); + +private slots: + void readMouseData(); + +private: + int mouseFD; + int mouseIdx; + enum {mouseBufSize = 128}; + uchar mouseBuf[mouseBufSize]; + QSocketNotifier *mouseNotifier; + + int oldButtonState; +}; + +QVFbGraphicsSystemScreenMouseHandler::QVFbGraphicsSystemScreenMouseHandler() +{ + int displayId = 0; //TODO: displayId + QString mouseDev = QString::fromLatin1(QT_VFB_MOUSE_PIPE) + .arg(displayId); + + mouseFD = QT_OPEN(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY); + + if (mouseFD == -1) { + perror("QVFbMouseHandler::QVFbMouseHandler"); + qWarning("QVFbMouseHander: Unable to open device %s", + qPrintable(mouseDev)); + return; + } + + // Clear pending input + char buf[2]; + while (QT_READ(mouseFD, buf, 1) > 0) { } + + mouseIdx = 0; + oldButtonState = 0; + mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this); + connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData())); +} + + +QVFbGraphicsSystemScreenMouseHandler::~QVFbGraphicsSystemScreenMouseHandler() +{ + if (mouseFD >= 0) + QT_CLOSE(mouseFD); +} + +void QVFbGraphicsSystemScreenMouseHandler::readMouseData() +{ + int n; + do { + n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx); + if (n > 0) + mouseIdx += n; + } while (n > 0); + + int idx = 0; + static const int packetsize = sizeof(QPoint) + 2*sizeof(int); + while (mouseIdx-idx >= packetsize) { + uchar *mb = mouseBuf+idx; + QPoint mousePos = *reinterpret_cast(mb); + mb += sizeof(QPoint); + int bstate = *reinterpret_cast(mb); + mb += sizeof(int); + int wheel = *reinterpret_cast(mb); + + int button = bstate ^ oldButtonState; + QEvent::Type type = QEvent::MouseMove; + + if (button) { + type = (button & bstate) ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; + } + QMouseEvent me(type, mousePos, mousePos, + Qt::MouseButton(button), Qt::MouseButtons(bstate), Qt::NoModifier); + QApplicationPrivate::handleMouseEvent(0, me); + +// qDebug() << "readMouseData" << mousePos << button << bstate << oldButtonState << type; + + oldButtonState = bstate; + + idx += packetsize; + } + + int surplus = mouseIdx - idx; + for (int i = 0; i < surplus; i++) + mouseBuf[i] = mouseBuf[idx+i]; + mouseIdx = surplus; + +} + + +class QVFbGraphicsSystemScreenPrivate +{ +public: + QVFbGraphicsSystemScreenPrivate(QVFbGraphicsSystemScreen *) + : shmrgn(0), hdr(0), data(0), mouseHandler(0), keyboardHandler(0) + { + connect(0); //for now we only handle one screen + } + + ~QVFbGraphicsSystemScreenPrivate() { disconnect(); } + void setDirty(const QRect &r); + + bool connect(int displayId); + void disconnect(); + + QImage *screenImage() { return &img; } + QSize screenSize() { return img.size(); } + + int depth() const { return img.depth(); } + QImage::Format format() const { return img.format(); } + +private: + unsigned char *shmrgn; + QVFbHeader *hdr; + uchar *data; + QVFbGraphicsSystemScreenMouseHandler *mouseHandler; + QVFbGraphicsSystemScreenKeyboardHandler *keyboardHandler; + + + QImage img; +}; + + +void QVFbGraphicsSystemScreenPrivate::setDirty(const QRect &r) +{ + hdr->dirty = true; + hdr->update = hdr->update.united(r); +} + + +bool QVFbGraphicsSystemScreenPrivate::connect(int displayId) +{ + + key_t key = ftok(QByteArray(QT_VFB_MOUSE_PIPE).replace("%1", QByteArray::number(displayId)), 'b'); + + if (key == -1) + return false; + + + int shmId = shmget(key, 0, 0); + if (shmId != -1) + shmrgn = (unsigned char *)shmat(shmId, 0, 0); + else + return false; + + if ((long)shmrgn == -1 || shmrgn == 0) { + qDebug("No shmrgn %ld", (long)shmrgn); + return false; + } + + hdr = (QVFbHeader *)shmrgn; + data = shmrgn + hdr->dataoffset; + + int w = hdr->width; + int h = hdr->height; + int d = hdr->depth; + int lstep = hdr->linestep; + + QImage::Format format = QImage::Format_Invalid; + if (d == 32) + format = QImage::Format_ARGB32_Premultiplied; + else if (d == 16) + format = QImage::Format_RGB16; + + + if (format == QImage::Format_Invalid) { + img = QImage(); + return false; + } + + img = QImage(data, w, h, lstep, format); + + qDebug("connected %dx%d %d bpp", w, h, d); + + + mouseHandler = new QVFbGraphicsSystemScreenMouseHandler; + keyboardHandler = new QVFbGraphicsSystemScreenKeyboardHandler; + return true; +} + +void QVFbGraphicsSystemScreenPrivate::disconnect() +{ + if ((long)shmrgn != -1 && shmrgn) { + shmdt((char*)shmrgn); + shmrgn = 0; + } + delete mouseHandler; + mouseHandler = 0; + delete keyboardHandler; + keyboardHandler = 0; +} + + +QVFbGraphicsSystemScreen::QVFbGraphicsSystemScreen() +{ + d_ptr = new QVFbGraphicsSystemScreenPrivate(this); +} + + +QVFbGraphicsSystemScreen::~QVFbGraphicsSystemScreen() +{ + delete d_ptr; +} + +void QVFbGraphicsSystemScreen::setDirty(const QRect &rect) +{ + d_ptr->setDirty(rect); +} + + + +QRect QVFbGraphicsSystemScreen::geometry() const { + return QRect(QPoint(), d_ptr->screenSize()); +} + + +int QVFbGraphicsSystemScreen::depth() const +{ + return d_ptr->depth(); +} + +QImage::Format QVFbGraphicsSystemScreen::format() const +{ + return d_ptr->format(); +} + +QSize QVFbGraphicsSystemScreen::physicalSize() const { + return (d_ptr->screenSize()*254)/720; +} + +#if 0 +int QVFbGraphicsSystemScreen::linestep() const { + return d_ptr->screenImage() ? d_ptr->screenImage()->bytesPerLine() : 0; +} + +uchar *QVFbGraphicsSystemScreen::base() const { + return d_ptr->screenImage() ? d_ptr->screenImage()->bits() : 0; +} +#endif + +QImage *QVFbGraphicsSystemScreen::screenImage() +{ + return d_ptr->screenImage(); +} + +QVFbGraphicsSystem::QVFbGraphicsSystem() +{ + mPrimaryScreen = new QVFbGraphicsSystemScreen(); + + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QVFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QVFbGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + if (widget->windowType() == Qt::Desktop) + return 0; // Don't create an explicit window surface for the destkop. + return new QVFbWindowSurface + (const_cast(this), mPrimaryScreen, widget); +} + +QT_END_NAMESPACE + +#include "qgraphicssystem_qvfb.moc" diff --git a/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.h b/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.h new file mode 100644 index 0000000..b31869c --- /dev/null +++ b/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_QVFB_H +#define QGRAPHICSSYSTEM_QVFB_H + +#include + +QT_BEGIN_NAMESPACE + + +class QVFbGraphicsSystemScreenPrivate; + +class QVFbGraphicsSystemScreen : public QGraphicsSystemScreen +{ +public: + QVFbGraphicsSystemScreen(); + ~QVFbGraphicsSystemScreen(); + + QRect geometry() const; + int depth() const; + QImage::Format format() const; + QSize physicalSize() const; + + QImage *screenImage(); + + void setDirty(const QRect &rect); + +public: + + QVFbGraphicsSystemScreenPrivate *d_ptr; +}; + +class QVFbGraphicsSystemPrivate; + + +class QVFbGraphicsSystem : public QGraphicsSystem +{ +public: + QVFbGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList screens() const { return mScreens; } + +private: + QVFbGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; +}; + + + +QT_END_NAMESPACE + + +#endif diff --git a/src/plugins/graphicssystems/qvfb/qvfb.pro b/src/plugins/graphicssystems/qvfb/qvfb.pro new file mode 100644 index 0000000..b321725 --- /dev/null +++ b/src/plugins/graphicssystems/qvfb/qvfb.pro @@ -0,0 +1,12 @@ +TARGET = qvfbgraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + + + +SOURCES = main.cpp qgraphicssystem_qvfb.cpp qwindowsurface_qvfb.cpp +HEADERS = qgraphicssystem_qvfb.h qwindowsurface_qvfb.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp b/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp new file mode 100644 index 0000000..c49f082 --- /dev/null +++ b/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "qwindowsurface_qvfb.h" +#include "qgraphicssystem_qvfb.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QVFbWindowSurface::QVFbWindowSurface(QVFbGraphicsSystem *graphicsSystem, + QVFbGraphicsSystemScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen) +{ +} + +QVFbWindowSurface::~QVFbWindowSurface() +{ +} + +QPaintDevice *QVFbWindowSurface::paintDevice() +{ + return mScreen->screenImage(); +} + +void QVFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(offset); + + QRect rect = geometry(); + QPoint topLeft = rect.topLeft(); + + mScreen->setDirty(region.boundingRect()); +} + +void QVFbWindowSurface::setGeometry(const QRect &) +{ + +// any size you like as long as it's full-screen... + + QRect rect(mScreen->availableGeometry()); + QApplicationPrivate::handleGeometryChange(this->window(), rect); + + QWindowSurface::setGeometry(rect); +} + +bool QVFbWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QVFbWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QVFbWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.h b/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.h new file mode 100644 index 0000000..1971caa --- /dev/null +++ b/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_QVFB_H +#define QWINDOWSURFACE_QVFB_H + +#include + +QT_BEGIN_NAMESPACE + +class QVFbGraphicsSystem; +class QVFbGraphicsSystemScreen; + +class QVFbWindowSurface : public QWindowSurface +{ +public: + QVFbWindowSurface(QVFbGraphicsSystem *graphicsSystem, + QVFbGraphicsSystemScreen *screen, QWidget *window); + ~QVFbWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + +private: + QVFbGraphicsSystem *mGraphicsSystem; + QVFbGraphicsSystemScreen *mScreen; +}; + +QT_END_NAMESPACE + +#endif -- cgit v0.12 From 976f07cbc50a9875d5a094dfd4f3c2d47cba52b4 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 9 Oct 2009 17:08:29 +0200 Subject: Remove some more debug output --- src/gui/kernel/qapplication_lite.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 6d4f30b..0615073 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -127,7 +127,6 @@ static bool qt_try_modal(QWidget *widget, const QEvent *event) void QApplicationPrivate::enterModal_sys(QWidget *widget) { - qDebug() << ">>>>>>>> enterModal_sys" << app_do_modal << widget; if (!qt_modal_stack) qt_modal_stack = new QWidgetList; qt_modal_stack->insert(0, widget); @@ -136,7 +135,6 @@ void QApplicationPrivate::enterModal_sys(QWidget *widget) void QApplicationPrivate::leaveModal_sys(QWidget *widget ) { - qDebug() << "<<<<<<<<< leaveModal_sys" << app_do_modal << widget; if (qt_modal_stack && qt_modal_stack->removeAll(widget)) { if (qt_modal_stack->isEmpty()) { delete qt_modal_stack; -- cgit v0.12 From 0be3fc435c0ada8d5f93389cdf4c96193f015f8f Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 9 Oct 2009 18:05:48 +0200 Subject: Add support for wheel events --- src/gui/kernel/qapplication_lite.cpp | 40 ++++++++++++++++++++++ src/gui/kernel/qapplication_p.h | 1 + .../testlite/qwindowsurface_testlite.cpp | 17 +++++++++ 3 files changed, 58 insertions(+) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 0615073..f551228 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -575,6 +575,45 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) } +//### there's a lot of duplicated logic here -- refactoring required! + +void QApplicationPrivate::handleWheelEvent(QWidget *tlw, QWheelEvent &ev) +{ +// QPoint localPoint = ev.pos(); + QPoint globalPoint = ev.globalPos(); +// bool trustLocalPoint = !!tlw; //is there something the local point can be local to? + QWidget *mouseWidget = tlw; + + qt_last_x = globalPoint.x(); + qt_last_y = globalPoint.y(); + + QWidget *mouseWindow = tlw; + + // find the tlw if we didn't get it from the plugin + if (!mouseWindow) { + mouseWindow = QApplication::topLevelAt(globalPoint); + } + + if (!mouseWindow) + return; + + if (app_do_modal && !qt_try_modal(mouseWindow, &ev) ) { + qDebug() << "modal blocked wheel event" << mouseWindow; + return; + } + QPoint p = mouseWindow->mapFromGlobal(globalPoint); + QWidget *w = mouseWindow->childAt(p); + if (w) { + mouseWidget = w; + p = mouseWidget->mapFromGlobal(globalPoint); + } + + QWheelEvent e(p, globalPoint, ev.delta(), ev.buttons(), ev.modifiers(), + ev.orientation()); + QApplication::sendSpontaneousEvent(mouseWidget, &e); +} + + // Remember, Qt convention is: keyboard state is state *before* @@ -628,4 +667,5 @@ void QApplicationPrivate::handleCloseEvent(QWidget *tlw) tlw->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent); } + QT_END_NAMESPACE diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 9cd3f4c..32004ba 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -582,6 +582,7 @@ public: static void handleKeyEvent(QWidget *tlw, QKeyEvent *e); static void handleGeometryChange(QWidget *tlw, const QRect &newRect); static void handleCloseEvent(QWidget *tlw); + static void handleWheelEvent(QWidget *tlw, QWheelEvent &e); #endif #if defined(Q_WS_S60) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 2ad3224..c2ad094 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -174,6 +174,23 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) case Button1: button = Qt::LeftButton; break; case Button2: button = Qt::MidButton; break; case Button3: button = Qt::RightButton; break; + case Button4: + case Button5: + case 6: + case 7: { + //mouse wheel + if (type == QEvent::MouseButtonPress) { + //logic borrowed from qapplication_x11.cpp + int delta = 120 * ((e->button == Button4 || e->button == 6) ? 1 : -1); + bool hor = (((e->button == Button4 || e->button == Button5) + && (modifiers & Qt::AltModifier)) + || (e->button == 6 || e->button == 7)); + QWheelEvent we(QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), delta, + buttons, modifiers, hor ? Qt::Horizontal : Qt::Vertical); + QApplicationPrivate::handleWheelEvent(window(),we); + } + return; + } default: break; } } -- cgit v0.12 From 7a078ab4f9abf814766c310ab41575d89bb622ce Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 12 Oct 2009 15:07:49 +0200 Subject: Make tooltips work. --- src/gui/kernel/qwidget_lite.cpp | 2 +- src/plugins/graphicssystems/testlite/x11util.cpp | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index dfcbeaa..1c48e10 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -284,7 +284,7 @@ void QWidgetPrivate::show_sys() surface->setVisible(true); } - if (q->windowType() != Qt::Popup) + if (q->windowType() != Qt::Popup && q->windowType() != Qt::ToolTip && !(q->windowFlags() & Qt::X11BypassWindowManagerHint)) q->activateWindow(); //### } diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index 6c8377a..e4d3e89 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -219,7 +219,7 @@ bool MyDisplay::handleEvent(XEvent *xe) } } if (!xw) { - qWarning() << "Unknown window" << xe->xany.window << "received event" << hex << xe->type; + qWarning() << "Unknown window" << hex << xe->xany.window << "received event" << xe->type; return quit; } @@ -358,13 +358,16 @@ MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) xd->windowList.append(this); -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::MyWindow"; -#endif window = XCreateSimpleWindow(xd->display, xd->rootWindow(), x, y, w, h, 0 /*border_width*/, xd->blackPixel(), xd->whitePixel()); + +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::MyWindow" << hex << window; +#endif + + width = -1; height = -1; xpos = -1; @@ -373,7 +376,8 @@ MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) XSetWindowBackgroundPixmap(xd->display, window, XNone); XSelectInput(xd->display, window, ExposureMask | KeyPressMask | KeyReleaseMask | - ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | StructureNotifyMask); + PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | + StructureNotifyMask); gc = createGC(); @@ -387,6 +391,9 @@ MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) MyWindow::~MyWindow() { +#ifdef MYX11_DEBUG + qDebug() << "~MyWindow" << hex << window; +#endif XFreeGC(xd->display, gc); XDestroyWindow(xd->display, window); -- cgit v0.12 From 09a75f3dd9a005b648111af6373660c0f48e772f Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 12 Oct 2009 15:27:29 +0200 Subject: Implement mouse double clicks for testlite. --- src/plugins/graphicssystems/testlite/x11util.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index e4d3e89..fc442a2 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -44,6 +44,7 @@ #include #include +#include #include "x11util.h" #include "qwindowsurface_testlite.h" @@ -385,8 +386,6 @@ MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) wmProtocolsAtom, XA_ATOM, 32, PropModeAppend, (unsigned char *) &wmDeleteWindowAtom, 1); - - } MyWindow::~MyWindow() @@ -466,7 +465,25 @@ void MyWindow::setGeometry(int x, int y, int w, int h) void MyWindow::mousePressEvent(XButtonEvent *e) { - windowSurface->handleMouseEvent(QEvent::MouseButtonPress, e); + static long prevTime = 0; + static Window prevWindow; + static int prevX = -999; + static int prevY = -999; + + QEvent::Type type = QEvent::MouseButtonPress; + + if (e->window == prevWindow && long(e->time) - prevTime < QApplication::doubleClickInterval() + && qAbs(e->x - prevX) < 5 && qAbs(e->y - prevY) < 5) { + type = QEvent::MouseButtonDblClick; + prevTime = e->time - QApplication::doubleClickInterval(); //no double click next time + } else { + prevTime = e->time; + } + prevWindow = e->window; + prevX = e->x; + prevY = e->y; + + windowSurface->handleMouseEvent(type, e); } void MyWindow::mouseReleaseEvent(XButtonEvent *e) -- cgit v0.12 From 7d27d9732e1f528396b27022720d60d38fe9717a Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 30 Sep 2009 13:57:33 +0200 Subject: Fix auto-test build. Reviewed-by:jesper --- tests/auto/qlistview/tst_qlistview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 499fb0b..d9cab02 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -59,6 +59,8 @@ #include #endif +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= -- cgit v0.12 From ba321e277e392c276c1ff8b32f8fca7d26ed0fbe Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 14 Oct 2009 11:29:18 +0200 Subject: Function keys --- src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index c2ad094..bec0b60 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -475,6 +475,9 @@ static const unsigned int keyTbl[] = { static int lookupCode(unsigned int xkeycode) { + if (xkeycode >= XK_F1 && xkeycode <= XK_F35) + return Qt::Key_F1 + (int(xkeycode) - XK_F1); + const unsigned int *p = keyTbl; while (*p) { if (*p == xkeycode) -- cgit v0.12 From 9a5fce0d7d66e0635678eb129f765b39ea11e600 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 14 Oct 2009 09:29:57 +0200 Subject: Fix some autotest failures and get rid of some compiler warnings --- src/gui/image/qpixmap.cpp | 6 ++++-- src/gui/kernel/qapplication.cpp | 2 +- src/gui/kernel/qapplication_lite.cpp | 20 ++++++++++++++++++++ src/gui/kernel/qwidget.cpp | 15 +++++++++++++-- src/gui/kernel/qwidget_lite.cpp | 3 +++ src/plugins/graphicssystems/testlite/x11util.cpp | 2 ++ tests/auto/qaction/tst_qaction.cpp | 2 +- 7 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 558ae54..21fb23e 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1689,8 +1689,8 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) In addition, on Symbian, the QPixmap class supports conversion to and from CFbsBitmap: the toSymbianCFbsBitmap() function creates - CFbsBitmap equivalent to the QPixmap, based on given mode and returns - a CFbsBitmap object. The fromSymbianCFbsBitmap() function returns a + CFbsBitmap equivalent to the QPixmap, based on given mode and returns + a CFbsBitmap object. The fromSymbianCFbsBitmap() function returns a QPixmap that is equivalent to the given bitmap and given mode. \section1 Pixmap Transformations @@ -1874,6 +1874,8 @@ int QPixmap::defaultDepth() return 32; #elif defined(Q_OS_SYMBIAN) return S60->screenDepth; +#elif defined(Q_WS_LITE) + return 32; //LITE: use graphicssystem (we should do that in general) #endif } diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 613dbb5..77e6ea8 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -757,7 +757,7 @@ void QApplicationPrivate::construct( { initResources(); - graphics_system_name = qgetenv("QT_DEFAULT_GRAPHICS_SYSTEM"); + graphics_system_name = QLatin1String(qgetenv("QT_DEFAULT_GRAPHICS_SYSTEM")); qt_is_gui_used = (qt_appType != QApplication::Tty); process_cmdline(); diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index f551228..8c3f7f5 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -477,9 +477,29 @@ void qt_cleanup() #endif QFont::cleanup(); QColormap::cleanup(); + delete QApplicationPrivate::inputContext; + QApplicationPrivate::inputContext = 0; + + QApplicationPrivate::active_window = 0; //### this should not be necessary } +#ifdef QT3_SUPPORT +void QApplication::setMainWidget(QWidget *mainWidget) +{ + QApplicationPrivate::main_widget = mainWidget; + if (QApplicationPrivate::main_widget && windowIcon().isNull() + && QApplicationPrivate::main_widget->testAttribute(Qt::WA_SetWindowIcon)) + setWindowIcon(QApplicationPrivate::main_widget->windowIcon()); +} +#endif + + +//------------------------------------------------------------ +// +// Callback functions for plugins: +// + /*! \a tlw == 0 means that \a ev is in global coords only diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 3217222..1abbd9f 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1444,7 +1444,7 @@ QWidget::~QWidget() } } -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) //### LITE else if (!internalWinId() && isVisible()) { qApp->d_func()->sendSyntheticEnterLeave(this); #ifdef Q_WS_QWS @@ -2319,7 +2319,10 @@ WId QWidget::effectiveWinId() const return id; QWidget *realParent = nativeParentWidget(); Q_ASSERT(realParent); +#ifndef Q_WS_LITE + //### we really need to implement winId functionality Q_ASSERT(realParent->internalWinId()); +#endif return realParent->internalWinId(); } @@ -4004,6 +4007,9 @@ QWidget *QWidget::window() const */ QWidget *QWidget::nativeParentWidget() const { +#ifdef Q_WS_LITE + return window(); //### we don't have native child widgets yet +#endif QWidget *parent = parentWidget(); while (parent && !parent->internalWinId()) parent = parent->parentWidget(); @@ -10145,6 +10151,11 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8), "QWidget::setAttribute(WidgetAttribute, bool)", "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute"); +#ifdef Q_WS_LITE + //### we don't have native child widgets, and WinId isn't really there yet + if (attribute == Qt::WA_NativeWindow) + return; +#endif #ifdef Q_WS_WIN // ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0 @@ -11454,7 +11465,7 @@ QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction) QWidget *targetWidget = 0; int shortestDistance = INT_MAX; foreach(QWidget *targetCandidate, QApplication::allWidgets()) { - + if (targetCandidate->focusProxy()) //skip if focus proxy set continue; diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 1c48e10..cab8cda 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -78,6 +78,9 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) if ((windowType() == Qt::Popup)) qApp->d_func()->closePopup(this); + //### we don't have proper focus event handling yet + if (this == QApplicationPrivate::active_window) + QApplication::setActiveWindow(0); } void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index fc442a2..41767c9 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -220,7 +220,9 @@ bool MyDisplay::handleEvent(XEvent *xe) } } if (!xw) { +#ifdef MYX11_DEBUG qWarning() << "Unknown window" << hex << xe->xany.window << "received event" << xe->type; +#endif return quit; } diff --git a/tests/auto/qaction/tst_qaction.cpp b/tests/auto/qaction/tst_qaction.cpp index 4aad8ca..1e3b143 100644 --- a/tests/auto/qaction/tst_qaction.cpp +++ b/tests/auto/qaction/tst_qaction.cpp @@ -242,7 +242,7 @@ void tst_QAction::setStandardKeys() QList expected; #if defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) expected << QKeySequence("CTRL+C"); -#elif defined(Q_WS_WIN) || defined(Q_WS_QWS) +#elif defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_LITE) expected << QKeySequence("CTRL+C") << QKeySequence("CTRL+INSERT"); #else expected << QKeySequence("CTRL+C") << QKeySequence("F16") << QKeySequence("CTRL+INSERT"); -- cgit v0.12 From 58073ea549f50b8de46902e45c111473a5c8d9fa Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 14 Oct 2009 13:26:03 +0200 Subject: Repaint when window is resized. Some of this ought to be done in Qt, and should not be the responsibility of the plugin. --- .../testlite/qwindowsurface_testlite.cpp | 20 +++++++++++++++++--- .../testlite/qwindowsurface_testlite.h | 1 + src/plugins/graphicssystems/testlite/x11util.cpp | 3 +++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index bec0b60..087fb1c 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -89,13 +89,26 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const xw->paintEvent(); } -void QTestLiteWindowSurface::setGeometry(const QRect &rect) + +void QTestLiteWindowSurface::geometryChanged(const QRect &rect) { - //qDebug() << "QTestLiteWindowSurface::setGeometry:" << rect << xw->window; QWindowSurface::setGeometry(rect); - if (xw->img.size() != rect.size()) + if (xw->img.size() != rect.size()) { xw->img = QImage(rect.size(), mScreen->format()); + window()->update(); //### this is the wrong place for this... + } + +} + + +void QTestLiteWindowSurface::setGeometry(const QRect &rect) +{ + QRect oldRect = geometry(); + if (rect == oldRect) + return; + + QTestLiteWindowSurface::geometryChanged(rect); //if unchanged ### // xw->setSize(rect.width(), rect.height()); @@ -212,6 +225,7 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) void QTestLiteWindowSurface::handleGeometryChange(int x, int y, int w, int h) { + geometryChanged(QRect(x,y,w,h)); QApplicationPrivate::handleGeometryChange(window(), QRect(x,y,w,h)); } diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h index 7edc448..44a8d57 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h @@ -62,6 +62,7 @@ public: QPaintDevice *paintDevice(); void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); void setGeometry(const QRect &rect); + void geometryChanged(const QRect &rect); bool scroll(const QRegion &area, int dx, int dy); void beginPaint(const QRegion ®ion); diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index 41767c9..d744e28 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -450,6 +450,9 @@ void MyWindow::resizeEvent(XConfigureEvent *e) width = e->width; height = e->height; +#ifdef MYX11_DEBUG + qDebug() << hex << window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height; +#endif windowSurface->handleGeometryChange(xpos, ypos, width, height); } -- cgit v0.12 From 1dcdfda53128e745edc3aaa16e659c273cc77cd7 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 14 Oct 2009 13:56:56 +0200 Subject: Make tooltips work better --- src/plugins/graphicssystems/testlite/x11util.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index d744e28..26076b1 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -640,6 +640,7 @@ Qt::WindowFlags MyWindow::setWindowFlags(Qt::WindowFlags flags) bool tool = (type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer); + bool tooltip = (type == Qt::ToolTip); XSetWindowAttributes wsa; @@ -723,7 +724,7 @@ Qt::WindowFlags MyWindow::setWindowFlags(Qt::WindowFlags flags) //##### only if initializeWindow??? - if (popup) { // popup widget + if (popup || tooltip) { // popup widget #ifdef MYX11_DEBUG qDebug() << "Doing XChangeWindowAttributes for popup" << wsa.override_redirect; #endif -- cgit v0.12 From 7750f3821c7cd526c33bfa09378378da3980a2e6 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 14 Oct 2009 13:45:21 +0200 Subject: basic support for multiple top level windows in the VNC backend This supports a simple stack of windows, with the most recently created sitting on top. --- .../graphicssystems/vnc/qgraphicssystem_vnc.cpp | 28 ++++++++++++++++++- .../graphicssystems/vnc/qgraphicssystem_vnc.h | 7 +++++ .../graphicssystems/vnc/qwindowsurface_vnc.cpp | 32 +++++++++++++++------- .../graphicssystems/vnc/qwindowsurface_vnc.h | 3 ++ 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp index 9a7c198..b50e5b5 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp @@ -45,6 +45,7 @@ #include #include +#include @@ -77,6 +78,23 @@ QVNCDirtyMap *QVNCGraphicsSystemScreen::dirtyMap() void QVNCGraphicsSystemScreen::setDirty(const QRect &rect) { + QPainter compositePainter(mScreenImage); + + // Blank the affected area, just in case there's nothing to display here + // Question - What's the background color? + // Another option would be to push a base level window that is the size of the display + + compositePainter.fillRect(rect, Qt::black); + + for (int i = 0; i < windowStack.length(); i++) { + QRect windowRect = windowStack[i]->geometry(); + QRect intersect = windowRect.intersected(rect); + QRect windowIntersect = intersect.translated(-windowRect.left(), + -windowRect.top()); + compositePainter.drawImage(intersect, windowStack[i]->image(), + windowIntersect); + } + d_ptr->setDirty(rect); } @@ -104,6 +122,14 @@ QWindowSurface *QVNCGraphicsSystem::createWindowSurface(QWidget *widget) const { if (widget->windowType() == Qt::Desktop) return 0; // Don't create an explicit window surface for the destkop. - return new QVNCWindowSurface + QVNCWindowSurface * newSurface = new QVNCWindowSurface (const_cast(this), mPrimaryScreen, widget); + mPrimaryScreen->addWindowSurface(newSurface); + return newSurface; +} + +void QVNCGraphicsSystemScreen::removeWindowSurface(QVNCWindowSurface * surface) +{ + windowStack.removeOne(surface); + setDirty(surface->geometry()); } diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h index 375b467..d593096 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h @@ -43,6 +43,7 @@ #define QGRAPHICSSYSTEM_VNC_H #include +#include "qwindowsurface_vnc.h" QT_BEGIN_NAMESPACE @@ -68,6 +69,9 @@ public: void setDirty(const QRect &rect); + void removeWindowSurface(QVNCWindowSurface * surface); + void addWindowSurface(QVNCWindowSurface * surface) { windowStack.append(surface); } + public: QRect mGeometry; int mDepth; @@ -77,6 +81,8 @@ public: QVNCServer *server; QVNCGraphicsSystemScreenPrivate *d_ptr; +private: + QList windowStack; }; class QVNCGraphicsSystemPrivate; @@ -92,6 +98,7 @@ public: QList screens() const { return mScreens; } + private: QVNCGraphicsSystemScreen *mPrimaryScreen; QList mScreens; diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp index 07668fb..af171f5 100644 --- a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp +++ b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp @@ -53,15 +53,17 @@ QVNCWindowSurface::QVNCWindowSurface(QVNCGraphicsSystem *graphicsSystem, : QWindowSurface(window), mScreen(screen) { + mImage = QImage(window->size(), mScreen->format()); } QVNCWindowSurface::~QVNCWindowSurface() { + mScreen->removeWindowSurface(this); } QPaintDevice *QVNCWindowSurface::paintDevice() { - return mScreen->mScreenImage; + return &mImage; } void QVNCWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) @@ -69,20 +71,30 @@ void QVNCWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi Q_UNUSED(widget); Q_UNUSED(offset); - QRect rect = geometry(); - QPoint topLeft = rect.topLeft(); - - mScreen->setDirty(region.boundingRect()); - // server->flush(region); - + QRect currentGeometry = geometry(); + // If this is a move, redraw the previous location + if (oldGeometry != currentGeometry) { + mScreen->setDirty(oldGeometry); + oldGeometry = currentGeometry; + } + + QRect dirtyClient = region.boundingRect(); + QRect dirtyRegion(currentGeometry.left() + dirtyClient.left(), + currentGeometry.top() + dirtyClient.top(), + dirtyClient.width(), + dirtyClient.height()); + mScreen->setDirty(dirtyRegion); } -void QVNCWindowSurface::setGeometry(const QRect &) +void QVNCWindowSurface::setGeometry(const QRect &rect) { + // store previous geometry for screen update + oldGeometry = geometry(); -// any size you like as long as it's full-screen... + // change the widget's QImage if this is a resize + if (mImage.size() != rect.size()) + mImage = QImage(rect.size(), mScreen->format()); - QRect rect(mScreen->availableGeometry()); QApplicationPrivate::handleGeometryChange(this->window(), rect); QWindowSurface::setGeometry(rect); diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h index 3fd1f12..b9af493 100644 --- a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h +++ b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h @@ -64,10 +64,13 @@ public: void beginPaint(const QRegion ®ion); void endPaint(const QRegion ®ion); + inline const QImage image() { return mImage; } private: QVNCGraphicsSystem *mGraphicsSystem; QVNCGraphicsSystemScreen *mScreen; + QRect oldGeometry; + QImage mImage; }; QT_END_NAMESPACE -- cgit v0.12 From eb9c3bee3cef8660cb2a05012f41f183a64c40de Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 15 Oct 2009 15:31:38 +0200 Subject: Fix popup mouse event delivery and start implementing enter/leave events If a popup has children, make sure to deliver mouse event to the child instead of the window. --- src/gui/kernel/qapplication_lite.cpp | 71 ++++++++++++---------- src/gui/kernel/qapplication_p.h | 2 + .../testlite/qwindowsurface_testlite.cpp | 8 +++ .../testlite/qwindowsurface_testlite.h | 2 + src/plugins/graphicssystems/testlite/x11util.cpp | 42 +++++++++++-- src/plugins/graphicssystems/testlite/x11util.h | 5 +- 6 files changed, 91 insertions(+), 39 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 8c3f7f5..884cfac 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -451,9 +451,6 @@ void qt_init(QApplicationPrivate *priv, int type) } #endif - - qDebug() << pluginList; - init_plugins(pluginList); QColormap::initialize(); @@ -507,6 +504,17 @@ void QApplication::setMainWidget(QWidget *mainWidget) */ + +void QApplicationPrivate::handleEnterEvent(QWidget *tlw) +{ + dispatchEnterLeave(tlw, 0); +} + +void QApplicationPrivate::handleLeaveEvent(QWidget *tlw) +{ + dispatchEnterLeave(0, tlw); +} + void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) { // qDebug() << "handleMouseEvent" << tlw << ev.pos() << hex << ev.buttons(); @@ -516,15 +524,15 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) QPoint localPoint = ev.pos(); QPoint globalPoint = ev.globalPos(); bool trustLocalPoint = !!tlw; //is there something the local point can be local to? - QWidget *mouseWidget = tlw; + QWidget *mouseWindow = tlw; qt_last_x = globalPoint.x(); qt_last_y = globalPoint.y(); if (self->inPopupMode()) { //popup mouse handling is magical... - mouseWidget = qApp->activePopupWidget(); - trustLocalPoint = (mouseWidget == tlw); + mouseWindow = qApp->activePopupWidget(); + trustLocalPoint = (mouseWindow == tlw); //### how should popup mode and implicit mouse grab interact? @@ -532,41 +540,40 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) //even if we're blocked by modality, we should deliver the mouse release event.. //### this code is not completely correct: multiple buttons can be pressed simultaneously if (!(implicit_mouse_grabber && ev.buttons() == Qt::NoButton)) { - //qDebug() << "modal blocked mouse event to" << tlw; + qDebug() << "modal blocked mouse event to" << tlw; return; } - } else { - QWidget *mouseWindow = tlw; + } - // find the tlw if we didn't get it from the plugin - if (!mouseWindow) { - mouseWindow = QApplication::topLevelAt(globalPoint); - } + // find the tlw if we didn't get it from the plugin + if (!mouseWindow) { + mouseWindow = QApplication::topLevelAt(globalPoint); + } - if (!mouseWindow && !implicit_mouse_grabber) - return; //nowhere to send it + if (!mouseWindow && !implicit_mouse_grabber) + return; //nowhere to send it - // which child should have it? - mouseWidget = mouseWindow; - if (mouseWindow) { - QWidget *w = mouseWindow->childAt(ev.pos()); - if (w) { - mouseWidget = w; - } + // which child should have it? + QWidget *mouseWidget = mouseWindow; + if (mouseWindow) { + QWidget *w = mouseWindow->childAt(ev.pos()); + if (w) { + mouseWidget = w; } + } - //handle implicit mouse grab - if (ev.type() == QEvent::MouseButtonPress && !implicit_mouse_grabber) { - implicit_mouse_grabber = mouseWidget; + //handle implicit mouse grab + if (ev.type() == QEvent::MouseButtonPress && !implicit_mouse_grabber) { + implicit_mouse_grabber = mouseWidget; - Q_ASSERT(mouseWindow); - mouseWindow->activateWindow(); //focus - } else if (implicit_mouse_grabber) { - mouseWidget = implicit_mouse_grabber; - mouseWindow = mouseWidget->window(); - trustLocalPoint = (mouseWindow == tlw); - } + Q_ASSERT(mouseWindow); + mouseWindow->activateWindow(); //focus + } else if (implicit_mouse_grabber) { + mouseWidget = implicit_mouse_grabber; + mouseWindow = mouseWidget->window(); + trustLocalPoint = (mouseWindow == tlw); } + Q_ASSERT(mouseWidget); if (trustLocalPoint) { diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 52d0642..a5496d6 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -566,6 +566,8 @@ public: static void handleGeometryChange(QWidget *tlw, const QRect &newRect); static void handleCloseEvent(QWidget *tlw); static void handleWheelEvent(QWidget *tlw, QWheelEvent &e); + static void handleEnterEvent(QWidget *tlw); + static void handleLeaveEvent(QWidget *tlw); #endif #if defined(Q_WS_S60) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 087fb1c..e0b9b9f 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -236,7 +236,15 @@ void QTestLiteWindowSurface::handleCloseEvent() } +void QTestLiteWindowSurface::handleEnterEvent() +{ + QApplicationPrivate::handleEnterEvent(window()); +} +void QTestLiteWindowSurface::handleLeaveEvent() +{ + QApplicationPrivate::handleLeaveEvent(window()); +} //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h index 44a8d57..af57c0b 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h @@ -72,6 +72,8 @@ public: void handleKeyEvent(QEvent::Type, void *); void handleGeometryChange(int x, int y, int w, int h); void handleCloseEvent(); + void handleEnterEvent(); + void handleLeaveEvent(); Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); Qt::WindowFlags windowFlags() const; diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index 26076b1..0c6f3c5 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -252,7 +252,6 @@ bool MyDisplay::handleEvent(XEvent *xe) if (xw) xw->resizeEvent(&xe->xconfigure); break; -#if 1 case ButtonPress: xw->mousePressEvent(&xe->xbutton); @@ -273,11 +272,18 @@ bool MyDisplay::handleEvent(XEvent *xe) case XKeyRelease: xw->keyReleaseEvent(&xe->xkey); break; -#endif + + case EnterNotify: + xw->enterEvent(&xe->xcrossing); + break; + + case LeaveNotify: + xw->leaveEvent(&xe->xcrossing); + break; default: #ifdef MYX11_DEBUG - qDebug() << "Other X event" << hex << xe->type; + qDebug() << hex << xe->xany.window << "Other X event" << xe->type; #endif break; } @@ -285,6 +291,7 @@ bool MyDisplay::handleEvent(XEvent *xe) }; + MyDisplay::MyDisplay() { char *display_name = getenv("DISPLAY"); @@ -379,6 +386,7 @@ MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) XSetWindowBackgroundPixmap(xd->display, window, XNone); XSelectInput(xd->display, window, ExposureMask | KeyPressMask | KeyReleaseMask | + EnterWindowMask | LeaveWindowMask | FocusChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | StructureNotifyMask); @@ -456,18 +464,38 @@ void MyWindow::resizeEvent(XConfigureEvent *e) windowSurface->handleGeometryChange(xpos, ypos, width, height); } - +#if 0 void MyWindow::setSize(int w, int h) { XResizeWindow(xd->display, window, w, h); } +#endif void MyWindow::setGeometry(int x, int y, int w, int h) { +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::setGeometry" << hex << window << dec << x << y << w << h; +#endif XMoveResizeWindow(xd->display, window, x, y, w, h); } +void MyWindow::enterEvent(XCrossingEvent *e) +{ +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::enterEvent" << hex << window; +#endif + windowSurface->handleEnterEvent(); +} + +void MyWindow::leaveEvent(XCrossingEvent *e) +{ +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::enterEvent" << hex << window; +#endif + windowSurface->handleLeaveEvent(); +} + void MyWindow::mousePressEvent(XButtonEvent *e) { static long prevTime = 0; @@ -623,7 +651,7 @@ Qt::WindowFlags MyWindow::setWindowFlags(Qt::WindowFlags flags) } #ifdef MYX11_DEBUG - qDebug() << "MyWindow::setWindowFlags" << hex << mwm_hint_atom << "flags" << flags; + qDebug() << "MyWindow::setWindowFlags" << hex << window << "flags" << flags; #endif Qt::WindowType type = static_cast(int(flags & Qt::WindowType_Mask)); @@ -746,7 +774,9 @@ Qt::WindowFlags MyWindow::setWindowFlags(Qt::WindowFlags flags) void MyWindow::setVisible(bool visible) { -// qDebug() << "MyWindow::setVisible" << visible << hex << window; +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::setVisible" << visible << hex << window; +#endif if (visible) XMapWindow(xd->display, window); else diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h index fbd9ef7..39fc331 100644 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -96,10 +96,13 @@ public: void keyPressEvent(XKeyEvent*); void keyReleaseEvent(XKeyEvent*); + void enterEvent(XCrossingEvent*); + void leaveEvent(XCrossingEvent*); + void closeEvent(); void paintEvent(); void resizeEvent(XConfigureEvent *configure_event); - void setSize(int w, int h); +// void setSize(int w, int h); void setGeometry(int x, int y, int w, int h); GC createGC(); -- cgit v0.12 From 3fc6f2c08d9648afc489175363a335e56b3f6526 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 15 Oct 2009 17:29:02 +0200 Subject: Allow VNC top level widgits to be hidden via QGraphicsSystemScreen::setVisible() --- src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp | 4 ++++ src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp | 8 +++++++- src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp index b50e5b5..52f354a 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp @@ -87,10 +87,14 @@ void QVNCGraphicsSystemScreen::setDirty(const QRect &rect) compositePainter.fillRect(rect, Qt::black); for (int i = 0; i < windowStack.length(); i++) { + if (!windowStack[i]->visible()) + continue; QRect windowRect = windowStack[i]->geometry(); QRect intersect = windowRect.intersected(rect); QRect windowIntersect = intersect.translated(-windowRect.left(), -windowRect.top()); + if (intersect.isNull()) + continue; compositePainter.drawImage(intersect, windowStack[i]->image(), windowIntersect); } diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp index af171f5..a3bce49 100644 --- a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp +++ b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp @@ -51,7 +51,8 @@ QT_BEGIN_NAMESPACE QVNCWindowSurface::QVNCWindowSurface(QVNCGraphicsSystem *graphicsSystem, QVNCGraphicsSystemScreen *screen, QWidget *window) : QWindowSurface(window), - mScreen(screen) + mScreen(screen), + visibleFlag(false) { mImage = QImage(window->size(), mScreen->format()); } @@ -115,4 +116,9 @@ void QVNCWindowSurface::endPaint(const QRegion ®ion) Q_UNUSED(region); } +void QVNCWindowSurface::setVisible(bool visible) +{ + visibleFlag = visible; + mScreen->setDirty(geometry()); +} QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h index b9af493..477fe1b 100644 --- a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h +++ b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h @@ -65,12 +65,14 @@ public: void beginPaint(const QRegion ®ion); void endPaint(const QRegion ®ion); inline const QImage image() { return mImage; } - + void setVisible(bool visible); + bool visible() { return visibleFlag; } private: QVNCGraphicsSystem *mGraphicsSystem; QVNCGraphicsSystemScreen *mScreen; QRect oldGeometry; QImage mImage; + bool visibleFlag; }; QT_END_NAMESPACE -- cgit v0.12 From bfdba4c5099bf57e0ec723b1b054ea8298e27f8e Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 16 Oct 2009 13:33:02 +0200 Subject: Adjustable screen size for VNC --- src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp index 52f354a..a97c594 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp @@ -53,7 +53,16 @@ QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() : mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0) { - mGeometry = QRect(0,0,800, 600); + int w = 800; + int h = 600; + int ew, eh; + const char *str; + if ((str=::getenv("QT_VNC_SIZE")) && sscanf(str,"%dx%d",&ew,&eh)==2) { + w = ew; + h = eh; + } + + mGeometry = QRect(0,0,w, h); mDepth = 32; mFormat = QImage::Format_RGB32; -- cgit v0.12 From d4cbb6936131867073fc026d3c4697af36a0e2d4 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 16 Oct 2009 11:56:23 +0200 Subject: One more fix for popup mouse events If the mouse handler doesn't provide local coordinates, we have to map before finding the child widget --- src/gui/kernel/qapplication_lite.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 884cfac..b3ad06f 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -517,13 +517,12 @@ void QApplicationPrivate::handleLeaveEvent(QWidget *tlw) void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) { -// qDebug() << "handleMouseEvent" << tlw << ev.pos() << hex << ev.buttons(); + // qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons(); static QWidget *implicit_mouse_grabber=0; QPoint localPoint = ev.pos(); QPoint globalPoint = ev.globalPos(); - bool trustLocalPoint = !!tlw; //is there something the local point can be local to? QWidget *mouseWindow = tlw; qt_last_x = globalPoint.x(); @@ -532,8 +531,8 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) if (self->inPopupMode()) { //popup mouse handling is magical... mouseWindow = qApp->activePopupWidget(); - trustLocalPoint = (mouseWindow == tlw); + implicit_mouse_grabber = 0; //### how should popup mode and implicit mouse grab interact? } else if (tlw && app_do_modal && !qt_try_modal(tlw, &ev) ) { @@ -553,10 +552,15 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) if (!mouseWindow && !implicit_mouse_grabber) return; //nowhere to send it + if (mouseWindow && mouseWindow != tlw) { + //we did not get a sensible localPoint from the window system, so let's calculate it + localPoint = mouseWindow->mapFromGlobal(globalPoint); + } + // which child should have it? QWidget *mouseWidget = mouseWindow; if (mouseWindow) { - QWidget *w = mouseWindow->childAt(ev.pos()); + QWidget *w = mouseWindow->childAt(localPoint); if (w) { mouseWidget = w; } @@ -571,20 +575,14 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) } else if (implicit_mouse_grabber) { mouseWidget = implicit_mouse_grabber; mouseWindow = mouseWidget->window(); - trustLocalPoint = (mouseWindow == tlw); + if (mouseWindow != tlw) + localPoint = mouseWindow->mapFromGlobal(globalPoint); } Q_ASSERT(mouseWidget); - if (trustLocalPoint) { - // we have a sensible localPoint, so we prefer that, since the - // window system may know more than we do - localPoint = mouseWidget->mapFrom(tlw, localPoint); - } else { - // we don't want to map a local point from a different toplevel - // and we definitely don't want to map from the null pointer - localPoint = mouseWidget->mapFromGlobal(globalPoint); - } + //localPoint is local to mouseWindow, but it needs to be local to mouseWidget + localPoint = mouseWidget->mapFrom(mouseWindow, localPoint); if (ev.buttons() == Qt::NoButton) { //qDebug() << "resetting mouse grabber"; -- cgit v0.12 From 59cab5edd7db8a8e8d16ebbb89329eafb5147b46 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 16 Oct 2009 16:33:43 +0200 Subject: Implement enter/leave events for Lighthouse --- src/gui/kernel/qapplication.cpp | 6 +++--- src/gui/kernel/qapplication_lite.cpp | 12 +++++++++++- src/gui/kernel/qapplication_p.h | 2 +- src/gui/kernel/qwidget.cpp | 14 +++++++------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 191cdf4..74f2971 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -498,7 +498,7 @@ inline bool QApplicationPrivate::isAlien(QWidget *widget) return false; #if defined(Q_WS_MAC) // Fake alien behavior on the Mac :) return !widget->isWindow() && widget->window()->testAttribute(Qt::WA_DontShowOnScreen); -#elif defined(Q_WS_QWS) +#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) return !widget->isWindow() # ifdef Q_BACKINGSTORE_SUBSURFACES && !(widget->d_func()->maybeTopData() && widget->d_func()->maybeTopData()->windowSurface) @@ -3004,7 +3004,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, return result; } -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) /* This function should only be called when the widget changes visibility, i.e. when the \a widget is shown, hidden or deleted. This function does nothing @@ -3016,7 +3016,7 @@ extern QWidget *qt_button_down; void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget) { #ifndef QT_NO_CURSOR -#ifdef Q_WS_QWS +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) if (!widget || widget->isWindow()) return; #else diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index b3ad06f..0ddcfab 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -72,6 +72,7 @@ extern QWidgetList *qt_modal_stack; // stack of modal widgets int qt_last_x = 0; int qt_last_y = 0; +QPointer qt_last_mouse_receiver = 0; QString QApplicationPrivate::appName() const { @@ -508,11 +509,15 @@ void QApplication::setMainWidget(QWidget *mainWidget) void QApplicationPrivate::handleEnterEvent(QWidget *tlw) { dispatchEnterLeave(tlw, 0); + qt_last_mouse_receiver = tlw; } void QApplicationPrivate::handleLeaveEvent(QWidget *tlw) { - dispatchEnterLeave(0, tlw); + dispatchEnterLeave(0, qt_last_mouse_receiver); + if (!tlw->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen + dispatchEnterLeave(0, tlw); + qt_last_mouse_receiver = 0; } void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) @@ -589,6 +594,11 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) implicit_mouse_grabber = 0; } + if (mouseWidget != qt_last_mouse_receiver) { + dispatchEnterLeave(mouseWidget, qt_last_mouse_receiver); + qt_last_mouse_receiver = mouseWidget; + } + // Remember, we might enter a modal event loop when sending the event, // so think carefully before adding code below this point. diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index a5496d6..2622f1c 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -504,7 +504,7 @@ public: static TUint resolveS60ScanCode(TInt scanCode, TUint keysym); QSet nativeWindows; #endif -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_LITE) void sendSyntheticEnterLeave(QWidget *widget); #endif diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 88d90ee..4d8386b 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1440,13 +1440,13 @@ QWidget::~QWidget() } } -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) //### LITE +#if defined(Q_WS_WIN) || defined(Q_WS_X11) else if (!internalWinId() && isVisible()) { qApp->d_func()->sendSyntheticEnterLeave(this); -#ifdef Q_WS_QWS - } else if (isVisible()) { + } +#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) + else if (isVisible()) { qApp->d_func()->sendSyntheticEnterLeave(this); -#endif } #endif @@ -7200,7 +7200,7 @@ void QWidgetPrivate::hide_helper() // next bit tries to move the focus if the focus widget is now // hidden. if (wasVisible) { -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_LITE) qApp->d_func()->sendSyntheticEnterLeave(q); #endif @@ -7332,7 +7332,7 @@ void QWidget::setVisible(bool visible) d->show_helper(); -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_LITE) qApp->d_func()->sendSyntheticEnterLeave(this); #endif } @@ -7447,7 +7447,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous) widget->d_func()->hide_sys(); } } -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_LITE) qApp->d_func()->sendSyntheticEnterLeave(widget); #endif #ifndef QT_NO_ACCESSIBILITY -- cgit v0.12 From 4a77f349127eca7e5c46ba1eafba20ebb8736ebb Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 19 Oct 2009 13:54:43 +0200 Subject: consolidate repainting of multiple QRects for the VNC display Schedule repainting of the VNC display backing store to allow multiple regions to be repainted in a single go. Requests are scheduled using a 0 timer. --- .../graphicssystems/vnc/qgraphicssystem_vnc.cpp | 61 +++++++++++++++------- .../graphicssystems/vnc/qgraphicssystem_vnc.h | 20 ++++++- 2 files changed, 61 insertions(+), 20 deletions(-) diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp index a97c594..6fe174c 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp @@ -47,7 +47,7 @@ #include #include - +#include QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() @@ -71,12 +71,20 @@ QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() mScreenImage = new QImage(mGeometry.size(), mFormat); d_ptr = new QVNCGraphicsSystemScreenPrivate(this); + + helper = new QVNCGraphicsSystemScreenTimerHelper(this); + repaintTimer = new QTimer(); + repaintTimer->setSingleShot(true); + repaintTimer->setInterval(0); + QObject::connect(repaintTimer, SIGNAL(timeout()), helper, SLOT(fireSlot())); } QVNCGraphicsSystemScreen::~QVNCGraphicsSystemScreen() { delete mScreenImage; + delete repaintTimer; + delete helper; } QVNCDirtyMap *QVNCGraphicsSystemScreen::dirtyMap() @@ -87,28 +95,43 @@ QVNCDirtyMap *QVNCGraphicsSystemScreen::dirtyMap() void QVNCGraphicsSystemScreen::setDirty(const QRect &rect) { + repaintRegion += rect; + if (!repaintTimer->isActive()) { + repaintTimer->start(); + } +} + +void QVNCGraphicsSystemScreen::doRedraw() +{ + if (repaintRegion.isEmpty()) + return; QPainter compositePainter(mScreenImage); - // Blank the affected area, just in case there's nothing to display here - // Question - What's the background color? - // Another option would be to push a base level window that is the size of the display - - compositePainter.fillRect(rect, Qt::black); - - for (int i = 0; i < windowStack.length(); i++) { - if (!windowStack[i]->visible()) - continue; - QRect windowRect = windowStack[i]->geometry(); - QRect intersect = windowRect.intersected(rect); - QRect windowIntersect = intersect.translated(-windowRect.left(), - -windowRect.top()); - if (intersect.isNull()) - continue; - compositePainter.drawImage(intersect, windowStack[i]->image(), - windowIntersect); + QVector rects = repaintRegion.rects(); + + for (int rectIndex = 0; rectIndex < repaintRegion.numRects(); rectIndex++) { + QRect rect = rects[rectIndex]; + // Blank the affected area, just in case there's nothing to display + // Question - What's the background color? + // Another option - a base level window that is the size of the display + compositePainter.fillRect(rect, Qt::black); + for (int i = 0; i < windowStack.length(); i++) { + if (!windowStack[i]->visible()) + continue; + QRect windowRect = windowStack[i]->geometry(); + QRect intersect = windowRect.intersected(rect); + QRect windowIntersect = intersect.translated(-windowRect.left(), + -windowRect.top()); + if (intersect.isNull()) + continue; + compositePainter.drawImage(intersect, windowStack[i]->image(), + windowIntersect); + d_ptr->setDirty(rect); + } + } - d_ptr->setDirty(rect); + repaintRegion = QRegion(); } diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h index d593096..497bd23 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h @@ -50,9 +50,10 @@ QT_BEGIN_NAMESPACE class QVNCServer; class QVNCDirtyMap; - class QVNCGraphicsSystemScreenPrivate; +class QVNCGraphicsSystemScreenTimerHelper; + class QVNCGraphicsSystemScreen : public QGraphicsSystemScreen { public: @@ -83,6 +84,23 @@ public: QVNCGraphicsSystemScreenPrivate *d_ptr; private: QList windowStack; + QRegion repaintRegion; + QTimer * repaintTimer; + QVNCGraphicsSystemScreenTimerHelper * helper; + void doRedraw(); + friend class QVNCGraphicsSystemScreenTimerHelper; +}; + +class QVNCGraphicsSystemScreenTimerHelper : public QObject +{ + Q_OBJECT +public: + QVNCGraphicsSystemScreenTimerHelper(QVNCGraphicsSystemScreen * s) + { screen = s; } +public slots: + void fireSlot() { screen->doRedraw(); } +private: + QVNCGraphicsSystemScreen * screen; }; class QVNCGraphicsSystemPrivate; -- cgit v0.12 From 950dc68999454fa3873a6b5c5a695529d02a57c4 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 19 Oct 2009 13:54:43 +0200 Subject: consolidate repainting of multiple QRects for the VNC display Schedule repainting of the VNC display backing store to allow multiple regions to be repainted in a single go. Requests are scheduled using a 0 timer. --- src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp index 6fe174c..95e6641 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp @@ -126,9 +126,8 @@ void QVNCGraphicsSystemScreen::doRedraw() continue; compositePainter.drawImage(intersect, windowStack[i]->image(), windowIntersect); - d_ptr->setDirty(rect); } - + d_ptr->setDirty(rect); } repaintRegion = QRegion(); -- cgit v0.12 From c0395ffd43858e700e2f9015b892c2e978ee8881 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 22 Oct 2009 16:01:48 +0200 Subject: Simplistic showMaximized/showFullScreen implementation --- src/gui/kernel/qwidget_lite.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index cab8cda..d5e4ac2 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -46,6 +46,7 @@ #include "private/qwidget_p.h" #include "private/qgraphicssystem_p.h" #include "private/qapplication_p.h" +#include "qdesktopwidget.h" QT_BEGIN_NAMESPACE @@ -315,12 +316,21 @@ void QWidgetPrivate::hide_sys() void QWidgetPrivate::setMaxWindowState_helper() { - // XXX + setFullScreenSize_helper(); //### decoration size } void QWidgetPrivate::setFullScreenSize_helper() { - // XXX + Q_Q(QWidget); + + const uint old_state = data.in_set_window_state; + data.in_set_window_state = 1; + + const QRect screen = qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(q)); + q->move(screen.topLeft()); + q->resize(screen.size()); + + data.in_set_window_state = old_state; } static Qt::WindowStates effectiveState(Qt::WindowStates state) -- cgit v0.12 From 67475f1f482cfb90c357f9e6d96592a1a29f8e7c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 22 Oct 2009 16:02:36 +0200 Subject: WinId for toplevel windows. --- src/gui/kernel/qwidget_lite.cpp | 20 ++++++++++++++------ src/gui/painting/qwindowsurface.cpp | 6 ++++++ src/gui/painting/qwindowsurface_p.h | 1 + .../testlite/qwindowsurface_testlite.cpp | 8 ++++++++ .../testlite/qwindowsurface_testlite.h | 1 + 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index d5e4ac2..cbda042 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -58,15 +58,23 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool /*destro Q_UNUSED(initializeWindow); // XXX - Qt::WindowFlags flags = data.window_flags; -#if 1 + if (!(flags & Qt::Window) || q->windowType() == Qt::Desktop) + return; // we only care about real toplevels + QWindowSurface *surface = q->windowSurface(); - if (surface && (flags & Qt::Window)) - data.window_flags = surface->setWindowFlags(data.window_flags); -#endif -// qDebug() << "create_sys" << q; + + if (!surface) + surface = createDefaultWindowSurface(); + + Q_ASSERT(surface); + + data.window_flags = surface->setWindowFlags(data.window_flags); + + setWinId(surface->winId()); + + qDebug() << "create_sys" << q << q->internalWinId(); } void QWidget::destroy(bool destroyWindow, bool destroySubWindows) diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp index 8add040..1b0a2ef 100644 --- a/src/gui/painting/qwindowsurface.cpp +++ b/src/gui/painting/qwindowsurface.cpp @@ -378,6 +378,12 @@ void QWindowSurface::setVisible(bool visible) Q_UNUSED(visible); } + +WId QWindowSurface::winId() const +{ + return WId(0); +} + #endif QT_END_NAMESPACE diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h index a84c461..88cc8ba 100644 --- a/src/gui/painting/qwindowsurface_p.h +++ b/src/gui/painting/qwindowsurface_p.h @@ -93,6 +93,7 @@ public: virtual void setVisible(bool visible); virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); virtual Qt::WindowFlags windowFlags() const; + virtual WId winId() const; #endif bool hasStaticContentsSupport() const; diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index e0b9b9f..b14efb8 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -568,4 +568,12 @@ void QTestLiteWindowSurface::setVisible(bool visible) } +WId QTestLiteWindowSurface::winId() const +{ + if (xw) + return (WId) xw->window; + else + return WId(0); +} + QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h index af57c0b..59db81f 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h @@ -78,6 +78,7 @@ public: Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); Qt::WindowFlags windowFlags() const; void setVisible(bool visible); + WId winId() const; private: QTestLiteGraphicsSystem *mGraphicsSystem; -- cgit v0.12 From 1ac68040623df0ba1feaa96b5056c82e75b2faa9 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 22 Oct 2009 16:12:07 +0200 Subject: Remove debug output --- src/gui/kernel/qwidget_lite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index cbda042..1eb93d3 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -74,7 +74,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool /*destro setWinId(surface->winId()); - qDebug() << "create_sys" << q << q->internalWinId(); +// qDebug() << "create_sys" << q << q->internalWinId(); } void QWidget::destroy(bool destroyWindow, bool destroySubWindows) -- cgit v0.12 From 14832f985044a7b978c68cdbdcc466f32aacb71d Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 30 Oct 2009 16:42:38 +0100 Subject: lighthouse VNC cursor support --- .../graphicssystems/vnc/qgraphicssystem_vnc.cpp | 25 +- .../graphicssystems/vnc/qgraphicssystem_vnc.h | 5 +- src/plugins/graphicssystems/vnc/qvnccursor.cpp | 689 +++++++++++++++++++++ src/plugins/graphicssystems/vnc/qvnccursor.h | 100 +++ src/plugins/graphicssystems/vnc/qvncserver.cpp | 12 +- src/plugins/graphicssystems/vnc/qvncserver.h | 2 + .../graphicssystems/vnc/qwindowsurface_vnc.cpp | 1 + src/plugins/graphicssystems/vnc/vnc.pro | 2 + 8 files changed, 829 insertions(+), 7 deletions(-) create mode 100644 src/plugins/graphicssystems/vnc/qvnccursor.cpp create mode 100644 src/plugins/graphicssystems/vnc/qvnccursor.h diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp index 95e6641..98e994c 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp @@ -49,6 +49,9 @@ #include +#include + +#include "qvnccursor.h" QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() : mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0) @@ -77,6 +80,9 @@ QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() repaintTimer->setSingleShot(true); repaintTimer->setInterval(0); QObject::connect(repaintTimer, SIGNAL(timeout()), helper, SLOT(fireSlot())); + + cursor = new QVNCCursor(d_ptr->vncServer, this); + d_ptr->vncServer->setCursor(cursor); } @@ -103,8 +109,11 @@ void QVNCGraphicsSystemScreen::setDirty(const QRect &rect) void QVNCGraphicsSystemScreen::doRedraw() { + repaintRegion += cursor->dirtyRect(); + if (repaintRegion.isEmpty()) return; + QPainter compositePainter(mScreenImage); QVector rects = repaintRegion.rects(); @@ -127,9 +136,14 @@ void QVNCGraphicsSystemScreen::doRedraw() compositePainter.drawImage(intersect, windowStack[i]->image(), windowIntersect); } - d_ptr->setDirty(rect); } + QRect pointerRect = cursor->drawCursor(compositePainter); + repaintRegion += pointerRect; + rects = repaintRegion.rects(); + for (int i = 0; i < rects.size(); i ++) + d_ptr->setDirty(rects[i]); + repaintRegion = QRegion(); } @@ -141,8 +155,8 @@ QVNCGraphicsSystem::QVNCGraphicsSystem() mPrimaryScreen = new QVNCGraphicsSystemScreen(); - int dw = mPrimaryScreen->geometry().width(); - int dh = mPrimaryScreen->geometry().height(); + //int dw = mPrimaryScreen->geometry().width(); + //int dh = mPrimaryScreen->geometry().height(); mScreens.append(mPrimaryScreen); @@ -168,3 +182,8 @@ void QVNCGraphicsSystemScreen::removeWindowSurface(QVNCWindowSurface * surface) windowStack.removeOne(surface); setDirty(surface->geometry()); } + +void QVNCGraphicsSystemScreen::pointerEvent(QMouseEvent & me) +{ + QApplicationPrivate::handleMouseEvent(0, me); +} diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h index 497bd23..eb48f86 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h @@ -44,6 +44,7 @@ #include #include "qwindowsurface_vnc.h" +#include "qvnccursor.h" QT_BEGIN_NAMESPACE @@ -72,6 +73,7 @@ public: void removeWindowSurface(QVNCWindowSurface * surface); void addWindowSurface(QVNCWindowSurface * surface) { windowStack.append(surface); } + void pointerEvent(QMouseEvent & me); public: QRect mGeometry; @@ -79,7 +81,6 @@ public: QImage::Format mFormat; QSize mPhysicalSize; QImage *mScreenImage; - QVNCServer *server; QVNCGraphicsSystemScreenPrivate *d_ptr; private: @@ -89,6 +90,8 @@ private: QVNCGraphicsSystemScreenTimerHelper * helper; void doRedraw(); friend class QVNCGraphicsSystemScreenTimerHelper; + + QVNCCursor * cursor; }; class QVNCGraphicsSystemScreenTimerHelper : public QObject diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.cpp b/src/plugins/graphicssystems/vnc/qvnccursor.cpp new file mode 100644 index 0000000..111ee3c --- /dev/null +++ b/src/plugins/graphicssystems/vnc/qvnccursor.cpp @@ -0,0 +1,689 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +#include + +#include "qvnccursor.h" +#include "qvncserver.h" +#include "qgraphicssystem_vnc.h" + +QT_BEGIN_NAMESPACE + +QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCGraphicsSystemScreen *scr ) + :useVncCursor(false), currentRect(QRect()), + prevRect(QRect()), server(srvr), screen(scr) +{ + d_ptr = new QVNCCursorPrivate(0, 0, 0, 0, 0, 0); +} + +void QVNCCursor::setCursorMode(bool vnc) +{ + if (vnc == useVncCursor) + return; + if (vnc) { + screen->setDirty(prevRect); + prevRect = QRect(); + sendClientCursor(); + } else { + clearClientCursor(); + } + useVncCursor = vnc; +} + +void QVNCCursor::setCursor(Qt::CursorShape shape) +{ + d_ptr->set(shape); + if (useVncCursor) { + sendClientCursor(); + } +} + +void QVNCCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) +{ + d_ptr->set(data, mask, width, height, hotX, hotY); + if (useVncCursor) { + sendClientCursor(); + } +} + +QRect QVNCCursor::dirtyRect() +{ + if (!useVncCursor) { + QRect rect = prevRect; + prevRect = QRect(); + return rect; + } + return QRect(); +} + +QRect QVNCCursor::drawCursor(QPainter & painter) +{ + if (useVncCursor) + return QRect(); + + if (currentRect.isNull()) + return QRect(); + + prevRect = currentRect; + painter.drawImage(prevRect, *d_ptr->image()); + return prevRect; +} + +void QVNCCursor::pointerEvent(QMouseEvent & e) +{ + QWidget *widget = QApplication::widgetAt(e.pos()); + + // Determine which cursor to use + if (currentWidget != widget) { + if (widget) { + QCursor widgetCursor = widget->cursor(); + Qt::CursorShape shape = widgetCursor.shape(); + + if (shape == Qt::BitmapCursor) { + // application supplied cursor + const QBitmap * map = widgetCursor.bitmap(); + const QBitmap * mask = widgetCursor.mask(); + QPoint spot = widgetCursor.hotSpot(); + setCursor(map->toImage().bits(), mask->toImage().bits(), map->width(), map->height(), spot.x(), spot.y()); + } else { + // system cursor + setCursor(shape); + } + } else { + // default cursor + setCursor(Qt::ArrowCursor); + } + currentWidget = widget; + } else if (!widget) { + // default cursor + setCursor(Qt::ArrowCursor); + } + if (!useVncCursor) { + currentRect = d_ptr->image()->rect().translated(-d_ptr->hotspot().x(), -d_ptr->hotspot().y()); + currentRect.translate(e.pos()); + screen->setDirty(QRect()); + } + + screen->pointerEvent(e); +} + +void QVNCCursor::clearClientCursor() +{ + QImage *image = d_ptr->image(); + if (image->isNull()) + return; + QTcpSocket *socket = server->clientSocket(); + if (!socket) { + return; + } + // FramebufferUpdate header + { + const quint16 tmp[6] = { htons(0), + htons(1), + htons(0), htons(0), + htons(0), + htons(0) }; + socket->write((char*)tmp, sizeof(tmp)); + + const quint32 encoding = htonl(-239); + socket->write((char*)(&encoding), sizeof(encoding)); + } +} + +void QVNCCursor::sendClientCursor() +{ + QImage *image = d_ptr->image(); + if (image->isNull()) + return; + QTcpSocket *socket = server->clientSocket(); + if (!socket) { + return; + } + // FramebufferUpdate header + { + const quint16 tmp[6] = { htons(0), + htons(1), + htons(d_ptr->hotspot().x()), htons(d_ptr->hotspot().y()), + htons(image->width()), + htons(image->height()) }; + socket->write((char*)tmp, sizeof(tmp)); + + const quint32 encoding = htonl(-239); + socket->write((char*)(&encoding), sizeof(encoding)); + } + + // write pixels + //Q_ASSERT(cursor->hasAlphaChannel()); + const QImage img = image->convertToFormat(QImage::Format_RGB32); + const int n = server->clientBytesPerPixel() * img.width(); + char *buffer = new char[n]; + for (int i = 0; i < img.height(); ++i) { + server->convertPixels(buffer, (const char*)img.scanLine(i), img.width()); + socket->write(buffer, n); + } + delete[] buffer; + + // write mask + const QImage bitmap = image->createAlphaMask().convertToFormat(QImage::Format_Mono); + Q_ASSERT(bitmap.depth() == 1); + Q_ASSERT(bitmap.size() == img.size()); + const int width = (bitmap.width() + 7) / 8; + for (int i = 0; i < bitmap.height(); ++i) + socket->write((const char*)bitmap.scanLine(i), width); +} + +// End of display and pointer event handling code +// Beginning of built-in cursor graphics +// from src/gui/embedded/QVNCCursorPrivate_qws.cpp + +static QVNCCursorPrivate *systemCursorTable[Qt::LastCursor+1]; +static bool systemCursorTableInit = false; + +// 16 x 16 +static const uchar cur_arrow_bits[] = { + 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08, + 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22, + 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 }; +static const uchar mcur_arrow_bits[] = { + 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f, + 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e, + 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 }; + +static const unsigned char cur_up_arrow_bits[] = { + 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, + 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01}; +static const unsigned char mcur_up_arrow_bits[] = { + 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07, + 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01}; + +static const unsigned char cur_cross_bits[] = { + 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00}; +static const unsigned char mcur_cross_bits[] = { + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; + +static const uchar cur_ibeam_bits[] = { + 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, + 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, + 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_ibeam_bits[] = { + 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 }; + +static const uchar cur_ver_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, + 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, + 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; +static const uchar mcur_ver_bits[] = { + 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, + 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, + 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; + +static const uchar cur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, + 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, + 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, + 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; +static const uchar cur_bdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, + 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, + 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_bdiag_bits[] = { + 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, + 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, + 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; +static const uchar cur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, + 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, + 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, + 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, + 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; +static const uchar cur_blank_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +// 20 x 20 +static const uchar forbidden_bits[] = { + 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, + 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, + 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, + 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; + +static const uchar forbiddenm_bits[] = { + 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, + 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, + 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, + 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; + +// 32 x 32 +static const uchar wait_data_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00, + 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, + 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00, + 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, + 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00, + 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar wait_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, + 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00, + 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar hsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, + 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar hsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, + 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, + 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, + 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar vsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar vsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar phand_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, + 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00, + 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, + 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar phandm_bits[] = { + 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, + 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, + 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, + 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, + 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar size_all_data_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00, + 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar size_all_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00, + 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01, + 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00, + 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar whatsthis_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, + 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, + 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, + 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, + 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, + 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; +static const uchar whatsthism_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, + 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, + 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, + 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, + 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, + 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + +static const uchar busy_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, + 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, + 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, + 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, + 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static const uchar busym_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, + 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, + 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, + 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, + 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +// 16 x 16 +static const uchar openhand_bits[] = { + 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, + 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, + 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; +static const uchar openhandm_bits[] = { + 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, + 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, + 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; +static const uchar closedhand_bits[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, + 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, + 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; +static const uchar closedhandm_bits[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, + 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, + 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; + +void QVNCCursorPrivate::createSystemCursor(int id) +{ + if (!systemCursorTableInit) { + for (int i = 0; i <= Qt::LastCursor; i++) + systemCursorTable[i] = 0; + systemCursorTableInit = true; + } + switch (id) { + // 16x16 cursors + case Qt::ArrowCursor: + systemCursorTable[Qt::ArrowCursor] = + new QVNCCursorPrivate(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0); + break; + + case Qt::UpArrowCursor: + systemCursorTable[Qt::UpArrowCursor] = + new QVNCCursorPrivate(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0); + break; + + case Qt::CrossCursor: + systemCursorTable[Qt::CrossCursor] = + new QVNCCursorPrivate(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7); + break; + + case Qt::IBeamCursor: + systemCursorTable[Qt::IBeamCursor] = + new QVNCCursorPrivate(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7); + break; + + case Qt::SizeVerCursor: + systemCursorTable[Qt::SizeVerCursor] = + new QVNCCursorPrivate(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7); + break; + + case Qt::SizeHorCursor: + systemCursorTable[Qt::SizeHorCursor] = + new QVNCCursorPrivate(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7); + break; + + case Qt::SizeBDiagCursor: + systemCursorTable[Qt::SizeBDiagCursor] = + new QVNCCursorPrivate(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7); + break; + + case Qt::SizeFDiagCursor: + systemCursorTable[Qt::SizeFDiagCursor] = + new QVNCCursorPrivate(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7); + break; + + case Qt::BlankCursor: + systemCursorTable[Qt::BlankCursor] = + new QVNCCursorPrivate(0, 0, 0, 0, 0, 0); + break; + + // 20x20 cursors + case Qt::ForbiddenCursor: + systemCursorTable[Qt::ForbiddenCursor] = + new QVNCCursorPrivate(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10); + break; + + // 32x32 cursors + case Qt::WaitCursor: + systemCursorTable[Qt::WaitCursor] = + new QVNCCursorPrivate(wait_data_bits, wait_mask_bits, 32, 32, 15, 15); + break; + + case Qt::SplitVCursor: + systemCursorTable[Qt::SplitVCursor] = + new QVNCCursorPrivate(vsplit_bits, vsplitm_bits, 32, 32, 15, 15); + break; + + case Qt::SplitHCursor: + systemCursorTable[Qt::SplitHCursor] = + new QVNCCursorPrivate(hsplit_bits, hsplitm_bits, 32, 32, 15, 15); + break; + + case Qt::SizeAllCursor: + systemCursorTable[Qt::SizeAllCursor] = + new QVNCCursorPrivate(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15); + break; + + case Qt::PointingHandCursor: + systemCursorTable[Qt::PointingHandCursor] = + new QVNCCursorPrivate(phand_bits, phandm_bits, 32, 32, 0, 0); + break; + + case Qt::WhatsThisCursor: + systemCursorTable[Qt::WhatsThisCursor] = + new QVNCCursorPrivate(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0); + break; + case Qt::BusyCursor: + systemCursorTable[Qt::BusyCursor] = + new QVNCCursorPrivate(busy_bits, busym_bits, 32, 32, 0, 0); + break; + + case Qt::OpenHandCursor: + systemCursorTable[Qt::OpenHandCursor] = + new QVNCCursorPrivate(openhand_bits, openhandm_bits, 16, 16, 8, 8); + break; + case Qt::ClosedHandCursor: + systemCursorTable[Qt::ClosedHandCursor] = + new QVNCCursorPrivate(closedhand_bits, closedhandm_bits, 16, 16, 8, 8); + break; + default: + qWarning("Unknown system cursor %d", id); + } +} + +void QVNCCursorPrivate::set(Qt::CursorShape id) +{ + QVNCCursorPrivate *cursor = 0; + if (id >= 0 && id <= Qt::LastCursor) { + if (!systemCursorTable[id]) + createSystemCursor(id); + cursor = systemCursorTable[id]; + } + + if (cursor == 0) { + if (!systemCursorTable[Qt::ArrowCursor]) + createSystemCursor(Qt::ArrowCursor); + cursor = systemCursorTable[Qt::ArrowCursor]; + } + cursorImage = cursor->cursorImage; + hot = cursor->hot; +} + +void QVNCCursorPrivate::set(const uchar *data, const uchar *mask, + int width, int height, int hx, int hy) +{ + hot.setX(hx); + hot.setY(hy); + + cursorImage = QImage(width,height, QImage::Format_Indexed8); + + if (!width || !height || !data || !mask || cursorImage.isNull()) + return; + + cursorImage.setNumColors(3); + cursorImage.setColor(0, 0xff000000); + cursorImage.setColor(1, 0xffffffff); + cursorImage.setColor(2, 0x00000000); + + int bytesPerLine = (width + 7) / 8; + int p = 0; + int d, m; + + int x = -1, w = 0; + + uchar *cursor_data = cursorImage.bits(); + int bpl = cursorImage.bytesPerLine(); + for (int i = 0; i < height; i++) + { + for (int j = 0; j < bytesPerLine; j++, data++, mask++) + { + for (int b = 0; b < 8 && j*8+b < width; b++) + { + d = *data & (1 << b); + m = *mask & (1 << b); + if (d && m) p = 0; + else if (!d && m) p = 1; + else p = 2; + cursor_data[j*8+b] = p; + + // calc region + if (x < 0 && m) + x = j*8+b; + else if (x >= 0 && !m) { + x = -1; + w = 0; + } + if (m) + w++; + } + } + if (x >= 0) { + x = -1; + w = 0; + } + cursor_data += bpl; + } + +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.h b/src/plugins/graphicssystems/vnc/qvnccursor.h new file mode 100644 index 0000000..1c0ce8a --- /dev/null +++ b/src/plugins/graphicssystems/vnc/qvnccursor.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QVNCCURSOR_H +#define QVNCCURSOR_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QVNCGraphicsSystemScreen; +class QVNCServer; + +// Cursor graphics management +class QVNCCursorPrivate { +public: + QVNCCursorPrivate(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + { set(data, mask, width, height, hotX, hotY); } + QImage * image() { return &cursorImage; } + QPoint hotspot() { return hot; } + QImage cursorImage; + QPoint hot; + void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + void set(Qt::CursorShape); +private: + static void createSystemCursor(int id); +}; + +class QVNCCursor { +public: + QVNCCursor(QVNCServer *, QVNCGraphicsSystemScreen *); + + // input methods + void setCursorMode(bool vnc); + void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + void setCursor(Qt::CursorShape shape); + void pointerEvent(QMouseEvent & event); + + // output methods + QRect drawCursor(QPainter &); + QRect dirtyRect(); + + // VNC client communication + void sendClientCursor(); + void clearClientCursor(); +private: + bool useVncCursor; // VNC or local + + QRect currentRect; // next place to draw the cursor + QRect prevRect; // last place the cursor was drawn + + QVNCServer * server; // VNC server to get events from + QVNCGraphicsSystemScreen * screen; // Where to request an update + QWidget * currentWidget; // widget currently under the cursor + + QVNCCursorPrivate * d_ptr; +}; + +QT_END_NAMESPACE + +#endif // QVNCCURSOR_H diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp index 36d8cc6..ad20eec 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -349,13 +349,13 @@ bool QRfbClientCutText::read(QTcpSocket *s) //=========================================================================== QVNCServer::QVNCServer(QVNCGraphicsSystemScreen *screen) - : qvnc_screen(screen) + : qvnc_screen(screen), cursor(0) { init(5900); } QVNCServer::QVNCServer(QVNCGraphicsSystemScreen *screen, int id) - : qvnc_screen(screen) + : qvnc_screen(screen), cursor(0) { init(5900 + id); } @@ -679,6 +679,7 @@ void QVNCServer::setEncodings() DesktopSize = -223 }; + supportCursor = false; if (encodingsPending && (unsigned)client->bytesAvailable() >= encodingsPending * sizeof(quint32)) { for (int i = 0; i < encodingsPending; ++i) { @@ -782,6 +783,8 @@ void QVNCServer::setEncodings() qDebug("QVNCServer::setEncodings: fallback using raw"); #endif } + if (cursor) + cursor->setCursorMode(supportCursor); } void QVNCServer::frameBufferUpdateRequest() @@ -830,7 +833,10 @@ void QVNCServer::pointerEvent() if (buttonChange(buttons, ev.buttons, &button, &isPress)) type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; QMouseEvent me(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); - QApplicationPrivate::handleMouseEvent(0, me); + if (cursor) + cursor->pointerEvent(me); + else + QApplicationPrivate::handleMouseEvent(0, me); buttons = ev.buttons; handleMsg = false; } diff --git a/src/plugins/graphicssystems/vnc/qvncserver.h b/src/plugins/graphicssystems/vnc/qvncserver.h index ed07ce1..351c094 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.h +++ b/src/plugins/graphicssystems/vnc/qvncserver.h @@ -466,6 +466,7 @@ public: inline bool hasClientCursor() const { return qvnc_cursor != 0; } #endif + void setCursor(QVNCCursor *c) { cursor = c; } private: void setPixelFormat(); void setEncodings(); @@ -516,6 +517,7 @@ private: #endif QRfbEncoder *encoder; + QVNCCursor * cursor; }; diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp index a3bce49..24ae846 100644 --- a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp +++ b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp @@ -54,6 +54,7 @@ QVNCWindowSurface::QVNCWindowSurface(QVNCGraphicsSystem *graphicsSystem, mScreen(screen), visibleFlag(false) { + Q_UNUSED(graphicsSystem); mImage = QImage(window->size(), mScreen->format()); } diff --git a/src/plugins/graphicssystems/vnc/vnc.pro b/src/plugins/graphicssystems/vnc/vnc.pro index 20e48ad..69cd1f7 100644 --- a/src/plugins/graphicssystems/vnc/vnc.pro +++ b/src/plugins/graphicssystems/vnc/vnc.pro @@ -11,6 +11,8 @@ HEADERS = qgraphicssystem_vnc.h qwindowsurface_vnc.h HEADERS += qvncserver.h SOURCES += qvncserver.cpp +HEADERS += qvnccursor.h +SOURCES += qvnccursor.cpp target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems INSTALLS += target -- cgit v0.12 From 2f76e87dba10d001ae7c3e445ef2fade9a255c2b Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 30 Oct 2009 10:31:34 -0700 Subject: Make QGraphicsSystemScreen a QObject This has several advantages: We already see the various screen drivers making QObject-based helper classes for timers, socketNotifiers etc Also, this gives us more introspection from applications that now can query things from the screen. Reviewed-by: TrustMe --- src/gui/painting/qgraphicssystem.cpp | 4 ++++ src/gui/painting/qgraphicssystem_p.h | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp index 777b93d..1565c45 100644 --- a/src/gui/painting/qgraphicssystem.cpp +++ b/src/gui/painting/qgraphicssystem.cpp @@ -89,6 +89,10 @@ QList QGraphicsSystem::screens() const return QList(); } +QGraphicsSystemScreen::QGraphicsSystemScreen(QObject *parent) + : QObject(parent) +{} + QGraphicsSystemScreen::~QGraphicsSystemScreen() { } diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index ea1031f..a2d03f0 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -60,9 +60,11 @@ QT_BEGIN_NAMESPACE class QPixmapFilter; -class Q_GUI_EXPORT QGraphicsSystemScreen +class Q_GUI_EXPORT QGraphicsSystemScreen : public QObject { + Q_OBJECT public: + QGraphicsSystemScreen(QObject *parent = 0); virtual ~QGraphicsSystemScreen(); virtual QRect geometry() const = 0; -- cgit v0.12 From a69dce80169686ae156ec5e1898ab33676f3eb40 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 2 Nov 2009 13:07:18 +0100 Subject: Use correct keycode for Ctrl+ --- .../graphicssystems/testlite/qwindowsurface_testlite.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index b14efb8..9e24f55 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -521,20 +521,22 @@ void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) int count = XLookupString(e, chars.data(), chars.size(), &keySym, 0); -// qDebug() << "QTLWS::handleKeyEvent" << count << hex << "XKeysym:" << keySym; -// if (count) -// qDebug() << hex << int(chars[0]) << "String:" << chars; +// qDebug() << "QTLWS::handleKeyEvent" << count << hex << "XKeysym:" << keySym; +// if (count) +// qDebug() << hex << int(chars[0]) << "String:" << chars; Qt::KeyboardModifiers modifiers = translateModifiers(e->state); int qtcode = lookupCode(keySym); -// qDebug() << "lookup: " << hex << keySym << qtcode; +// qDebug() << "lookup: " << hex << keySym << qtcode << "mod" << modifiers; if (qtcode) { QKeyEvent keyEvent(type, qtcode, modifiers); QApplicationPrivate::handleKeyEvent(window(), &keyEvent); } else if (chars[0]) { int qtcode = chars.toUpper()[0]; //Not exactly right... + if (modifiers & Qt::ControlModifier && qtcode < ' ') + qtcode = chars[0] + '@'; QKeyEvent keyEvent(type, qtcode, modifiers, QString::fromLatin1(chars)); QApplicationPrivate::handleKeyEvent(window(), &keyEvent); } else { -- cgit v0.12 From 505f9cb67a79ccfbd6b9216cf4ad66521fc5d990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 2 Nov 2009 14:56:59 +0100 Subject: initial commit of minimaldfb --- src/plugins/graphicssystems/minimaldfb/main.cpp | 71 ++++++++ .../graphicssystems/minimaldfb/minimaldfb.pro | 13 ++ .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 183 +++++++++++++++++++++ .../minimaldfb/qgraphicssystem_minimaldfb.h | 93 +++++++++++ .../minimaldfb/qwindowsurface_minimaldfb.cpp | 150 +++++++++++++++++ .../minimaldfb/qwindowsurface_minimaldfb.h | 80 +++++++++ 6 files changed, 590 insertions(+) create mode 100644 src/plugins/graphicssystems/minimaldfb/main.cpp create mode 100644 src/plugins/graphicssystems/minimaldfb/minimaldfb.pro create mode 100644 src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp create mode 100644 src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h create mode 100644 src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp create mode 100644 src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h diff --git a/src/plugins/graphicssystems/minimaldfb/main.cpp b/src/plugins/graphicssystems/minimaldfb/main.cpp new file mode 100644 index 0000000..fe9407c --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qgraphicssystem_minimaldfb.h" + +QT_BEGIN_NAMESPACE + +class QDirectFbGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QDirectFbGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "MinimalDfb"; + return list; +} + +QGraphicsSystem* QDirectFbGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "minimaldfb") + return new QDirectFbGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(directfb, QDirectFbGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro new file mode 100644 index 0000000..a3b7f5c --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro @@ -0,0 +1,13 @@ +TARGET = qdirectfbgraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +QMAKE_CXXFLAGS += -I/usr/include/directfb +LIBS += -ldirectfb -lfusion -ldirect -lpthread + +SOURCES = main.cpp qgraphicssystem_minimaldfb.cpp qwindowsurface_minimaldfb.cpp +HEADERS = qgraphicssystem_minimaldfb.h qwindowsurface_minimaldfb.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp new file mode 100644 index 0000000..7c06748 --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicssystem_minimaldfb.h" +#include "qwindowsurface_minimaldfb.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int display) +{ + DFBResult result = dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &m_layer); + if (result != DFB_OK) { + DirectFBError("QDirectFbGraphicsSystemScreen::connect: " + "Unable to get primary display layer!", result); + } + + IDirectFBSurface *topLevelSurface; + m_layer->GetSurface(m_layer, &topLevelSurface); + m_format = QDirectFbGraphicsSystem::imageFormatFromSurface(topLevelSurface); + + result = m_layer->GetScreen(m_layer,&m_screen); + if (result != DFB_OK) { + DirectFBError("QDirectFbGraphicsSystemScreen: Failed to get screen", result); + } + + int w(0),h(0); + m_screen->GetSize(m_screen,&w,&h); + m_geometry = QRect(0,0,w,h); + const int dpi = 72; + const qreal inch = 25.4; + m_depth = 32; + m_physicalSize = QSize(qRound(w * inch / dpi), qRound(h *inch / dpi)); +} + +QDirectFbGraphicsSystemScreen::~QDirectFbGraphicsSystemScreen() +{ +} + +IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect) +{ + IDirectFBWindow *window; + + DFBWindowDescription description; + memset(&description,0,sizeof(DFBWindowDescription)); +// description.flags = DWDESC_SURFACE_CAPS; + description.width = rect.width(); + description.height = rect.height(); + description.posx = rect.x(); + description.posy = rect.y(); +// description.flags |= DWDESC_OPTIONS; +// description.options = DWOP_GHOST|DWOP_ALPHACHANNEL; +// description.caps = (DFBWindowDescription) (DWCAPS_NODECORATION|DWCAPS_DOUBLEBUFFER); +// description.surface_caps = DSCAPS_PREMULTIPLIED; + + DFBResult result = m_layer->CreateWindow(m_layer,&description,&window); + if (result != DFB_OK) { + DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); + } + return window; +} + +QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() +{ + DFBResult result = DFB_OK; + + { // pass command line arguments to DirectFB + const QStringList args = QCoreApplication::arguments(); + int argc = args.size(); + char **argv = new char*[argc]; + + for (int i = 0; i < argc; ++i) + argv[i] = qstrdup(args.at(i).toLocal8Bit().constData()); + + result = DirectFBInit(&argc, &argv); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen: error initializing DirectFB", + result); + } + delete[] argv; + } + + result = DirectFBCreate(&dfb); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen: error creating DirectFB interface", + result); + } + + mPrimaryScreen = new QDirectFbGraphicsSystemScreen(dfb,0); + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QDirectFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QDirectFbGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + return new QDirectFbWindowSurface (mPrimaryScreen, widget); +} + +QImage::Format QDirectFbGraphicsSystem::imageFormatFromSurface(IDirectFBSurface *surface) +{ + DFBSurfacePixelFormat format; + surface->GetPixelFormat(surface, &format); + + switch (format) { + case DSPF_LUT8: + return QImage::Format_Indexed8; + case DSPF_RGB24: + return QImage::Format_RGB888; + case DSPF_ARGB4444: + return QImage::Format_ARGB4444_Premultiplied; + case DSPF_RGB444: + return QImage::Format_RGB444; + case DSPF_RGB555: + case DSPF_ARGB1555: + return QImage::Format_RGB555; + case DSPF_RGB16: + return QImage::Format_RGB16; + case DSPF_ARGB6666: + return QImage::Format_ARGB6666_Premultiplied; + case DSPF_RGB18: + return QImage::Format_RGB666; + case DSPF_RGB32: + return QImage::Format_RGB32; + case DSPF_ARGB: { + DFBSurfaceCapabilities caps; + const DFBResult result = surface->GetCapabilities(surface, &caps); + Q_ASSERT(result == DFB_OK); + Q_UNUSED(result); + return (caps & DSCAPS_PREMULTIPLIED + ? QImage::Format_ARGB32_Premultiplied + : QImage::Format_ARGB32); } + default: + break; + } + return QImage::Format_Invalid; + +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h new file mode 100644 index 0000000..fbc5498 --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_MINIMAL_H +#define QGRAPHICSSYSTEM_MINIMAL_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QDirectFbGraphicsSystemScreen : public QGraphicsSystemScreen +{ +public: + QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int display); + ~QDirectFbGraphicsSystemScreen(); + + 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; } + + IDirectFBWindow *createWindow(const QRect &); + +public: + QRect m_geometry; + int m_depth; + QImage::Format m_format; + QSize m_physicalSize; + + IDirectFBScreen *m_screen; + IDirectFBDisplayLayer *m_layer; +}; + +class QDirectFbGraphicsSystem : public QGraphicsSystem +{ +public: + QDirectFbGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList screens() const { return mScreens; } + + static QImage::Format imageFormatFromSurface(IDirectFBSurface *surface); + +private: + IDirectFB *dfb; + QDirectFbGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp new file mode 100644 index 0000000..76fad68 --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsurface_minimaldfb.h" +#include "qgraphicssystem_minimaldfb.h" +#include + +QT_BEGIN_NAMESPACE + +QDirectFbWindowSurface::QDirectFbWindowSurface + (QDirectFbGraphicsSystemScreen *screen, QWidget *window) + : QWindowSurface(window), m_screen(screen), m_lock(false) +{ + window->setWindowSurface(this); + m_dfbWindow = m_screen->createWindow(window->rect()); + DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); + if (result != DFB_OK) { + DirectFBError("QDirectFbWindowSurface::QDirectFbWindowSurface: unable to get windows surface",result); + } + + + +} + +QDirectFbWindowSurface::~QDirectFbWindowSurface() +{ +} + +QPaintDevice *QDirectFbWindowSurface::paintDevice() +{ + return m_image; +} + +void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(offset); + + const quint8 windowOpacity = quint8(widget->windowOpacity() * 0xff); + m_dfbWindow->SetOpacity(m_dfbWindow,windowOpacity); + + QVector rects = region.rects(); + for (int i = 0 ; i < rects.size(); i++) { + const QRect rect = rects.at(i); + DFBRegion dfbReg = { rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()}; + m_dfbSurface->Flip(m_dfbSurface,&dfbReg,DSFLIP_BLIT); + } +} + +void QDirectFbWindowSurface::setGeometry(const QRect &rect) +{ +// qDebug() << "QDirectF.bWindowSurface::setGeometry:" << (long)this << rect; + bool wasLocked = false; + if (m_lock){ + m_dfbSurface->Unlock(m_dfbSurface); + wasLocked = true; + } + m_dfbSurface->Release(m_dfbSurface); + QWindowSurface::setGeometry(rect); + m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), + rect.width(), rect.height()); +// m_dfbWindow->Resize(m_dfbWindow,rect.width(),rect.height()); +// m_dfbWindow->MoveTo(m_dfbWindow,rect.x(),rect.y()); + DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); + if (result != DFB_OK) + qDebug() << "could not resurface"; + + if (wasLocked) + lockSurfaceToImage(); +} + +bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QDirectFbWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); + if (!m_lock) + lockSurfaceToImage(); +} + +void QDirectFbWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); + if (m_lock){ + m_dfbSurface->Unlock(m_dfbSurface); + m_lock = false; + } +} + +void QDirectFbWindowSurface::lockSurfaceToImage() +{ + if (m_lock) + return; + m_lock = true; + + int w,h; + m_dfbSurface->GetSize(m_dfbSurface,&w,&h); + uchar *data; + int bpl; + DFBResult result = m_dfbSurface->Lock(m_dfbSurface,static_cast(DSLF_READ|DSLF_WRITE),reinterpret_cast(&data),&bpl); + if (!result == DFB_OK) { + DirectFBError("QDirectFbWindowSurface::lockSurfaceToImage() failed to lock surface",result); + return; + } + QImage::Format format = QDirectFbGraphicsSystem::imageFormatFromSurface(m_dfbSurface); + m_image = new QImage(data,w,h,bpl,format); +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h new file mode 100644 index 0000000..fe88878 --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_MINIMAL_H +#define QWINDOWSURFACE_MINIMAL_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QDirectFbGraphicsSystemScreen; + +class QDirectFbWindowSurface : public QWindowSurface +{ +public: + QDirectFbWindowSurface + (QDirectFbGraphicsSystemScreen *screen, QWidget *window); + ~QDirectFbWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + +private: + void lockSurfaceToImage(); + + QDirectFbGraphicsSystemScreen *m_screen; + QImage *m_image; + bool m_lock; + + IDirectFBWindow *m_dfbWindow; + IDirectFBSurface *m_dfbSurface; +}; + +QT_END_NAMESPACE + +#endif -- cgit v0.12 From f8c70ab13a3f54da54e2c68a2a96ef18916f9178 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 4 Nov 2009 13:46:09 +0100 Subject: Fix autotest screenNumberForPoint on Lighthouse --- src/gui/kernel/qdesktopwidget_lite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qdesktopwidget_lite.cpp b/src/gui/kernel/qdesktopwidget_lite.cpp index fed1f9c..a3535fb 100644 --- a/src/gui/kernel/qdesktopwidget_lite.cpp +++ b/src/gui/kernel/qdesktopwidget_lite.cpp @@ -131,7 +131,7 @@ int QDesktopWidget::screenNumber(const QPoint &p) const if (screens[i]->geometry().contains(p)) return i; - return -1; + return primaryScreen(); //even better would be closest screen } void QDesktopWidget::resizeEvent(QResizeEvent *) -- cgit v0.12 From a43f98dea9024f84223ae8c8c59db1b4e5ead588 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 4 Nov 2009 15:52:03 +0100 Subject: Compile after latest qvfbhdr changes --- src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp b/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp index 10e4e53..77942c9 100644 --- a/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp +++ b/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp @@ -85,8 +85,7 @@ private: QVFbGraphicsSystemScreenKeyboardHandler::QVFbGraphicsSystemScreenKeyboardHandler() { int displayId = 0; //TODO displayId - const QString keyboardDev = QString::fromLatin1(QT_VFB_KEYBOARD_PIPE) - .arg(displayId); + const QString keyboardDev = QT_VFB_KEYBOARD_PIPE(displayId); kbdFD = -1; @@ -185,8 +184,7 @@ private: QVFbGraphicsSystemScreenMouseHandler::QVFbGraphicsSystemScreenMouseHandler() { int displayId = 0; //TODO: displayId - QString mouseDev = QString::fromLatin1(QT_VFB_MOUSE_PIPE) - .arg(displayId); + QString mouseDev = QT_VFB_MOUSE_PIPE(displayId); mouseFD = QT_OPEN(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY); @@ -301,7 +299,7 @@ void QVFbGraphicsSystemScreenPrivate::setDirty(const QRect &r) bool QVFbGraphicsSystemScreenPrivate::connect(int displayId) { - key_t key = ftok(QByteArray(QT_VFB_MOUSE_PIPE).replace("%1", QByteArray::number(displayId)), 'b'); + key_t key = ftok(QT_VFB_MOUSE_PIPE(displayId).toLatin1(), 'b'); if (key == -1) return false; -- cgit v0.12 From 49696780e9cf026b2a7063976eb42f823a6792d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 9 Nov 2009 14:07:50 +0100 Subject: Adding the blitter paint engine --- src/gui/painting/painting.pri | 2 + src/gui/painting/qpaintengine.h | 1 + src/gui/painting/qpaintengine_blitter.cpp | 638 ++++++++++++++++++++++++++++++ src/gui/painting/qpaintengine_blitter_p.h | 94 +++++ src/gui/painting/qpaintengine_raster_p.h | 2 + 5 files changed, 737 insertions(+) create mode 100644 src/gui/painting/qpaintengine_blitter.cpp create mode 100644 src/gui/painting/qpaintengine_blitter_p.h diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 0f63198..4a32e71 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -17,6 +17,7 @@ HEADERS += \ painting/qpaintengine_p.h \ painting/qpaintengine_alpha_p.h \ painting/qpaintengine_preview_p.h \ + painting/qpaintengine_blitter_p.h \ painting/qpaintengineex_p.h \ painting/qpainter.h \ painting/qpainter_p.h \ @@ -63,6 +64,7 @@ SOURCES += \ painting/qpaintengine.cpp \ painting/qpaintengine_alpha.cpp \ painting/qpaintengine_preview.cpp \ + painting/qpaintengine_blitter.cpp \ painting/qpaintengineex.cpp \ painting/qpainter.cpp \ painting/qpainterpath.cpp \ diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h index c540be4..321bbf5 100644 --- a/src/gui/painting/qpaintengine.h +++ b/src/gui/painting/qpaintengine.h @@ -213,6 +213,7 @@ public: OpenVG, OpenGL2, PaintBuffer, + Blitter, User = 50, // first user type id MaxUser = 100 // last user type id diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp new file mode 100644 index 0000000..367a8b5 --- /dev/null +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -0,0 +1,638 @@ +#include "private/qpaintengine_blitter_p.h" +#include "private/qpaintengine_raster_p.h" +#include "private/qpainter_p.h" +#include "private/qapplication_p.h" + +#define STATE_XFORM_SCALE 0x00000001 +#define STATE_XFORM_COMPLEX 0x00000002 + +#define STATE_BRUSH_PATTERN 0x00000010 +#define STATE_BRUSH_ALPHA 0x00000020 + +#define STATE_PEN_ENABLED 0x00000100 + +#define STATE_ANTIALIASING 0x00001000 +#define STATE_ALPHA 0x00002000 +#define STATE_BLENDING_COMPLEX 0x00004000 + +#define STATE_CLIPSYS_COMPLEX 0x00010000 +#define STATE_CLIP_COMPLEX 0x00020000 + +//#define RASTEROVERLAY + +#ifdef RASTEROVERLAY +QColor rasterColor(255,0,0,100); +QBrush rasterBrush(rasterColor); +#endif + +static inline void updateStateBits(uint *state, uint mask, bool on) +{ + *state = on ? (*state | mask) : (*state & ~mask); +} + +class CapabilitiesToStateMask +{ +public: + CapabilitiesToStateMask(QBlittable::Capabilities capabilities) + : m_capabilities(capabilities), + fillRectMask(0), fillRectState(0), + drawRectMask(0), drawRectState(0), + drawPixmapMask(0), drawPixmapState(0) + { + if (capabilities & QBlittable::SolidRectCapability) { + setFillRectMask(); + } + if (capabilities & QBlittable::SourcePixmapCapability) { + setSourcePixmapMask(); + } + if (capabilities & QBlittable::SourceOverPixmapCapability) { + setSourceOverPixmapMask(); + } + } + + inline bool canBlitterFillRect() const + { + return !fillRectState || (fillRectState & fillRectMask); + } + + inline bool canBlitterDrawRectMask() const + { + return drawRectState & drawRectMask; + } + + bool canBlitterDrawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) const + { + if ((!drawPixmapState) || drawPixmapState & drawPixmapMask) { + if (m_capabilities & (QBlittable::SourceOverPixmapCapability + | QBlittable::SourceOverScaledPixmapCapability)) { + if (r.size() != sr.size()) { + return m_capabilities & QBlittable::SourceOverScaledPixmapCapability; + } else { + return m_capabilities & QBlittable::SourceOverPixmapCapability; + } + } + if ((m_capabilities & QBlittable::SourcePixmapCapability) && r.size() == sr.size() && !pm.hasAlphaChannel()) { + return m_capabilities & QBlittable::SourcePixmapCapability; + } + } + return false; + } + + inline void updateFillRectBits(uint mask, bool on) { + updateStateBits(&fillRectState,mask,on); + } + + inline void updateDrawRectBits(uint mask, bool on) { + updateStateBits(&drawRectState,mask,on); + } + + inline void updateDrawPixmapBits(uint mask, bool on) { + updateStateBits(&drawPixmapState,mask,on); + } + inline void updateAllWithBits(uint mask, bool on) { + updateStateBits(&fillRectState,mask,on); + updateStateBits(&drawRectState,mask,on); + updateStateBits(&drawPixmapState,mask,on); + } + +public: + + void setFillRectMask() { + updateStateBits(&fillRectMask, STATE_XFORM_SCALE, false); + updateStateBits(&fillRectMask, STATE_XFORM_COMPLEX, false); + + updateStateBits(&fillRectMask, STATE_BRUSH_PATTERN, false); + updateStateBits(&fillRectMask, STATE_BRUSH_ALPHA, false); + + updateStateBits(&fillRectMask, STATE_PEN_ENABLED, false); + + updateStateBits(&fillRectMask, STATE_ANTIALIASING, false); + updateStateBits(&fillRectMask, STATE_ALPHA, false); + updateStateBits(&fillRectMask, STATE_BLENDING_COMPLEX, false); + + updateStateBits(&fillRectMask, STATE_CLIPSYS_COMPLEX, false); + updateStateBits(&fillRectMask, STATE_CLIP_COMPLEX, false); + } + + void setSourcePixmapMask() { + updateStateBits(&drawPixmapMask, STATE_XFORM_SCALE, true); + updateStateBits(&drawPixmapMask, STATE_XFORM_COMPLEX, false); + + updateStateBits(&drawPixmapMask, STATE_BRUSH_PATTERN, false); + updateStateBits(&drawPixmapMask, STATE_BRUSH_ALPHA, false); + + updateStateBits(&drawPixmapMask, STATE_PEN_ENABLED, false); + + updateStateBits(&drawPixmapMask, STATE_ANTIALIASING, false); + updateStateBits(&drawPixmapMask, STATE_ALPHA, false); + updateStateBits(&drawPixmapMask, STATE_BLENDING_COMPLEX, false); + + updateStateBits(&drawPixmapMask, STATE_CLIPSYS_COMPLEX, false); + updateStateBits(&drawPixmapMask, STATE_CLIP_COMPLEX, false); + } + + void setSourceOverPixmapMask() { + setSourcePixmapMask(); + } + + QBlittable::Capabilities m_capabilities; + uint fillRectMask; + uint fillRectState; + uint drawRectMask; + uint drawRectState; + uint drawPixmapMask; + uint drawPixmapState; +}; + +class QBlitterPaintEnginePrivate : public QPaintEngineExPrivate +{ +public: + QBlitterPaintEnginePrivate(QPaintDevice *p) + : QPaintEngineExPrivate(), + raster(new QRasterPaintEngine(p)), isBlitterLocked(false), + capabillities(0), hasXForm(false) + { + if (QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem()) { +// QBlittable *b = gs->createBlitter(p); +// if (b) { +// blitter=b; +// capabillities = new CapabilitiesToStateMask(blitter->capabilities()); +// blitter->unlock(); +// } else +// qWarning("No blitter returned from the graphics system. QBlitterPaintEngine will not work"); + } + + } + + inline void lock() { + if (!isBlitterLocked) { + raster->d_func()->rasterBuffer->prepare(blitter->lock()); + isBlitterLocked = true; + } + } + + inline void unlock() { + if (isBlitterLocked) { + blitter->unlock(); + isBlitterLocked = false; + } + } + + void fillRect(const QRectF &rect, const QColor &color) { + unlock(); + QRectF targetRect = rect; + if (hasXForm) { + targetRect = state->matrix.mapRect(rect); + } + QClipData *clipData = raster->state()->clip; + if (clipData) { + if (clipData->hasRectClip) + blitter->fillRect(targetRect & clipData->clipRect, color); + else if (clipData->hasRegionClip) { + QVector rects = clipData->clipRegion.rects(); + for ( int i = 0; i < rects.size(); i++ ) { + QRect intersectRect = rects.at(i).intersected(targetRect.toRect()); + if (!intersectRect.isEmpty()) { + blitter->fillRect(intersectRect,color); + } + } + } + }else { + if (targetRect.x() >= 0 && targetRect.y() >= 0 + && targetRect.width() <= raster->paintDevice()->width() + && targetRect.height() <= raster->paintDevice()->height()) + blitter->fillRect(targetRect,color); + else { + QRectF deviceRect(0,0,raster->paintDevice()->width(), raster->paintDevice()->height()); + blitter->fillRect(deviceRect&targetRect,color); + } + } + } + + void clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr) { + QRectF intersectedRect = clip.intersected(target); + if (intersectedRect.isEmpty()) + return; + + QRectF source = sr; + if(intersectedRect.size() != target.size()) { + qreal deltaTop = target.top() - intersectedRect.top(); + qreal deltaLeft = target.left() - intersectedRect.left(); + qreal deltaBottom = target.bottom() - intersectedRect.bottom(); + qreal deltaRight = target.right() - intersectedRect.right(); + source.adjust(-deltaLeft,-deltaTop,deltaRight,deltaBottom); + } + blitter->drawPixmap(intersectedRect, pm, source); + } + + void updateClip() { + const QClipData *clip = raster->d_func()->clip(); + bool complex = clip != 0 && !(clip->hasRectClip || clip->hasRegionClip); + capabillities->updateAllWithBits(STATE_CLIP_COMPLEX, complex); + } + + void systemStateChanged() { + raster->d_func()->systemStateChanged(); + } + + QRasterPaintEngine *raster; + QRasterPaintEngineState *state; + + QBlittable *blitter; + bool isBlitterLocked; + + CapabilitiesToStateMask *capabillities; + + uint hasXForm; +}; + +QBlitterPaintEngine::QBlitterPaintEngine(QPaintDevice *p) + : QPaintEngineEx(*(new QBlitterPaintEnginePrivate(p))) +{ +} + +QBlitterPaintEngine::~QBlitterPaintEngine() +{ + Q_D(QBlitterPaintEngine); +} + +QPainterState *QBlitterPaintEngine::createState(QPainterState *orig) const +{ + Q_D(const QBlitterPaintEngine); + return d->raster->createState(orig); +} + +bool QBlitterPaintEngine::begin(QPaintDevice *pdev) +{ + Q_D(QBlitterPaintEngine); + + d->raster->setSystemRect(systemRect()); + d->raster->setSystemClip(systemClip()); + + bool ok = d->raster->begin(pdev); + return ok; +} + + +bool QBlitterPaintEngine::end() +{ + Q_D(QBlitterPaintEngine); + + d->raster->setPaintDevice(0); + d->raster->setActive(false); + return d->raster->end(); +} + + +void QBlitterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) +{ + Q_D(QBlitterPaintEngine); + + if (path.shape() == QVectorPath::RectangleHint) { + QRectF rect(((QPointF *) path.points())[0], ((QPointF *) path.points())[2]); + fillRect(rect, brush); + } else { + d->lock(); + d->raster->fill(path, brush); +#ifdef RASTEROVERLAY + d->raster->fill(path,rasterBrush); +#endif + } +} + +void QBlitterPaintEngine::fillRect(const QRectF &rect, const QColor &color) +{ + Q_D(QBlitterPaintEngine); + if (d->capabillities->canBlitterFillRect() && color.alpha() == 255) { + d->fillRect(rect, color); + } else { + d->lock(); + d->raster->fillRect(rect, color); +#ifdef RASTEROVERLAY + d->raster->fillRect(rect,rasterColor); +#endif + } +} + +void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) +{ + if(rect.size().isEmpty()) + return; + Q_D(QBlitterPaintEngine); + if (qbrush_style(brush) == Qt::SolidPattern + && qbrush_color(brush).alpha() == 255 + && d->capabillities->canBlitterFillRect()) + { + d->fillRect(rect, qbrush_color(brush)); + }else if (brush.style() == Qt::TexturePattern + && d->capabillities->canBlitterDrawPixmap(rect,brush.texture(),rect)) + { + bool rectIsFilled = false; + QRectF transformedRect = state()->matrix.mapRect(rect); + qreal x = transformedRect.x(); + qreal y = transformedRect.y(); + QPixmap pm = brush.texture(); + d->unlock(); + int srcX = (int)(rect.x() - d->raster->state()->brushOrigin.x()) % pm.width(); + if (srcX < 0) + srcX = pm.width() + srcX; + const int startX = srcX; + int srcY = (int)(rect.y() - d->raster->state()->brushOrigin.y())% pm.height(); + if (srcY < 0) + srcY = pm.height() + srcY; + while (!rectIsFilled) { + qreal blitWidth = (pm.width() ) - srcX; + qreal blitHeight = (pm.height() ) - srcY; + if (x + blitWidth > transformedRect.right()) + blitWidth = transformedRect.right() -x; + if (y + blitHeight > transformedRect.bottom()) + blitHeight = transformedRect.bottom() - y; + const QClipData *clipData = d->raster->d_func()->clip(); + if (clipData->hasRectClip) { + QRect targetRect = QRect(x,y,blitWidth,blitHeight).intersected(clipData->clipRect); + if (targetRect.isValid()) { + int tmpSrcX = srcX + (targetRect.x() - x); + int tmpSrcY = srcY + (targetRect.y() - y); + QRect srcRect(tmpSrcX,tmpSrcY,targetRect.width(),targetRect.height()); + d->blitter->drawPixmap(targetRect,pm,srcRect); + } + } else if (clipData->hasRegionClip) { + QVector clipRects = clipData->clipRegion.rects(); + QRect unclippedTargetRect(x,y,blitWidth,blitHeight); + QRegion intersectedRects = clipData->clipRegion.intersected(unclippedTargetRect); + + for ( int i = 0; i < intersectedRects.rects().size(); i++ ) { + QRect targetRect = intersectedRects.rects().at(i); + if (!targetRect.isValid() || targetRect.isEmpty()) + continue; + int tmpSrcX = srcX + (targetRect.x() - x); + int tmpSrcY = srcY + (targetRect.y() - y); + QRect srcRect(tmpSrcX,tmpSrcY,targetRect.width(),targetRect.height()); + d->blitter->drawPixmap(targetRect,pm,srcRect); + } + } else Q_ASSERT(false);//should never happen + x+=blitWidth; + if (x>=transformedRect.right()) { + x = transformedRect.x(); + srcX = startX; + srcY = 0; + y+=blitHeight; + if (y>=transformedRect.bottom()) + rectIsFilled = true; + } else + srcX = 0; + } + + } else { + d->lock(); + d->raster->fillRect(rect, brush); +#ifdef RASTEROVERLAY + d->raster->fillRect(rect,rasterBrush); +#endif + } + +} + +void QBlitterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) +{ + Q_D(QBlitterPaintEngine); + d->lock(); + d->raster->stroke(path, pen); +#ifdef RASTEROVERLAY + d->raster->stroke(path,QPen(rasterColor)); +#endif +} + +void QBlitterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) +{ + Q_D(QBlitterPaintEngine); + d->raster->clip(path, op); + d->updateClip(); +} +void QBlitterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op){ + Q_D(QBlitterPaintEngine); + d->raster->clip(rect,op); + d->updateClip(); +} +void QBlitterPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) +{ + Q_D(QBlitterPaintEngine); + d->raster->clip(region,op); + d->updateClip(); +} + +void QBlitterPaintEngine::clipEnabledChanged() +{ + Q_D(QBlitterPaintEngine); + d->raster->clipEnabledChanged(); +} + +void QBlitterPaintEngine::penChanged() +{ + Q_D(QBlitterPaintEngine); + d->raster->penChanged(); + d->capabillities->updateDrawRectBits(STATE_PEN_ENABLED,qpen_style(d->state->pen) != Qt::NoPen); +} + +void QBlitterPaintEngine::brushChanged() +{ + Q_D(QBlitterPaintEngine); + d->raster->brushChanged(); + + bool solid = qbrush_style(d->state->brush) == Qt::SolidPattern; + + d->capabillities->updateDrawRectBits(STATE_BRUSH_PATTERN, !solid); + d->capabillities->updateDrawRectBits(STATE_BRUSH_ALPHA, + qbrush_color(d->state->brush).alpha() < 255); +} + +void QBlitterPaintEngine::brushOriginChanged() +{ + Q_D(QBlitterPaintEngine); + d->raster->brushOriginChanged(); +} + +void QBlitterPaintEngine::opacityChanged() +{ + Q_D(QBlitterPaintEngine); + d->raster->opacityChanged(); + + bool translucent = d->state->opacity < 1; + d->capabillities->updateAllWithBits(STATE_ALPHA,translucent); +} + +void QBlitterPaintEngine::compositionModeChanged() +{ + Q_D(QBlitterPaintEngine); + d->raster->compositionModeChanged(); + + bool nonTrivial = d->state->composition_mode != QPainter::CompositionMode_SourceOver + && d->state->composition_mode != QPainter::CompositionMode_Source; + + d->capabillities->updateAllWithBits(STATE_BLENDING_COMPLEX,nonTrivial); +} + +void QBlitterPaintEngine::renderHintsChanged() +{ + Q_D(QBlitterPaintEngine); + d->raster->renderHintsChanged(); + + bool aa = d->state->renderHints & QPainter::Antialiasing; + d->capabillities->updateFillRectBits(STATE_ANTIALIASING, aa); + d->capabillities->updateDrawRectBits(STATE_ANTIALIASING, aa); + +} + +void QBlitterPaintEngine::transformChanged() +{ + Q_D(QBlitterPaintEngine); + d->raster->transformChanged(); + + QTransform::TransformationType type = d->state->matrix.type(); + + d->capabillities->updateAllWithBits(STATE_XFORM_COMPLEX, type > QTransform::TxScale); + + d->hasXForm = type >= QTransform::TxTranslate; + +} + +void QBlitterPaintEngine::drawRects(const QRect *rects, int rectCount) +{ + Q_D(QBlitterPaintEngine); + if (d->capabillities->canBlitterDrawRectMask()) { + for (int i=0; ifillRect(rects[i], qbrush_color(d->state->brush)); + } + } else { + QPaintEngineEx::drawRects(rects, rectCount); +#ifdef RASTEROVERLAY + d->raster->drawRects(rects,rectCount); +#endif + } +} + +void QBlitterPaintEngine::drawRects(const QRectF *rects, int rectCount) +{ + Q_D(QBlitterPaintEngine); + if (d->capabillities->canBlitterDrawRectMask()) { + for (int i=0; ifillRect(rects[i], qbrush_color(d->state->brush)); + } + } else { + QPaintEngineEx::drawRects(rects, rectCount); +#ifdef RASTEROVERLAY + d->raster->drawRects(rects,rectCount); +#endif + } +} + +void QBlitterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) +{ + Q_D(QBlitterPaintEngine); + if (d->capabillities->canBlitterDrawPixmap(r,pm,sr)) { + + d->unlock(); + QRectF targetRect = r; + if (d->hasXForm) { + targetRect = state()->matrix.mapRect(r); + } + const QClipData *clipData = d->raster->d_func()->clip(); + if (clipData) { + if (clipData->hasRectClip) { + d->clipAndDrawPixmap(clipData->clipRect,targetRect,pm,sr); + }else if (clipData->hasRegionClip) { + QVectorrects = clipData->clipRegion.rects(); + for (int i = 0; iclipAndDrawPixmap(rects.at(i),targetRect,pm,sr); + } + } + } else { + QRectF deviceRect(0,0,d->raster->paintDevice()->width(), d->raster->paintDevice()->height()); + d->clipAndDrawPixmap(deviceRect,targetRect,pm,sr); + } + }else { + d->lock(); + d->raster->drawPixmap(r, pm, sr); +#ifdef RASTEROVERLAY + d->raster->fillRect(r,rasterColor); +#endif + } +} + +void QBlitterPaintEngine::drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, + Qt::ImageConversionFlags flags) +{ + Q_D(QBlitterPaintEngine); + d->lock(); + d->raster->drawImage(r, pm, sr, flags); +#ifdef RASTEROVERLAY + d->raster->fillRect(r,rasterColor); +#endif +} + + +void QBlitterPaintEngine::drawTextItem(const QPointF &pos, const QTextItem &ti) +{ + Q_D(QBlitterPaintEngine); + d->lock(); + d->raster->drawTextItem(pos, ti); +#ifdef RASTEROVERLAY + QFontMetricsF fm(ti.font()); + QRectF rect = fm.tightBoundingRect(ti.text()); + rect.moveBottomLeft(pos); + d->raster->fillRect(rect, rasterColor); +#endif +} + + +void QBlitterPaintEngine::setState(QPainterState *s) +{ + Q_D(QBlitterPaintEngine); + QPaintEngineEx::setState(s); + d->raster->setState(s); + d->state = (QRasterPaintEngineState *) s; + + clipEnabledChanged(); + penChanged(); + brushChanged(); + brushOriginChanged(); + opacityChanged(); + compositionModeChanged(); + renderHintsChanged(); + transformChanged(); + + d->updateClip(); +} + +class QBlittablePrivate +{ +public: + QBlittable::Capabilities caps; +}; + + +QBlittable::QBlittable(Capabilities caps) + : d_ptr(new QBlittablePrivate) +{ + d_ptr->caps = caps; +} + +QBlittable::QBlittable(QBlittablePrivate &d, Capabilities caps) + : d_ptr(&d) +{ + d_ptr->caps = caps; +} + + +QBlittable::~QBlittable() +{ + delete d_ptr; +} + + +QBlittable::Capabilities QBlittable::capabilities() const +{ + Q_D(const QBlittable); + return d->caps; +} + diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h new file mode 100644 index 0000000..90493a4 --- /dev/null +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -0,0 +1,94 @@ +#ifndef QPAINTENGINE_BLITTER_P_H +#define QPAINTENGINE_BLITTER_P_H + +#include "private/qpaintengineex_p.h" + +class QRasterPaintEngine; +class QBlittablePrivate; +class QBlitterPaintEnginePrivate; + +// ### find name +class Q_GUI_EXPORT QBlittable +{ + Q_DECLARE_PRIVATE(QBlittable); +public: + enum Capability { + + SolidRectCapability = 0x0001, + SourcePixmapCapability = 0x0002, + SourceOverPixmapCapability = 0x0004, + SourceOverScaledPixmapCapability = 0x0008, + + // Internal ones + OutlineCapability = 0x0001000, + }; + Q_DECLARE_FLAGS(Capabilities, Capability); + + QBlittable(Capabilities caps); + virtual ~QBlittable(); + + Capabilities capabilities() const; + + virtual void fillRect(const QRectF &rect, const QColor &color) = 0; + virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect) = 0; + + virtual QImage *lock() = 0; + virtual void unlock() = 0; + +protected: + QBlittablePrivate *d_ptr; + + QBlittable(QBlittablePrivate &d, Capabilities caps); +}; + + +class Q_GUI_EXPORT QBlitterPaintEngine : public QPaintEngineEx +{ + Q_DECLARE_PRIVATE(QBlitterPaintEngine); +public: + QBlitterPaintEngine(QPaintDevice *p); + ~QBlitterPaintEngine(); + + virtual QPainterState *createState(QPainterState *orig) const; + + virtual QPaintEngine::Type type() const { return Blitter; } + + virtual bool begin(QPaintDevice *pdev); + virtual bool end(); + + virtual void fill(const QVectorPath &path, const QBrush &brush); + virtual void stroke(const QVectorPath &path, const QPen &pen); + + virtual void clip(const QVectorPath &path, Qt::ClipOperation op); + virtual void clip(const QRect &rect, Qt::ClipOperation op); + virtual void clip(const QRegion ®ion, Qt::ClipOperation op); + + virtual void clipEnabledChanged(); + virtual void penChanged(); + virtual void brushChanged(); + virtual void brushOriginChanged(); + virtual void opacityChanged(); + virtual void compositionModeChanged(); + virtual void renderHintsChanged(); + virtual void transformChanged(); + + virtual void fillRect(const QRectF &rect, const QBrush &brush); + virtual void fillRect(const QRectF &rect, const QColor &color); + + virtual void drawRects(const QRect *rects, int rectCount); + virtual void drawRects(const QRectF *rects, int rectCount); + + virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); + + virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags); + + virtual void drawTextItem(const QPointF &pos, const QTextItem &ti); + + virtual void setState(QPainterState *s); + + inline QPainterState *state() { return static_cast(QPaintEngine::state); } + inline const QPainterState *state() const { return static_cast(QPaintEngine::state); } + +}; + +#endif // QPAINTENGINE_BLITTER_P_H diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 1787d16..36e8b13 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -252,6 +252,8 @@ protected: QRasterPaintEngine(QRasterPaintEnginePrivate &d, QPaintDevice *); private: friend struct QSpanData; + friend class QBlitterPaintEngine; + friend class QBlitterPaintEnginePrivate; void init(); void fillRect(const QRectF &rect, QSpanData *data); -- cgit v0.12 From 617f572f459f4406b3f0316e45abdceba01c0c26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 9 Nov 2009 14:08:22 +0100 Subject: Using the correct geometry --- src/plugins/graphicssystems/minimaldfb/minimaldfb.pro | 2 +- .../graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp | 8 +++++++- .../graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp | 3 --- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro index a3b7f5c..d4c93fd 100644 --- a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro +++ b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro @@ -1,4 +1,4 @@ -TARGET = qdirectfbgraphicssystem +TARGET = qminimaldfb include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index 7c06748..bf46d4c 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -54,8 +54,10 @@ QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int DirectFBError("QDirectFbGraphicsSystemScreen::connect: " "Unable to get primary display layer!", result); } + m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); IDirectFBSurface *topLevelSurface; + //This line gives a warning m_layer->GetSurface(m_layer, &topLevelSurface); m_format = QDirectFbGraphicsSystem::imageFormatFromSurface(topLevelSurface); @@ -65,7 +67,11 @@ QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int } int w(0),h(0); - m_screen->GetSize(m_screen,&w,&h); + //Asking the screen for its size gives the desktop geometry on X11 + //Thats not something we want, so as the topLevelSorface instead +// m_screen->GetSize(m_screen,&w,&h); + topLevelSurface->GetSize(topLevelSurface,&w,&h); + m_geometry = QRect(0,0,w,h); const int dpi = 72; const qreal inch = 25.4; diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 76fad68..e75a43c 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -55,9 +55,6 @@ QDirectFbWindowSurface::QDirectFbWindowSurface if (result != DFB_OK) { DirectFBError("QDirectFbWindowSurface::QDirectFbWindowSurface: unable to get windows surface",result); } - - - } QDirectFbWindowSurface::~QDirectFbWindowSurface() -- cgit v0.12 From d279d7d64fda1a1fd253a21875e1c832093b00c8 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 11 Nov 2009 11:34:12 +0100 Subject: Common framebuffer functionality for VNC and linuxfb, cursor event notification --- src/gui/kernel/qapplication.cpp | 8 +- src/gui/kernel/qapplication_p.h | 2 + src/gui/kernel/qwidget_lite.cpp | 24 + src/gui/painting/painting.pri | 5 +- src/gui/painting/qgraphicssystem_p.h | 2 + src/gui/painting/qgraphicssystemcursor.cpp | 600 +++++++++++++++++++++ src/gui/painting/qgraphicssystemcursor.h | 98 ++++ src/plugins/graphicssystems/fb_base/fb_base.cpp | 205 +++++++ src/plugins/graphicssystems/fb_base/fb_base.h | 90 ++++ src/plugins/graphicssystems/fb_base/fb_base.pro | 23 + src/plugins/graphicssystems/linuxfb/linuxfb.pro | 5 +- .../linuxfb/qgraphicssystem_linuxfb.cpp | 66 ++- .../linuxfb/qgraphicssystem_linuxfb.h | 26 +- .../linuxfb/qwindowsurface_linuxfb.cpp | 114 ---- .../linuxfb/qwindowsurface_linuxfb.h | 73 --- .../graphicssystems/vnc/qgraphicssystem_vnc.cpp | 110 +--- .../graphicssystems/vnc/qgraphicssystem_vnc.h | 50 +- src/plugins/graphicssystems/vnc/qvnccursor.cpp | 541 +------------------ src/plugins/graphicssystems/vnc/qvnccursor.h | 27 +- src/plugins/graphicssystems/vnc/qvncserver.cpp | 8 +- src/plugins/graphicssystems/vnc/qvncserver.h | 5 +- .../graphicssystems/vnc/qwindowsurface_vnc.cpp | 125 ----- .../graphicssystems/vnc/qwindowsurface_vnc.h | 80 --- src/plugins/graphicssystems/vnc/vnc.pro | 9 +- 24 files changed, 1173 insertions(+), 1123 deletions(-) create mode 100644 src/gui/painting/qgraphicssystemcursor.cpp create mode 100644 src/gui/painting/qgraphicssystemcursor.h create mode 100644 src/plugins/graphicssystems/fb_base/fb_base.cpp create mode 100644 src/plugins/graphicssystems/fb_base/fb_base.h create mode 100644 src/plugins/graphicssystems/fb_base/fb_base.pro delete mode 100644 src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp delete mode 100644 src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h delete mode 100644 src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp delete mode 100644 src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 74f2971..c36dc44 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -2655,7 +2655,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { // Update cursor for alien/graphics widgets. const bool enterOnAlien = (enter && (isAlien(enter) || enter->testAttribute(Qt::WA_DontShowOnScreen))); -#if defined(Q_WS_X11) +#if defined(Q_WS_X11) || defined(Q_WS_LITE) //Whenever we leave an alien widget on X11, we need to reset its nativeParentWidget()'s cursor. // This is not required on Windows as the cursor is reset on every single mouse move. QWidget *parentOfLeavingCursor = 0; @@ -2676,7 +2676,11 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { if (!parentOfLeavingCursor->window()->graphicsProxyWidget()) #endif { +#if defined(Q_WS_X11) qt_x11_enforce_cursor(parentOfLeavingCursor,true); +#elif defined(Q_WS_LITE) + qt_lite_set_cursor(parentOfLeavingCursor, true); +#endif } } #endif @@ -2700,6 +2704,8 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { qt_x11_enforce_cursor(cursorWidget, true); #elif defined(Q_WS_S60) qt_symbian_set_cursor(cursorWidget, true); +#elif defined(Q_WS_LITE) + qt_lite_set_cursor(cursorWidget, true); #endif } } diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 2622f1c..baec8ca 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -606,6 +606,8 @@ Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, extern void qt_x11_enforce_cursor(QWidget *); #elif defined(Q_OS_SYMBIAN) extern void qt_symbian_set_cursor(QWidget *, bool); +#elif defined (Q_WS_LITE) + extern void qt_lite_set_cursor(QWidget *, bool); #endif QT_END_NAMESPACE diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 1eb93d3..a4d60a7 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -48,6 +48,8 @@ #include "private/qapplication_p.h" #include "qdesktopwidget.h" +#include "qgraphicssystemcursor.h" + QT_BEGIN_NAMESPACE void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool /*destroyOldWindow*/) @@ -647,4 +649,26 @@ void QWidgetPrivate::setModal_sys() { } +void qt_lite_set_cursor(QWidget * w, bool force) +{ + static QPointer lastUnderMouse = 0; + if (force) { + lastUnderMouse = w; + } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse + && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) { + w = lastUnderMouse; + } + + QWidget * curWin = QApplication::activeWindow(); + if (!curWin && w && w->internalWinId()) + return; + QWidget* cW = w && !w->internalWinId() ? w : curWin; + if (!cW || cW->window() != w->window() || + !cW->isVisible() || !cW->underMouse() || QApplication::overrideCursor()) + return; + + if (QGraphicsSystemCursor::instance) { + QGraphicsSystemCursor::instance->changeCursor(w); + } +} QT_END_NAMESPACE diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 4a32e71..2c6deda 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -182,7 +182,10 @@ embedded { embedded_lite { SOURCES += \ painting/qcolormap_lite.cpp \ - painting/qpaintdevice_lite.cpp + painting/qpaintdevice_lite.cpp \ + painting/qgraphicssystemcursor.cpp + HEADERS += \ + painting/qgraphicssystemcursor.h } symbian { diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index a2d03f0..7cc6247 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -72,6 +72,8 @@ public: virtual int depth() const = 0; virtual QImage::Format format() const = 0; virtual QSize physicalSize() const = 0; + virtual void setDirty(QRect) { } + virtual void pointerEvent(QMouseEvent &) { } }; class Q_GUI_EXPORT QGraphicsSystem diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp new file mode 100644 index 0000000..91a6535 --- /dev/null +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -0,0 +1,600 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qgraphicssystemcursor.h" +//#include "qlighthousegraphicsscreen.h" + +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +QPointer QGraphicsSystemCursor::instance = 0; + +QGraphicsSystemCursor::QGraphicsSystemCursor(QGraphicsSystemScreen *scr ) + :currentRect(QRect()), prevRect(QRect()), screen(scr) +{ + graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); + instance = this; + QWidget * widget = QApplication::widgetAt(QCursor::pos()); + changeCursor(widget); +} + +QGraphicsSystemCursor::~QGraphicsSystemCursor() +{ +} + +void QGraphicsSystemCursor::setCursor(Qt::CursorShape shape) +{ + graphic->set(shape); +} + +void QGraphicsSystemCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) +{ + graphic->set(data, mask, width, height, hotX, hotY); +} + +QRect QGraphicsSystemCursor::dirtyRect() +{ + if (!prevRect.isNull()) { + QRect rect = prevRect; + prevRect = QRect(); + return rect; + } + return QRect(); +} + +QRect QGraphicsSystemCursor::drawCursor(QPainter & painter) +{ + if (currentRect.isNull()) + return QRect(); + + prevRect = currentRect; + painter.drawImage(prevRect, *graphic->image()); + return prevRect; +} + +void QGraphicsSystemCursor::pointerEvent(QMouseEvent & e) +{ + currentRect = graphic->image()->rect().translated(-graphic->hotspot().x(), + -graphic->hotspot().y()); + currentRect.translate(e.pos()); + screen->setDirty(currentRect); + + screen->pointerEvent(e); +} + +void QGraphicsSystemCursor::changeCursor(QWidget * widget) +{ + if (widget) { + QCursor widgetCursor = widget->cursor(); + Qt::CursorShape shape = widgetCursor.shape(); + + if (shape == Qt::BitmapCursor) { + // application supplied cursor + const QBitmap * map = widgetCursor.bitmap(); + const QBitmap * mask = widgetCursor.mask(); + QPoint spot = widgetCursor.hotSpot(); + setCursor(map->toImage().bits(), mask->toImage().bits(), map->width(), map->height(), spot.x(), spot.y()); + } else { + // system cursor + setCursor(shape); + } + } else { + // default cursor + setCursor(Qt::ArrowCursor); + } +} + +// End of display and pointer event handling code +// Beginning of built-in cursor graphics +// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp + +static QGraphicsSystemCursorImage *systemCursorTable[Qt::LastCursor+1]; +static bool systemCursorTableInit = false; + +// 16 x 16 +static const uchar cur_arrow_bits[] = { + 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08, + 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22, + 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 }; +static const uchar mcur_arrow_bits[] = { + 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f, + 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e, + 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 }; + +static const unsigned char cur_up_arrow_bits[] = { + 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, + 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01}; +static const unsigned char mcur_up_arrow_bits[] = { + 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07, + 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01}; + +static const unsigned char cur_cross_bits[] = { + 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00}; +static const unsigned char mcur_cross_bits[] = { + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; + +static const uchar cur_ibeam_bits[] = { + 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, + 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, + 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_ibeam_bits[] = { + 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 }; + +static const uchar cur_ver_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, + 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, + 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; +static const uchar mcur_ver_bits[] = { + 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, + 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, + 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; + +static const uchar cur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, + 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, + 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, + 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; +static const uchar cur_bdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, + 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, + 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_bdiag_bits[] = { + 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, + 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, + 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; +static const uchar cur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, + 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, + 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, + 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, + 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; +static const uchar cur_blank_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +// 20 x 20 +static const uchar forbidden_bits[] = { + 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, + 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, + 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, + 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; + +static const uchar forbiddenm_bits[] = { + 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, + 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, + 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, + 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; + +// 32 x 32 +static const uchar wait_data_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00, + 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, + 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00, + 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, + 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00, + 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar wait_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, + 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00, + 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar hsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, + 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar hsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, + 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, + 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, + 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar vsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar vsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar phand_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, + 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00, + 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, + 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar phandm_bits[] = { + 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, + 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, + 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, + 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, + 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar size_all_data_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00, + 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar size_all_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00, + 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01, + 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00, + 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar whatsthis_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, + 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, + 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, + 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, + 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, + 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; +static const uchar whatsthism_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, + 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, + 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, + 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, + 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, + 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + +static const uchar busy_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, + 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, + 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, + 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, + 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static const uchar busym_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, + 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, + 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, + 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, + 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +// 16 x 16 +static const uchar openhand_bits[] = { + 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, + 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, + 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; +static const uchar openhandm_bits[] = { + 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, + 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, + 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; +static const uchar closedhand_bits[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, + 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, + 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; +static const uchar closedhandm_bits[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, + 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, + 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; + +void QGraphicsSystemCursorImage::createSystemCursor(int id) +{ + if (!systemCursorTableInit) { + for (int i = 0; i <= Qt::LastCursor; i++) + systemCursorTable[i] = 0; + systemCursorTableInit = true; + } + switch (id) { + // 16x16 cursors + case Qt::ArrowCursor: + systemCursorTable[Qt::ArrowCursor] = + new QGraphicsSystemCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0); + break; + + case Qt::UpArrowCursor: + systemCursorTable[Qt::UpArrowCursor] = + new QGraphicsSystemCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0); + break; + + case Qt::CrossCursor: + systemCursorTable[Qt::CrossCursor] = + new QGraphicsSystemCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7); + break; + + case Qt::IBeamCursor: + systemCursorTable[Qt::IBeamCursor] = + new QGraphicsSystemCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7); + break; + + case Qt::SizeVerCursor: + systemCursorTable[Qt::SizeVerCursor] = + new QGraphicsSystemCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7); + break; + + case Qt::SizeHorCursor: + systemCursorTable[Qt::SizeHorCursor] = + new QGraphicsSystemCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7); + break; + + case Qt::SizeBDiagCursor: + systemCursorTable[Qt::SizeBDiagCursor] = + new QGraphicsSystemCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7); + break; + + case Qt::SizeFDiagCursor: + systemCursorTable[Qt::SizeFDiagCursor] = + new QGraphicsSystemCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7); + break; + + case Qt::BlankCursor: + systemCursorTable[Qt::BlankCursor] = + new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); + break; + + // 20x20 cursors + case Qt::ForbiddenCursor: + systemCursorTable[Qt::ForbiddenCursor] = + new QGraphicsSystemCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10); + break; + + // 32x32 cursors + case Qt::WaitCursor: + systemCursorTable[Qt::WaitCursor] = + new QGraphicsSystemCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15); + break; + + case Qt::SplitVCursor: + systemCursorTable[Qt::SplitVCursor] = + new QGraphicsSystemCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15); + break; + + case Qt::SplitHCursor: + systemCursorTable[Qt::SplitHCursor] = + new QGraphicsSystemCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15); + break; + + case Qt::SizeAllCursor: + systemCursorTable[Qt::SizeAllCursor] = + new QGraphicsSystemCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15); + break; + + case Qt::PointingHandCursor: + systemCursorTable[Qt::PointingHandCursor] = + new QGraphicsSystemCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0); + break; + + case Qt::WhatsThisCursor: + systemCursorTable[Qt::WhatsThisCursor] = + new QGraphicsSystemCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0); + break; + case Qt::BusyCursor: + systemCursorTable[Qt::BusyCursor] = + new QGraphicsSystemCursorImage(busy_bits, busym_bits, 32, 32, 0, 0); + break; + + case Qt::OpenHandCursor: + systemCursorTable[Qt::OpenHandCursor] = + new QGraphicsSystemCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8); + break; + case Qt::ClosedHandCursor: + systemCursorTable[Qt::ClosedHandCursor] = + new QGraphicsSystemCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8); + break; + default: + qWarning("Unknown system cursor %d", id); + } +} + +void QGraphicsSystemCursorImage::set(Qt::CursorShape id) +{ + QGraphicsSystemCursorImage *cursor = 0; + if (id >= 0 && id <= Qt::LastCursor) { + if (!systemCursorTable[id]) + createSystemCursor(id); + cursor = systemCursorTable[id]; + } + + if (cursor == 0) { + if (!systemCursorTable[Qt::ArrowCursor]) + createSystemCursor(Qt::ArrowCursor); + cursor = systemCursorTable[Qt::ArrowCursor]; + } + cursorImage = cursor->cursorImage; + hot = cursor->hot; +} + +void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, + int width, int height, int hx, int hy) +{ + hot.setX(hx); + hot.setY(hy); + + cursorImage = QImage(width,height, QImage::Format_Indexed8); + + if (!width || !height || !data || !mask || cursorImage.isNull()) + return; + + cursorImage.setNumColors(3); + cursorImage.setColor(0, 0xff000000); + cursorImage.setColor(1, 0xffffffff); + cursorImage.setColor(2, 0x00000000); + + int bytesPerLine = (width + 7) / 8; + int p = 0; + int d, m; + + int x = -1, w = 0; + + uchar *cursor_data = cursorImage.bits(); + int bpl = cursorImage.bytesPerLine(); + for (int i = 0; i < height; i++) + { + for (int j = 0; j < bytesPerLine; j++, data++, mask++) + { + for (int b = 0; b < 8 && j*8+b < width; b++) + { + d = *data & (1 << b); + m = *mask & (1 << b); + if (d && m) p = 0; + else if (!d && m) p = 1; + else p = 2; + cursor_data[j*8+b] = p; + + // calc region + if (x < 0 && m) + x = j*8+b; + else if (x >= 0 && !m) { + x = -1; + w = 0; + } + if (m) + w++; + } + } + if (x >= 0) { + x = -1; + w = 0; + } + cursor_data += bpl; + } + +} + +QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystemcursor.h b/src/gui/painting/qgraphicssystemcursor.h new file mode 100644 index 0000000..cb5c471 --- /dev/null +++ b/src/gui/painting/qgraphicssystemcursor.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QGRAPHICSSYSTEMCURSOR_H +#define QGRAPHICSSYSTEMCURSOR_H + +#include +#include +#include +#include +#include +#include "qgraphicssystem_p.h" + +QT_BEGIN_NAMESPACE + +// Cursor graphics management +class QGraphicsSystemCursorImage { +public: + QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + { set(data, mask, width, height, hotX, hotY); } + QImage * image() { return &cursorImage; } + QPoint hotspot() { return hot; } + void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + void set(Qt::CursorShape); +private: + static void createSystemCursor(int id); + QImage cursorImage; + QPoint hot; +}; + +class Q_GUI_EXPORT QGraphicsSystemCursor : public QObject { +public: + QGraphicsSystemCursor(QGraphicsSystemScreen *); + virtual ~QGraphicsSystemCursor(); + + // input methods + virtual void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + virtual void setCursor(Qt::CursorShape shape); + virtual void pointerEvent(QMouseEvent & event); + virtual void changeCursor(QWidget * widget); + + // output methods + virtual QRect drawCursor(QPainter &); + virtual QRect dirtyRect(); + + static QPointer instance; + +protected: + + QRect currentRect; // next place to draw the cursor + QRect prevRect; // last place the cursor was drawn + + QGraphicsSystemScreen * screen; // Where to request an update + QWidget * currentWidget; // widget currently under the cursor + + QGraphicsSystemCursorImage * graphic; +}; + +QT_END_NAMESPACE + +#endif // QGRAPHICSSYSTEMCURSOR_H diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp new file mode 100644 index 0000000..ffa5d4e --- /dev/null +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -0,0 +1,205 @@ +#include "fb_base.h" + +#include +#include +#include + +#include + +QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0) +{ + mScreenImage = new QImage(mGeometry.size(), mFormat); + redrawTimer.setSingleShot(true); + redrawTimer.setInterval(0); + QObject::connect(&redrawTimer, SIGNAL(timeout()), this, SLOT(doRedraw())); +} + +void QGraphicsSystemFbScreen::setGeometry(QRect rect) +{ + delete mScreenImage; + mGeometry = rect; + mScreenImage = new QImage(mGeometry.size(), mFormat); +} + +void QGraphicsSystemFbScreen::setDepth(int depth) +{ + mDepth = depth; +} + +void QGraphicsSystemFbScreen::setPhysicalSize(QSize size) +{ + mPhysicalSize = size; +} + +void QGraphicsSystemFbScreen::setFormat(QImage::Format format) +{ + mFormat = format; + delete mScreenImage; + mScreenImage = new QImage(mGeometry.size(), mFormat); +} + +QGraphicsSystemFbScreen::~QGraphicsSystemFbScreen() +{ + delete mScreenImage; +} + +void QGraphicsSystemFbScreen::setDirty(const QRect &rect) +{ + repaintRegion += rect; + if (!redrawTimer.isActive()) { + redrawTimer.start(); + } +} + +QRegion QGraphicsSystemFbScreen::doRedraw() +{ + QRegion touchedRegion; + if (cursor) + repaintRegion += cursor->dirtyRect(); + if (repaintRegion.isEmpty()) + return touchedRegion; + + QPainter compositePainter(mScreenImage); + QVector rects = repaintRegion.rects(); + + for (int rectIndex = 0; rectIndex < repaintRegion.numRects(); rectIndex++) { + QRect rect = rects[rectIndex]; + // Blank the affected area, just in case there's nothing to display + compositePainter.fillRect(rect, Qt::black); + for (int i = 0; i < windowStack.length(); i++) { + if (!windowStack[i]->visible()) + continue; + QRect windowRect = windowStack[i]->geometry(); + QRect intersect = windowRect.intersected(rect); + QRect windowIntersect = intersect.translated(-windowRect.left(), + -windowRect.top()); + if (intersect.isNull()) + continue; + compositePainter.drawImage(intersect, windowStack[i]->image(), + windowIntersect); + } + } + + QRect cursorRect; + if (cursor) { + cursorRect = cursor->drawCursor(compositePainter); + touchedRegion += cursorRect; + } + touchedRegion += repaintRegion; + repaintRegion = QRegion(); + + return touchedRegion; +} + +void QGraphicsSystemFbScreen::removeWindowSurface(QGraphicsSystemFbWindowSurface * surface) +{ + windowStack.removeOne(surface); + setDirty(surface->geometry()); +} + +void QGraphicsSystemFbScreen::raise(QGraphicsSystemFbWindowSurface * surface) +{ + int index = windowStack.indexOf(surface); + if (index <= 0) + return; + windowStack.move(index, index - 1); +} + +void QGraphicsSystemFbScreen::lower(QGraphicsSystemFbWindowSurface * surface) +{ + int index = windowStack.indexOf(surface); + if (index == -1 || index == (windowStack.size() - 1)) + return; + windowStack.move(index, index + 1); +} + +void QGraphicsSystemFbScreen::top(QGraphicsSystemFbWindowSurface * surface) +{ + int index = windowStack.indexOf(surface); + if (index == -1) + return; + windowStack.move(index, 0); +} + +void QGraphicsSystemFbScreen::bottom(QGraphicsSystemFbWindowSurface * surface) +{ + int index = windowStack.indexOf(surface); + if (index == -1) + return; + windowStack.move(index, windowStack.size() - 1); +} + + +void QGraphicsSystemFbScreen::pointerEvent(QMouseEvent & me) +{ + QApplicationPrivate::handleMouseEvent(0, me); +} + + +QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen), + visibleFlag(false) +{ + mImage = QImage(window->size(), mScreen->format()); +} + +QGraphicsSystemFbWindowSurface::~QGraphicsSystemFbWindowSurface() +{ + mScreen->removeWindowSurface(this); +} + +void QGraphicsSystemFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(offset); + + QRect currentGeometry = geometry(); + // If this is a move, redraw the previous location + if (oldGeometry != currentGeometry) { + mScreen->setDirty(oldGeometry); + oldGeometry = currentGeometry; + } + + QRect dirtyClient = region.boundingRect(); + QRect dirtyRegion(currentGeometry.left() + dirtyClient.left(), + currentGeometry.top() + dirtyClient.top(), + dirtyClient.width(), + dirtyClient.height()); + mScreen->setDirty(dirtyRegion); +} + +void QGraphicsSystemFbWindowSurface::setGeometry(const QRect &rect) +{ + // store previous geometry for screen update + oldGeometry = geometry(); + + // change the widget's QImage if this is a resize + if (mImage.size() != rect.size()) + mImage = QImage(rect.size(), mScreen->format()); + + QApplicationPrivate::handleGeometryChange(this->window(), rect); + + QWindowSurface::setGeometry(rect); +} + +bool QGraphicsSystemFbWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QGraphicsSystemFbWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QGraphicsSystemFbWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QGraphicsSystemFbWindowSurface::setVisible(bool visible) +{ + visibleFlag = visible; + mScreen->setDirty(geometry()); +} diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h new file mode 100644 index 0000000..fba7a7a --- /dev/null +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -0,0 +1,90 @@ +#ifndef QLIGHTHOUSEGRAPHICSSCREEN_H +#define QLIGHTHOUSEGRAPHICSSCREEN_H + +#include +#include +#include +#include +#include +#include + +class QMouseEvent; +class QSize; +class QPainter; + +class QGraphicsSystemFbWindowSurface; +class QGraphicsSystemFbScreen; + +class QGraphicsSystemFbWindowSurface : public QWindowSurface +{ +public: + QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window); + ~QGraphicsSystemFbWindowSurface(); + + virtual QPaintDevice *paintDevice() { return &mImage; } + virtual void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + virtual bool scroll(const QRegion &area, int dx, int dy); + + virtual void beginPaint(const QRegion ®ion); + virtual void endPaint(const QRegion ®ion); + virtual void setVisible(bool visible); + virtual bool visible() { return visibleFlag; } + + const QImage image() { return mImage; } + void setGeometry(const QRect &rect); +protected: + QGraphicsSystemFbScreen *mScreen; + QRect oldGeometry; + QImage mImage; + bool visibleFlag; +}; + +class QGraphicsSystemFbScreen : public QGraphicsSystemScreen +{ + Q_OBJECT +public: + QGraphicsSystemFbScreen(); + ~QGraphicsSystemFbScreen(); + + virtual QRect geometry() const { return mGeometry; } + virtual int depth() const { return mDepth; } + virtual QImage::Format format() const { return mFormat; } + virtual QSize physicalSize() const { return mPhysicalSize; } + + virtual void setGeometry(QRect rect); + virtual void setDepth(int depth); + virtual void setFormat(QImage::Format format); + virtual void setPhysicalSize(QSize size); + + virtual void setDirty(const QRect &rect); + + virtual void removeWindowSurface(QGraphicsSystemFbWindowSurface * surface); + virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { windowStack.append(surface); } + virtual void raise(QGraphicsSystemFbWindowSurface * surface); + virtual void lower(QGraphicsSystemFbWindowSurface * surface); + virtual void top(QGraphicsSystemFbWindowSurface * surface); + virtual void bottom(QGraphicsSystemFbWindowSurface * surface); + + virtual void pointerEvent(QMouseEvent & me); + + QImage * image() const { return mScreenImage; } + QPaintDevice * paintDevice() const { return mScreenImage; } + +protected: + QList windowStack; + QRegion repaintRegion; + QGraphicsSystemCursor * cursor; + QTimer redrawTimer; + +protected slots: + virtual QRegion doRedraw(); + +protected: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; + QImage *mScreenImage; +}; + +#endif // QLIGHTHOUSEGRAPHICSSCREEN_H diff --git a/src/plugins/graphicssystems/fb_base/fb_base.pro b/src/plugins/graphicssystems/fb_base/fb_base.pro new file mode 100644 index 0000000..e08c0c5 --- /dev/null +++ b/src/plugins/graphicssystems/fb_base/fb_base.pro @@ -0,0 +1,23 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2009-11-05T13:22:31 +# +#------------------------------------------------- + +#QT -= core gui +TARGET = fb_base +#include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +TEMPLATE = lib + +#DEFINES += STATIC_LIBRARY +CONFIG += staticlib + +SOURCES += fb_base.cpp + +HEADERS += fb_base.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/graphicssystems/linuxfb/linuxfb.pro b/src/plugins/graphicssystems/linuxfb/linuxfb.pro index 1251d2f..ea92573 100644 --- a/src/plugins/graphicssystems/linuxfb/linuxfb.pro +++ b/src/plugins/graphicssystems/linuxfb/linuxfb.pro @@ -3,8 +3,9 @@ include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems -SOURCES = main.cpp qgraphicssystem_linuxfb.cpp qwindowsurface_linuxfb.cpp -HEADERS = qgraphicssystem_linuxfb.h qwindowsurface_linuxfb.h +SOURCES = main.cpp qgraphicssystem_linuxfb.cpp +HEADERS = qgraphicssystem_linuxfb.h target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +LIBS += -L$$[QT_INSTALL_PLUGINS]/graphicssystems -lfb_base INSTALLS += target diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp index 95c636f..291b118 100644 --- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp +++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp @@ -40,9 +40,11 @@ ****************************************************************************/ #include "qgraphicssystem_linuxfb.h" -#include "qwindowsurface_linuxfb.h" +#include "../fb_base/fb_base.h" #include #include // overrides QT_OPEN +#include +#include #include #include @@ -163,15 +165,11 @@ QLinuxFbGraphicsSystem::QLinuxFbGraphicsSystem() if (!connect(displaySpec)) qFatal("QLinuxFbGraphicsSystem: could not initialize screen"); - mPrimaryScreen = new QLinuxFbGraphicsSystemScreen(); - mPrimaryScreen->mGeometry = QRect(0, 0, w, h); - mPrimaryScreen->mDepth = d; - mPrimaryScreen->mFormat = screenFormat; - mPrimaryScreen->mPhysicalSize = QSize(physWidth, physHeight); - // Create a QImage directly on the screen's framebuffer. // This is the blit target for copying windows to the screen. - mPrimaryScreen->mScreenImage = new QImage(data, w, h, lstep, screenFormat); + mPrimaryScreen = new QLinuxFbGraphicsSystemScreen(data, w, h, lstep, + screenFormat); + mPrimaryScreen->setPhysicalSize(QSize(physWidth, physHeight)); mScreens.append(mPrimaryScreen); } @@ -791,7 +789,57 @@ QWindowSurface *QLinuxFbGraphicsSystem::createWindowSurface(QWidget *widget) con { if (widget->windowType() == Qt::Desktop) return 0; // Don't create an explicit window surface for the destkop. - return new QLinuxFbWindowSurface(mPrimaryScreen, widget); + QGraphicsSystemFbWindowSurface * surface = + new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); + mPrimaryScreen->addWindowSurface(surface); + return surface; +} + +QLinuxFbGraphicsSystemScreen::QLinuxFbGraphicsSystemScreen(uchar * d, int w, + int h, int lstep, QImage::Format screenFormat) +{ + data = d; + mGeometry = QRect(0,0,w,h); + bytesPerLine = lstep; + mFormat = screenFormat; + mDepth = 16; + mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), + mFormat); + mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), + bytesPerLine, mFormat); +} + +void QLinuxFbGraphicsSystemScreen::setGeometry(QRect rect) +{ + mGeometry = rect; + delete mFbScreenImage; + mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), + bytesPerLine, mFormat); + delete mScreenImage; + mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), + mFormat); +} + +void QLinuxFbGraphicsSystemScreen::setFormat(QImage::Format format) +{ + mFormat = format; + delete mFbScreenImage; + mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), + bytesPerLine, mFormat); + delete mScreenImage; + mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), + mFormat); } +QRegion QLinuxFbGraphicsSystemScreen::doRedraw() +{ + QRegion touched; + touched = QGraphicsSystemFbScreen::doRedraw(); + + QPainter compositePainter(mFbScreenImage); + QVector rects = touched.rects(); + for (int i = 0; i < rects.size(); i++) + compositePainter.drawImage(rects[i], *mScreenImage, rects[i]); + return touched; +} QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h index 7ceaf037..f85718a 100644 --- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h +++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h @@ -43,28 +43,24 @@ #define QGRAPHICSSYSTEM_LINUXFB_H #include +#include "../fb_base/fb_base.h" QT_BEGIN_NAMESPACE -class QLinuxFbGraphicsSystemScreen : public QGraphicsSystemScreen +class QLinuxFbGraphicsSystemScreen : public QGraphicsSystemFbScreen { public: - QLinuxFbGraphicsSystemScreen() - : mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0) {} - ~QLinuxFbGraphicsSystemScreen() { delete mScreenImage; } + QLinuxFbGraphicsSystemScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat); + void setGeometry(QRect rect); + void setFormat(QImage::Format format); - QRect geometry() const { return mGeometry; } - int depth() const { return mDepth; } - QImage::Format format() const { return mFormat; } - QSize physicalSize() const { return mPhysicalSize; } - -public: - QRect mGeometry; - int mDepth; - QImage::Format mFormat; - QSize mPhysicalSize; - QImage *mScreenImage; +public slots: + QRegion doRedraw(); +private: + QImage * mFbScreenImage; + uchar * data; + int bytesPerLine; }; class QLinuxFbGraphicsSystemPrivate; diff --git a/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp deleted file mode 100644 index dbe5dd7..0000000 --- a/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindowsurface_linuxfb.h" -#include "qgraphicssystem_linuxfb.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QLinuxFbWindowSurface::QLinuxFbWindowSurface - (QLinuxFbGraphicsSystemScreen *screen, QWidget *window) - : QWindowSurface(window), - mScreen(screen) -{ -} - -QLinuxFbWindowSurface::~QLinuxFbWindowSurface() -{ -} - -QPaintDevice *QLinuxFbWindowSurface::paintDevice() -{ - return &mImage; -} - -void QLinuxFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(offset); - - QRect rect = geometry(); - QPoint topLeft = rect.topLeft(); - - QPainter painter(mScreen->mScreenImage); - if (region.numRects() == 1) { - QRect wrect = region.boundingRect(); - painter.drawImage(wrect.topLeft() + topLeft, mImage, wrect); - } else { - QVector rects = region.rects(); - foreach (QRect wrect, rects) - painter.drawImage(wrect.topLeft() + topLeft, mImage, wrect); - } -} - -void QLinuxFbWindowSurface::setGeometry(const QRect &r) -{ -#ifdef QT_LITE_FORCE_FULLSCREEN -// any size you like as long as it's full-screen... - QRect rect(mScreen->availableGeometry()); - QApplicationPrivate::handleGeometryChange(this->window(), rect); -#else - QRect rect(r); -#endif - QWindowSurface::setGeometry(rect); - if (mImage.size() != rect.size()) - mImage = QImage(rect.size(), mScreen->format()); -} - -bool QLinuxFbWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - return QWindowSurface::scroll(area, dx, dy); -} - -void QLinuxFbWindowSurface::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -void QLinuxFbWindowSurface::endPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h b/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h deleted file mode 100644 index 37efcb0..0000000 --- a/src/plugins/graphicssystems/linuxfb/qwindowsurface_linuxfb.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_LINUXFB_H -#define QWINDOWSURFACE_LINUXFB_H - -#include - -QT_BEGIN_NAMESPACE - -class QLinuxFbGraphicsSystemScreen; - -class QLinuxFbWindowSurface : public QWindowSurface -{ -public: - QLinuxFbWindowSurface - (QLinuxFbGraphicsSystemScreen *screen, QWidget *window); - ~QLinuxFbWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - -private: - QLinuxFbGraphicsSystemScreen *mScreen; - QImage mImage; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp index 98e994c..7815f24 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp @@ -40,7 +40,8 @@ ****************************************************************************/ #include "qgraphicssystem_vnc.h" -#include "qwindowsurface_vnc.h" +#include "../fb_base/fb_base.h" +#include #include #include @@ -49,12 +50,9 @@ #include -#include - -#include "qvnccursor.h" QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() - : mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0) + : QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() { int w = 800; int h = 600; @@ -65,32 +63,16 @@ QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() h = eh; } - mGeometry = QRect(0,0,w, h); - - mDepth = 32; - mFormat = QImage::Format_RGB32; - mPhysicalSize = (mGeometry.size()*254)/720; + setGeometry(QRect(0,0,w, h)); + setDepth(32); + setFormat(QImage::Format_RGB32); + setPhysicalSize((geometry().size()*254)/720); - mScreenImage = new QImage(mGeometry.size(), mFormat); d_ptr = new QVNCGraphicsSystemScreenPrivate(this); - helper = new QVNCGraphicsSystemScreenTimerHelper(this); - repaintTimer = new QTimer(); - repaintTimer->setSingleShot(true); - repaintTimer->setInterval(0); - QObject::connect(repaintTimer, SIGNAL(timeout()), helper, SLOT(fireSlot())); - cursor = new QVNCCursor(d_ptr->vncServer, this); - d_ptr->vncServer->setCursor(cursor); -} - - -QVNCGraphicsSystemScreen::~QVNCGraphicsSystemScreen() -{ - delete mScreenImage; - delete repaintTimer; - delete helper; + d_ptr->vncServer->setCursor(static_cast(cursor)); } QVNCDirtyMap *QVNCGraphicsSystemScreen::dirtyMap() @@ -98,67 +80,22 @@ QVNCDirtyMap *QVNCGraphicsSystemScreen::dirtyMap() return d_ptr->dirty; } - -void QVNCGraphicsSystemScreen::setDirty(const QRect &rect) -{ - repaintRegion += rect; - if (!repaintTimer->isActive()) { - repaintTimer->start(); - } -} - -void QVNCGraphicsSystemScreen::doRedraw() +QRegion QVNCGraphicsSystemScreen::doRedraw() { - repaintRegion += cursor->dirtyRect(); - - if (repaintRegion.isEmpty()) - return; - - QPainter compositePainter(mScreenImage); - - QVector rects = repaintRegion.rects(); - - for (int rectIndex = 0; rectIndex < repaintRegion.numRects(); rectIndex++) { - QRect rect = rects[rectIndex]; - // Blank the affected area, just in case there's nothing to display - // Question - What's the background color? - // Another option - a base level window that is the size of the display - compositePainter.fillRect(rect, Qt::black); - for (int i = 0; i < windowStack.length(); i++) { - if (!windowStack[i]->visible()) - continue; - QRect windowRect = windowStack[i]->geometry(); - QRect intersect = windowRect.intersected(rect); - QRect windowIntersect = intersect.translated(-windowRect.left(), - -windowRect.top()); - if (intersect.isNull()) - continue; - compositePainter.drawImage(intersect, windowStack[i]->image(), - windowIntersect); - } - } + QRegion touched; + touched = QGraphicsSystemFbScreen::doRedraw(); - QRect pointerRect = cursor->drawCursor(compositePainter); - repaintRegion += pointerRect; - rects = repaintRegion.rects(); - for (int i = 0; i < rects.size(); i ++) + QVector rects = touched.rects(); + for (int i = 0; i < rects.size(); i++) d_ptr->setDirty(rects[i]); - - repaintRegion = QRegion(); + return touched; } QVNCGraphicsSystem::QVNCGraphicsSystem() { -//////// xd = new MyDisplay; - mPrimaryScreen = new QVNCGraphicsSystemScreen(); - - //int dw = mPrimaryScreen->geometry().width(); - //int dh = mPrimaryScreen->geometry().height(); - - mScreens.append(mPrimaryScreen); } @@ -171,19 +108,8 @@ QWindowSurface *QVNCGraphicsSystem::createWindowSurface(QWidget *widget) const { if (widget->windowType() == Qt::Desktop) return 0; // Don't create an explicit window surface for the destkop. - QVNCWindowSurface * newSurface = new QVNCWindowSurface - (const_cast(this), mPrimaryScreen, widget); - mPrimaryScreen->addWindowSurface(newSurface); - return newSurface; -} - -void QVNCGraphicsSystemScreen::removeWindowSurface(QVNCWindowSurface * surface) -{ - windowStack.removeOne(surface); - setDirty(surface->geometry()); -} - -void QVNCGraphicsSystemScreen::pointerEvent(QMouseEvent & me) -{ - QApplicationPrivate::handleMouseEvent(0, me); + QGraphicsSystemFbWindowSurface * surface; + surface = new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); + mPrimaryScreen->addWindowSurface(surface); + return surface; } diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h index eb48f86..b3349b7 100644 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h +++ b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h @@ -43,8 +43,8 @@ #define QGRAPHICSSYSTEM_VNC_H #include -#include "qwindowsurface_vnc.h" #include "qvnccursor.h" +#include "../fb_base/fb_base.h" QT_BEGIN_NAMESPACE @@ -53,57 +53,21 @@ class QVNCDirtyMap; class QVNCGraphicsSystemScreenPrivate; -class QVNCGraphicsSystemScreenTimerHelper; - -class QVNCGraphicsSystemScreen : public QGraphicsSystemScreen +class QVNCGraphicsSystemScreen : public QGraphicsSystemFbScreen { public: QVNCGraphicsSystemScreen(); - ~QVNCGraphicsSystemScreen(); - - QRect geometry() const { return mGeometry; } - int depth() const { return mDepth; } - QImage::Format format() const { return mFormat; } - QSize physicalSize() const { return mPhysicalSize; } - int linestep() const { return mScreenImage ? mScreenImage->bytesPerLine() : 0; } - uchar *base() const { return mScreenImage ? mScreenImage->bits() : 0; } - QVNCDirtyMap *dirtyMap(); - - void setDirty(const QRect &rect); - void removeWindowSurface(QVNCWindowSurface * surface); - void addWindowSurface(QVNCWindowSurface * surface) { windowStack.append(surface); } - void pointerEvent(QMouseEvent & me); + int linestep() const { return image() ? image()->bytesPerLine() : 0; } + uchar *base() const { return image() ? image()->bits() : 0; } + QVNCDirtyMap *dirtyMap(); public: - QRect mGeometry; - int mDepth; - QImage::Format mFormat; - QSize mPhysicalSize; - QImage *mScreenImage; - QVNCGraphicsSystemScreenPrivate *d_ptr; -private: - QList windowStack; - QRegion repaintRegion; - QTimer * repaintTimer; - QVNCGraphicsSystemScreenTimerHelper * helper; - void doRedraw(); - friend class QVNCGraphicsSystemScreenTimerHelper; - - QVNCCursor * cursor; -}; -class QVNCGraphicsSystemScreenTimerHelper : public QObject -{ - Q_OBJECT -public: - QVNCGraphicsSystemScreenTimerHelper(QVNCGraphicsSystemScreen * s) - { screen = s; } -public slots: - void fireSlot() { screen->doRedraw(); } private: - QVNCGraphicsSystemScreen * screen; + QVNCServer *server; + QRegion doRedraw(); }; class QVNCGraphicsSystemPrivate; diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.cpp b/src/plugins/graphicssystems/vnc/qvnccursor.cpp index 111ee3c..ec9a4ee 100644 --- a/src/plugins/graphicssystems/vnc/qvnccursor.cpp +++ b/src/plugins/graphicssystems/vnc/qvnccursor.cpp @@ -54,16 +54,14 @@ QT_BEGIN_NAMESPACE QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCGraphicsSystemScreen *scr ) - :useVncCursor(false), currentRect(QRect()), - prevRect(QRect()), server(srvr), screen(scr) + :QGraphicsSystemCursor::QGraphicsSystemCursor(scr), useVncCursor(false), server(srvr) { - d_ptr = new QVNCCursorPrivate(0, 0, 0, 0, 0, 0); } void QVNCCursor::setCursorMode(bool vnc) { - if (vnc == useVncCursor) - return; +// if (vnc == useVncCursor) +// return; if (vnc) { screen->setDirty(prevRect); prevRect = QRect(); @@ -76,7 +74,7 @@ void QVNCCursor::setCursorMode(bool vnc) void QVNCCursor::setCursor(Qt::CursorShape shape) { - d_ptr->set(shape); + QGraphicsSystemCursor::setCursor(shape); if (useVncCursor) { sendClientCursor(); } @@ -84,22 +82,12 @@ void QVNCCursor::setCursor(Qt::CursorShape shape) void QVNCCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) { - d_ptr->set(data, mask, width, height, hotX, hotY); + QGraphicsSystemCursor::setCursor(data, mask, width, height, hotX, hotY); if (useVncCursor) { sendClientCursor(); } } -QRect QVNCCursor::dirtyRect() -{ - if (!useVncCursor) { - QRect rect = prevRect; - prevRect = QRect(); - return rect; - } - return QRect(); -} - QRect QVNCCursor::drawCursor(QPainter & painter) { if (useVncCursor) @@ -108,54 +96,11 @@ QRect QVNCCursor::drawCursor(QPainter & painter) if (currentRect.isNull()) return QRect(); - prevRect = currentRect; - painter.drawImage(prevRect, *d_ptr->image()); - return prevRect; -} - -void QVNCCursor::pointerEvent(QMouseEvent & e) -{ - QWidget *widget = QApplication::widgetAt(e.pos()); - - // Determine which cursor to use - if (currentWidget != widget) { - if (widget) { - QCursor widgetCursor = widget->cursor(); - Qt::CursorShape shape = widgetCursor.shape(); - - if (shape == Qt::BitmapCursor) { - // application supplied cursor - const QBitmap * map = widgetCursor.bitmap(); - const QBitmap * mask = widgetCursor.mask(); - QPoint spot = widgetCursor.hotSpot(); - setCursor(map->toImage().bits(), mask->toImage().bits(), map->width(), map->height(), spot.x(), spot.y()); - } else { - // system cursor - setCursor(shape); - } - } else { - // default cursor - setCursor(Qt::ArrowCursor); - } - currentWidget = widget; - } else if (!widget) { - // default cursor - setCursor(Qt::ArrowCursor); - } - if (!useVncCursor) { - currentRect = d_ptr->image()->rect().translated(-d_ptr->hotspot().x(), -d_ptr->hotspot().y()); - currentRect.translate(e.pos()); - screen->setDirty(QRect()); - } - - screen->pointerEvent(e); + return QGraphicsSystemCursor::drawCursor(painter); } void QVNCCursor::clearClientCursor() { - QImage *image = d_ptr->image(); - if (image->isNull()) - return; QTcpSocket *socket = server->clientSocket(); if (!socket) { return; @@ -176,7 +121,7 @@ void QVNCCursor::clearClientCursor() void QVNCCursor::sendClientCursor() { - QImage *image = d_ptr->image(); + QImage *image = graphic->image(); if (image->isNull()) return; QTcpSocket *socket = server->clientSocket(); @@ -187,7 +132,7 @@ void QVNCCursor::sendClientCursor() { const quint16 tmp[6] = { htons(0), htons(1), - htons(d_ptr->hotspot().x()), htons(d_ptr->hotspot().y()), + htons(graphic->hotspot().x()), htons(graphic->hotspot().y()), htons(image->width()), htons(image->height()) }; socket->write((char*)tmp, sizeof(tmp)); @@ -216,474 +161,4 @@ void QVNCCursor::sendClientCursor() socket->write((const char*)bitmap.scanLine(i), width); } -// End of display and pointer event handling code -// Beginning of built-in cursor graphics -// from src/gui/embedded/QVNCCursorPrivate_qws.cpp - -static QVNCCursorPrivate *systemCursorTable[Qt::LastCursor+1]; -static bool systemCursorTableInit = false; - -// 16 x 16 -static const uchar cur_arrow_bits[] = { - 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08, - 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22, - 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 }; -static const uchar mcur_arrow_bits[] = { - 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f, - 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e, - 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 }; - -static const unsigned char cur_up_arrow_bits[] = { - 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, - 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01}; -static const unsigned char mcur_up_arrow_bits[] = { - 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07, - 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01}; - -static const unsigned char cur_cross_bits[] = { - 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00}; -static const unsigned char mcur_cross_bits[] = { - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; - -static const uchar cur_ibeam_bits[] = { - 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, - 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, - 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_ibeam_bits[] = { - 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 }; - -static const uchar cur_ver_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, - 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, - 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; -static const uchar mcur_ver_bits[] = { - 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, - 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, - 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; - -static const uchar cur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, - 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, - 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, - 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; -static const uchar cur_bdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, - 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, - 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_bdiag_bits[] = { - 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, - 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, - 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; -static const uchar cur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, - 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, - 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, - 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, - 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; -static const uchar cur_blank_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -// 20 x 20 -static const uchar forbidden_bits[] = { - 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, - 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, - 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, - 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; - -static const uchar forbiddenm_bits[] = { - 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, - 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, - 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, - 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; - -// 32 x 32 -static const uchar wait_data_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00, - 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, - 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00, - 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, - 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00, - 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar wait_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, - 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00, - 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar hsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, - 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar hsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, - 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, - 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, - 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar vsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar vsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar phand_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, - 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00, - 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, - 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar phandm_bits[] = { - 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, - 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, - 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, - 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, - 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar size_all_data_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00, - 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar size_all_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00, - 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01, - 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00, - 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar whatsthis_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, - 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, - 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, - 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, - 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, - 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -static const uchar whatsthism_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, - 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, - 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, - 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, - 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, - 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - -static const uchar busy_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, - 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, - 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, - 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, - 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static const uchar busym_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, - 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, - 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, - 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, - 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, - 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -// 16 x 16 -static const uchar openhand_bits[] = { - 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, - 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, - 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; -static const uchar openhandm_bits[] = { - 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, - 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, - 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; -static const uchar closedhand_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, - 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, - 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; -static const uchar closedhandm_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, - 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, - 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; - -void QVNCCursorPrivate::createSystemCursor(int id) -{ - if (!systemCursorTableInit) { - for (int i = 0; i <= Qt::LastCursor; i++) - systemCursorTable[i] = 0; - systemCursorTableInit = true; - } - switch (id) { - // 16x16 cursors - case Qt::ArrowCursor: - systemCursorTable[Qt::ArrowCursor] = - new QVNCCursorPrivate(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0); - break; - - case Qt::UpArrowCursor: - systemCursorTable[Qt::UpArrowCursor] = - new QVNCCursorPrivate(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0); - break; - - case Qt::CrossCursor: - systemCursorTable[Qt::CrossCursor] = - new QVNCCursorPrivate(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7); - break; - - case Qt::IBeamCursor: - systemCursorTable[Qt::IBeamCursor] = - new QVNCCursorPrivate(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7); - break; - - case Qt::SizeVerCursor: - systemCursorTable[Qt::SizeVerCursor] = - new QVNCCursorPrivate(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7); - break; - - case Qt::SizeHorCursor: - systemCursorTable[Qt::SizeHorCursor] = - new QVNCCursorPrivate(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7); - break; - - case Qt::SizeBDiagCursor: - systemCursorTable[Qt::SizeBDiagCursor] = - new QVNCCursorPrivate(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7); - break; - - case Qt::SizeFDiagCursor: - systemCursorTable[Qt::SizeFDiagCursor] = - new QVNCCursorPrivate(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7); - break; - - case Qt::BlankCursor: - systemCursorTable[Qt::BlankCursor] = - new QVNCCursorPrivate(0, 0, 0, 0, 0, 0); - break; - - // 20x20 cursors - case Qt::ForbiddenCursor: - systemCursorTable[Qt::ForbiddenCursor] = - new QVNCCursorPrivate(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10); - break; - - // 32x32 cursors - case Qt::WaitCursor: - systemCursorTable[Qt::WaitCursor] = - new QVNCCursorPrivate(wait_data_bits, wait_mask_bits, 32, 32, 15, 15); - break; - - case Qt::SplitVCursor: - systemCursorTable[Qt::SplitVCursor] = - new QVNCCursorPrivate(vsplit_bits, vsplitm_bits, 32, 32, 15, 15); - break; - - case Qt::SplitHCursor: - systemCursorTable[Qt::SplitHCursor] = - new QVNCCursorPrivate(hsplit_bits, hsplitm_bits, 32, 32, 15, 15); - break; - - case Qt::SizeAllCursor: - systemCursorTable[Qt::SizeAllCursor] = - new QVNCCursorPrivate(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15); - break; - - case Qt::PointingHandCursor: - systemCursorTable[Qt::PointingHandCursor] = - new QVNCCursorPrivate(phand_bits, phandm_bits, 32, 32, 0, 0); - break; - - case Qt::WhatsThisCursor: - systemCursorTable[Qt::WhatsThisCursor] = - new QVNCCursorPrivate(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0); - break; - case Qt::BusyCursor: - systemCursorTable[Qt::BusyCursor] = - new QVNCCursorPrivate(busy_bits, busym_bits, 32, 32, 0, 0); - break; - - case Qt::OpenHandCursor: - systemCursorTable[Qt::OpenHandCursor] = - new QVNCCursorPrivate(openhand_bits, openhandm_bits, 16, 16, 8, 8); - break; - case Qt::ClosedHandCursor: - systemCursorTable[Qt::ClosedHandCursor] = - new QVNCCursorPrivate(closedhand_bits, closedhandm_bits, 16, 16, 8, 8); - break; - default: - qWarning("Unknown system cursor %d", id); - } -} - -void QVNCCursorPrivate::set(Qt::CursorShape id) -{ - QVNCCursorPrivate *cursor = 0; - if (id >= 0 && id <= Qt::LastCursor) { - if (!systemCursorTable[id]) - createSystemCursor(id); - cursor = systemCursorTable[id]; - } - - if (cursor == 0) { - if (!systemCursorTable[Qt::ArrowCursor]) - createSystemCursor(Qt::ArrowCursor); - cursor = systemCursorTable[Qt::ArrowCursor]; - } - cursorImage = cursor->cursorImage; - hot = cursor->hot; -} - -void QVNCCursorPrivate::set(const uchar *data, const uchar *mask, - int width, int height, int hx, int hy) -{ - hot.setX(hx); - hot.setY(hy); - - cursorImage = QImage(width,height, QImage::Format_Indexed8); - - if (!width || !height || !data || !mask || cursorImage.isNull()) - return; - - cursorImage.setNumColors(3); - cursorImage.setColor(0, 0xff000000); - cursorImage.setColor(1, 0xffffffff); - cursorImage.setColor(2, 0x00000000); - - int bytesPerLine = (width + 7) / 8; - int p = 0; - int d, m; - - int x = -1, w = 0; - - uchar *cursor_data = cursorImage.bits(); - int bpl = cursorImage.bytesPerLine(); - for (int i = 0; i < height; i++) - { - for (int j = 0; j < bytesPerLine; j++, data++, mask++) - { - for (int b = 0; b < 8 && j*8+b < width; b++) - { - d = *data & (1 << b); - m = *mask & (1 << b); - if (d && m) p = 0; - else if (!d && m) p = 1; - else p = 2; - cursor_data[j*8+b] = p; - - // calc region - if (x < 0 && m) - x = j*8+b; - else if (x >= 0 && !m) { - x = -1; - w = 0; - } - if (m) - w++; - } - } - if (x >= 0) { - x = -1; - w = 0; - } - cursor_data += bpl; - } - -} - QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.h b/src/plugins/graphicssystems/vnc/qvnccursor.h index 1c0ce8a..1a53da7 100644 --- a/src/plugins/graphicssystems/vnc/qvnccursor.h +++ b/src/plugins/graphicssystems/vnc/qvnccursor.h @@ -41,6 +41,7 @@ #ifndef QVNCCURSOR_H #define QVNCCURSOR_H +#include "qgraphicssystemcursor.h" #include #include #include @@ -50,22 +51,7 @@ QT_BEGIN_NAMESPACE class QVNCGraphicsSystemScreen; class QVNCServer; -// Cursor graphics management -class QVNCCursorPrivate { -public: - QVNCCursorPrivate(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) - { set(data, mask, width, height, hotX, hotY); } - QImage * image() { return &cursorImage; } - QPoint hotspot() { return hot; } - QImage cursorImage; - QPoint hot; - void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); - void set(Qt::CursorShape); -private: - static void createSystemCursor(int id); -}; - -class QVNCCursor { +class QVNCCursor : public QGraphicsSystemCursor { public: QVNCCursor(QVNCServer *, QVNCGraphicsSystemScreen *); @@ -73,11 +59,9 @@ public: void setCursorMode(bool vnc); void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); void setCursor(Qt::CursorShape shape); - void pointerEvent(QMouseEvent & event); // output methods QRect drawCursor(QPainter &); - QRect dirtyRect(); // VNC client communication void sendClientCursor(); @@ -85,14 +69,7 @@ public: private: bool useVncCursor; // VNC or local - QRect currentRect; // next place to draw the cursor - QRect prevRect; // last place the cursor was drawn - QVNCServer * server; // VNC server to get events from - QVNCGraphicsSystemScreen * screen; // Where to request an update - QWidget * currentWidget; // widget currently under the cursor - - QVNCCursorPrivate * d_ptr; }; QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp index ad20eec..fd66f47 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -680,6 +680,7 @@ void QVNCServer::setEncodings() }; supportCursor = false; + if (encodingsPending && (unsigned)client->bytesAvailable() >= encodingsPending * sizeof(quint32)) { for (int i = 0; i < encodingsPending; ++i) { @@ -783,6 +784,7 @@ void QVNCServer::setEncodings() qDebug("QVNCServer::setEncodings: fallback using raw"); #endif } + if (cursor) cursor->setCursorMode(supportCursor); } @@ -833,10 +835,8 @@ void QVNCServer::pointerEvent() if (buttonChange(buttons, ev.buttons, &button, &isPress)) type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; QMouseEvent me(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); - if (cursor) + if(cursor) cursor->pointerEvent(me); - else - QApplicationPrivate::handleMouseEvent(0, me); buttons = ev.buttons; handleMsg = false; } @@ -1827,7 +1827,7 @@ void QRfbRawEncoder::write() inline QImage *QVNCServer::screenImage() const { - return qvnc_screen->mScreenImage; + return qvnc_screen->image(); } void QVNCServer::checkUpdate() diff --git a/src/plugins/graphicssystems/vnc/qvncserver.h b/src/plugins/graphicssystems/vnc/qvncserver.h index 351c094..79b2098 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.h +++ b/src/plugins/graphicssystems/vnc/qvncserver.h @@ -54,6 +54,7 @@ // #include "qgraphicssystem_vnc.h" +#include "qvnccursor.h" #define QT_NO_QWS_CURSOR #ifndef QT_NO_QWS_VNC @@ -466,7 +467,7 @@ public: inline bool hasClientCursor() const { return qvnc_cursor != 0; } #endif - void setCursor(QVNCCursor *c) { cursor = c; } + void setCursor(QVNCCursor * c) { cursor = c; } private: void setPixelFormat(); void setEncodings(); @@ -517,7 +518,7 @@ private: #endif QRfbEncoder *encoder; - QVNCCursor * cursor; + QVNCCursor *cursor; }; diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp deleted file mode 100644 index 24ae846..0000000 --- a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qwindowsurface_vnc.h" -#include "qgraphicssystem_vnc.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QVNCWindowSurface::QVNCWindowSurface(QVNCGraphicsSystem *graphicsSystem, - QVNCGraphicsSystemScreen *screen, QWidget *window) - : QWindowSurface(window), - mScreen(screen), - visibleFlag(false) -{ - Q_UNUSED(graphicsSystem); - mImage = QImage(window->size(), mScreen->format()); -} - -QVNCWindowSurface::~QVNCWindowSurface() -{ - mScreen->removeWindowSurface(this); -} - -QPaintDevice *QVNCWindowSurface::paintDevice() -{ - return &mImage; -} - -void QVNCWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(offset); - - QRect currentGeometry = geometry(); - // If this is a move, redraw the previous location - if (oldGeometry != currentGeometry) { - mScreen->setDirty(oldGeometry); - oldGeometry = currentGeometry; - } - - QRect dirtyClient = region.boundingRect(); - QRect dirtyRegion(currentGeometry.left() + dirtyClient.left(), - currentGeometry.top() + dirtyClient.top(), - dirtyClient.width(), - dirtyClient.height()); - mScreen->setDirty(dirtyRegion); -} - -void QVNCWindowSurface::setGeometry(const QRect &rect) -{ - // store previous geometry for screen update - oldGeometry = geometry(); - - // change the widget's QImage if this is a resize - if (mImage.size() != rect.size()) - mImage = QImage(rect.size(), mScreen->format()); - - QApplicationPrivate::handleGeometryChange(this->window(), rect); - - QWindowSurface::setGeometry(rect); -} - -bool QVNCWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - return QWindowSurface::scroll(area, dx, dy); -} - -void QVNCWindowSurface::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -void QVNCWindowSurface::endPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -void QVNCWindowSurface::setVisible(bool visible) -{ - visibleFlag = visible; - mScreen->setDirty(geometry()); -} -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h b/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h deleted file mode 100644 index 477fe1b..0000000 --- a/src/plugins/graphicssystems/vnc/qwindowsurface_vnc.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_VNC_H -#define QWINDOWSURFACE_VNC_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QVNCGraphicsSystem; -class QVNCGraphicsSystemScreen; - -class QVNCWindowSurface : public QWindowSurface -{ -public: - QVNCWindowSurface(QVNCGraphicsSystem *graphicsSystem, - QVNCGraphicsSystemScreen *screen, QWidget *window); - ~QVNCWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - inline const QImage image() { return mImage; } - void setVisible(bool visible); - bool visible() { return visibleFlag; } -private: - QVNCGraphicsSystem *mGraphicsSystem; - QVNCGraphicsSystemScreen *mScreen; - QRect oldGeometry; - QImage mImage; - bool visibleFlag; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/vnc/vnc.pro b/src/plugins/graphicssystems/vnc/vnc.pro index 69cd1f7..aecb371 100644 --- a/src/plugins/graphicssystems/vnc/vnc.pro +++ b/src/plugins/graphicssystems/vnc/vnc.pro @@ -3,10 +3,8 @@ include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - - -SOURCES = main.cpp qgraphicssystem_vnc.cpp qwindowsurface_vnc.cpp -HEADERS = qgraphicssystem_vnc.h qwindowsurface_vnc.h +SOURCES = main.cpp qgraphicssystem_vnc.cpp +HEADERS = qgraphicssystem_vnc.h HEADERS += qvncserver.h SOURCES += qvncserver.cpp @@ -15,4 +13,7 @@ HEADERS += qvnccursor.h SOURCES += qvnccursor.cpp target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems + +LIBS += -L$$[QT_INSTALL_PLUGINS]/graphicssystems -lfb_base + INSTALLS += target -- cgit v0.12 From fc0c5aa573d834041b9ea164fc4b19eda7e66ab7 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 11 Nov 2009 13:55:00 +0100 Subject: include fb_base code using fb_base.pri, rather than as a library --- src/plugins/graphicssystems/fb_base/fb_base.pri | 2 ++ src/plugins/graphicssystems/linuxfb/linuxfb.pro | 3 ++- src/plugins/graphicssystems/vnc/vnc.pro | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 src/plugins/graphicssystems/fb_base/fb_base.pri diff --git a/src/plugins/graphicssystems/fb_base/fb_base.pri b/src/plugins/graphicssystems/fb_base/fb_base.pri new file mode 100644 index 0000000..41bd87f --- /dev/null +++ b/src/plugins/graphicssystems/fb_base/fb_base.pri @@ -0,0 +1,2 @@ +SOURCES += ../fb_base/fb_base.cpp +HEADERS += ../fb_base/fb_base.h diff --git a/src/plugins/graphicssystems/linuxfb/linuxfb.pro b/src/plugins/graphicssystems/linuxfb/linuxfb.pro index ea92573..031b843 100644 --- a/src/plugins/graphicssystems/linuxfb/linuxfb.pro +++ b/src/plugins/graphicssystems/linuxfb/linuxfb.pro @@ -6,6 +6,7 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems SOURCES = main.cpp qgraphicssystem_linuxfb.cpp HEADERS = qgraphicssystem_linuxfb.h +include(../fb_base/fb_base.pri) + target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -LIBS += -L$$[QT_INSTALL_PLUGINS]/graphicssystems -lfb_base INSTALLS += target diff --git a/src/plugins/graphicssystems/vnc/vnc.pro b/src/plugins/graphicssystems/vnc/vnc.pro index aecb371..0b73b5b 100644 --- a/src/plugins/graphicssystems/vnc/vnc.pro +++ b/src/plugins/graphicssystems/vnc/vnc.pro @@ -12,8 +12,8 @@ SOURCES += qvncserver.cpp HEADERS += qvnccursor.h SOURCES += qvnccursor.cpp -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +include(../fb_base/fb_base.pri) -LIBS += -L$$[QT_INSTALL_PLUGINS]/graphicssystems -lfb_base +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems INSTALLS += target -- cgit v0.12 From f50552ccfbe9a71d798d00a2d963898c98654256 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 11 Nov 2009 14:08:41 +0100 Subject: send client cursor via QVNCServer checkUpdate(), rather than asynchronously --- src/plugins/graphicssystems/vnc/qvnccursor.cpp | 12 ++++++++---- src/plugins/graphicssystems/vnc/qvncserver.cpp | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.cpp b/src/plugins/graphicssystems/vnc/qvnccursor.cpp index ec9a4ee..80ab750 100644 --- a/src/plugins/graphicssystems/vnc/qvnccursor.cpp +++ b/src/plugins/graphicssystems/vnc/qvnccursor.cpp @@ -65,9 +65,9 @@ void QVNCCursor::setCursorMode(bool vnc) if (vnc) { screen->setDirty(prevRect); prevRect = QRect(); - sendClientCursor(); + server->setDirtyCursor(); } else { - clearClientCursor(); + server->setDirtyCursor(); } useVncCursor = vnc; } @@ -76,7 +76,7 @@ void QVNCCursor::setCursor(Qt::CursorShape shape) { QGraphicsSystemCursor::setCursor(shape); if (useVncCursor) { - sendClientCursor(); + server->setDirtyCursor(); } } @@ -84,7 +84,7 @@ void QVNCCursor::setCursor(const uchar *data, const uchar *mask, int width, int { QGraphicsSystemCursor::setCursor(data, mask, width, height, hotX, hotY); if (useVncCursor) { - sendClientCursor(); + server->setDirtyCursor(); } } @@ -121,6 +121,10 @@ void QVNCCursor::clearClientCursor() void QVNCCursor::sendClientCursor() { + if (useVncCursor == false) { + clearClientCursor(); + return; + } QImage *image = graphic->image(); if (image->isNull()) return; diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp index fd66f47..ef6b4a1 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -1840,6 +1840,7 @@ void QVNCServer::checkUpdate() Q_ASSERT(qvnc_cursor); qvnc_cursor->write(); #endif + cursor->sendClientCursor(); dirtyCursor = false; wantUpdate = false; return; -- cgit v0.12 From 3ca4be160028e042691fb990ed57126add3a5448 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 12 Nov 2009 15:39:45 +0100 Subject: Support for override cursors, and fixed cursor change without a widget enter/leave --- src/gui/kernel/qapplication_lite.cpp | 10 +++++++--- src/gui/kernel/qwidget_lite.cpp | 16 +++++++++++++--- src/gui/painting/qgraphicssystemcursor.cpp | 29 +++++++++++++++++------------ src/gui/painting/qgraphicssystemcursor.h | 1 + 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 0ddcfab..061ac5b 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -336,14 +336,18 @@ bool QApplication::isEffectEnabled(Qt::UIEffect effect) } #ifndef QT_NO_CURSOR -void QApplication::setOverrideCursor(const QCursor &) +void QApplication::setOverrideCursor(const QCursor &cursor) { - // XXX + qApp->d_func()->cursor_list.prepend(cursor); + qt_lite_set_cursor(0, false); } void QApplication::restoreOverrideCursor() { - // XXX + if (qApp->d_func()->cursor_list.isEmpty()) + return; + qApp->d_func()->cursor_list.removeFirst(); + qt_lite_set_cursor(0, false); } #endif// QT_NO_CURSOR diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index a4d60a7..6a579ad 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -167,14 +167,14 @@ void QWidgetPrivate::setCursor_sys(const QCursor &cursor) Q_UNUSED(cursor); Q_Q(QWidget); if (q->isVisible()) - updateCursor(); + qt_lite_set_cursor(q, false); } void QWidgetPrivate::unsetCursor_sys() { Q_Q(QWidget); if (q->isVisible()) - updateCursor(); + qt_lite_set_cursor(q, false); } void QWidgetPrivate::updateCursor() const @@ -652,7 +652,16 @@ void QWidgetPrivate::setModal_sys() void qt_lite_set_cursor(QWidget * w, bool force) { static QPointer lastUnderMouse = 0; - if (force) { + if (w == 0) { // override cursor stack emptied + QCursor * override = QApplication::overrideCursor(); + if (override) { + if (QGraphicsSystemCursor::instance) { + QGraphicsSystemCursor::instance->changeCursor(override); + } + return; + } + w = QApplication::widgetAt(QCursor::pos()); + } else if (force) { lastUnderMouse = w; } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) { @@ -663,6 +672,7 @@ void qt_lite_set_cursor(QWidget * w, bool force) if (!curWin && w && w->internalWinId()) return; QWidget* cW = w && !w->internalWinId() ? w : curWin; + if (!cW || cW->window() != w->window() || !cW->isVisible() || !cW->underMouse() || QApplication::overrideCursor()) return; diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp index 91a6535..9bf5d02 100644 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -105,22 +105,27 @@ void QGraphicsSystemCursor::pointerEvent(QMouseEvent & e) screen->pointerEvent(e); } +void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor) +{ + Qt::CursorShape shape = widgetCursor->shape(); + + if (shape == Qt::BitmapCursor) { + // application supplied cursor + const QBitmap * map = widgetCursor->bitmap(); + const QBitmap * mask = widgetCursor->mask(); + QPoint spot = widgetCursor->hotSpot(); + setCursor(map->toImage().bits(), mask->toImage().bits(), map->width(), map->height(), spot.x(), spot.y()); + } else { + // system cursor + setCursor(shape); + } +} + void QGraphicsSystemCursor::changeCursor(QWidget * widget) { if (widget) { QCursor widgetCursor = widget->cursor(); - Qt::CursorShape shape = widgetCursor.shape(); - - if (shape == Qt::BitmapCursor) { - // application supplied cursor - const QBitmap * map = widgetCursor.bitmap(); - const QBitmap * mask = widgetCursor.mask(); - QPoint spot = widgetCursor.hotSpot(); - setCursor(map->toImage().bits(), mask->toImage().bits(), map->width(), map->height(), spot.x(), spot.y()); - } else { - // system cursor - setCursor(shape); - } + changeCursor(&widgetCursor); } else { // default cursor setCursor(Qt::ArrowCursor); diff --git a/src/gui/painting/qgraphicssystemcursor.h b/src/gui/painting/qgraphicssystemcursor.h index cb5c471..eab7203 100644 --- a/src/gui/painting/qgraphicssystemcursor.h +++ b/src/gui/painting/qgraphicssystemcursor.h @@ -75,6 +75,7 @@ public: virtual void setCursor(Qt::CursorShape shape); virtual void pointerEvent(QMouseEvent & event); virtual void changeCursor(QWidget * widget); + virtual void changeCursor(QCursor * widgetCursor); // output methods virtual QRect drawCursor(QPainter &); -- cgit v0.12 From 6f22069b01d089ef7151b2d78d56c13c71924b62 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 6 Nov 2009 13:41:17 +0100 Subject: Make tst_QWidget lower() and stackUnder() test functions pass --- src/gui/kernel/qwidget_lite.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 6a579ad..615d4dd 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -419,17 +419,31 @@ void QWidgetPrivate::setFocus_sys() void QWidgetPrivate::raise_sys() { - // XXX + Q_Q(QWidget); + if (q->isWindow()) { + qWarning() << "raise_sys not implemented for tlw" << q; + } } void QWidgetPrivate::lower_sys() { - // XXX + Q_Q(QWidget); + if (q->isWindow()) { + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); + qWarning() << "lower_sys not implemented for tlw" << q; + } else if (QWidget *p = q->parentWidget()) { + setDirtyOpaqueRegion(); + p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); + } } void QWidgetPrivate::stackUnder_sys(QWidget*) { - // XXX + Q_Q(QWidget); + if (QWidget *p = q->parentWidget()) { + setDirtyOpaqueRegion(); + p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); + } } void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) -- cgit v0.12 From 9904436eb0f3ebdabfba527fe659f4964af8bf06 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 11 Nov 2009 16:46:55 +0100 Subject: Starting to implement grabWindow() for Lighthouse --- src/gui/image/qpixmap_lite.cpp | 9 +++------ src/gui/painting/qgraphicssystem.cpp | 14 ++++++++++++++ src/gui/painting/qgraphicssystem_p.h | 6 +++++- .../graphicssystems/testlite/qgraphicssystem_testlite.cpp | 8 ++++++++ .../graphicssystems/testlite/qgraphicssystem_testlite.h | 2 ++ 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/gui/image/qpixmap_lite.cpp b/src/gui/image/qpixmap_lite.cpp index 90761ca..d263855 100644 --- a/src/gui/image/qpixmap_lite.cpp +++ b/src/gui/image/qpixmap_lite.cpp @@ -40,13 +40,10 @@ ****************************************************************************/ #include +#include +#include QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) { - Q_UNUSED(window); - Q_UNUSED(x); - Q_UNUSED(y); - Q_UNUSED(w); - Q_UNUSED(h); - return QPixmap(); + return QApplicationPrivate::graphicsSystem()->grabWindow(window, x, y, w, h); } diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp index 1565c45..2071127 100644 --- a/src/gui/painting/qgraphicssystem.cpp +++ b/src/gui/painting/qgraphicssystem.cpp @@ -84,11 +84,23 @@ QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType typ return 0; } +#ifdef Q_WS_LITE QList QGraphicsSystem::screens() const { return QList(); } +QPixmap QGraphicsSystem::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(); +} + + QGraphicsSystemScreen::QGraphicsSystemScreen(QObject *parent) : QObject(parent) {} @@ -102,4 +114,6 @@ QRect QGraphicsSystemScreen::availableGeometry() const return geometry(); } +#endif //Q_WS_LITE + QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index 7cc6247..ddba22d 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE class QPixmapFilter; +#ifdef Q_WS_LITE class Q_GUI_EXPORT QGraphicsSystemScreen : public QObject { Q_OBJECT @@ -75,6 +76,7 @@ public: virtual void setDirty(QRect) { } virtual void pointerEvent(QMouseEvent &) { } }; +#endif // Q_WS_LITE class Q_GUI_EXPORT QGraphicsSystem { @@ -84,8 +86,10 @@ public: virtual ~QGraphicsSystem() = 0; +#ifdef Q_WS_LITE virtual QList screens() const; - + virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; +#endif //### Remove this & change qpixmap.cpp & qbitmap.cpp once every platform is gaurenteed // to have a graphics system. static QPixmapData *createDefaultPixmapData(QPixmapData::PixelType type); diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp index 9cb0424..9991e75 100644 --- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp @@ -77,4 +77,12 @@ QWindowSurface *QTestLiteGraphicsSystem::createWindowSurface(QWidget *widget) co (const_cast(this), mPrimaryScreen, widget); } + +QPixmap QTestLiteGraphicsSystem::grabWindow(WId window, int x, int y, int width, int height) const +{ + qDebug() << "grabWindow" << hex << window << dec<< x << y << width << height; + return QPixmap(); +} + + QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h index ad7f581..b2cd496 100644 --- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h +++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h @@ -75,6 +75,8 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QWindowSurface *createWindowSurface(QWidget *widget) const; + QPixmap grabWindow(WId window, int x, int y, int width, int height) const; + QList screens() const { return mScreens; } MyDisplay *xd; -- cgit v0.12 From 2e3b33c91578e6ec9524b15965449d81e09fb56f Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 13 Nov 2009 16:34:52 +0100 Subject: support raise/lower for widgets that are a lighthouse window --- src/gui/kernel/qwidget_lite.cpp | 9 +++++++-- src/gui/painting/qgraphicssystem_p.h | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 615d4dd..d52d432 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -51,6 +51,7 @@ #include "qgraphicssystemcursor.h" QT_BEGIN_NAMESPACE +static QGraphicsSystemScreen *qt_screenForWidget(const QWidget *w); void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool /*destroyOldWindow*/) { @@ -421,7 +422,9 @@ void QWidgetPrivate::raise_sys() { Q_Q(QWidget); if (q->isWindow()) { - qWarning() << "raise_sys not implemented for tlw" << q; + QWindowSurface *surface = q->windowSurface(); + QGraphicsSystemScreen *screen = qt_screenForWidget(q); + screen->raise(surface); } } @@ -430,7 +433,9 @@ void QWidgetPrivate::lower_sys() Q_Q(QWidget); if (q->isWindow()) { Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - qWarning() << "lower_sys not implemented for tlw" << q; + QWindowSurface *surface = q->windowSurface(); + QGraphicsSystemScreen *screen = qt_screenForWidget(q); + screen->lower(surface); } else if (QWidget *p = q->parentWidget()) { setDirtyOpaqueRegion(); p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index ddba22d..5b5848e 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -75,6 +75,9 @@ public: virtual QSize physicalSize() const = 0; virtual void setDirty(QRect) { } virtual void pointerEvent(QMouseEvent &) { } + + virtual void raise(QWindowSurface *) { qWarning("This plugin does not support raise()"); } + virtual void lower(QWindowSurface *) { qWarning("This plugin does not support lower()"); } }; #endif // Q_WS_LITE -- cgit v0.12 From 9c89de22a012aab0cb8c0be48374896df69f9d2a Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 13 Nov 2009 16:35:52 +0100 Subject: correct the order of window stacking, support raise and lower --- src/plugins/graphicssystems/fb_base/fb_base.cpp | 31 +++++++------------------ src/plugins/graphicssystems/fb_base/fb_base.h | 8 +++---- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index ffa5d4e..c4c009f 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -66,7 +66,7 @@ QRegion QGraphicsSystemFbScreen::doRedraw() QRect rect = rects[rectIndex]; // Blank the affected area, just in case there's nothing to display compositePainter.fillRect(rect, Qt::black); - for (int i = 0; i < windowStack.length(); i++) { + for (int i = windowStack.length() - 1; i >= 0; i--) { if (!windowStack[i]->visible()) continue; QRect windowRect = windowStack[i]->geometry(); @@ -97,39 +97,26 @@ void QGraphicsSystemFbScreen::removeWindowSurface(QGraphicsSystemFbWindowSurface setDirty(surface->geometry()); } -void QGraphicsSystemFbScreen::raise(QGraphicsSystemFbWindowSurface * surface) +void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) { - int index = windowStack.indexOf(surface); + QGraphicsSystemFbWindowSurface *s = static_cast(surface); + int index = windowStack.indexOf(s); if (index <= 0) return; windowStack.move(index, index - 1); + setDirty(s->geometry()); } -void QGraphicsSystemFbScreen::lower(QGraphicsSystemFbWindowSurface * surface) +void QGraphicsSystemFbScreen::lower(QWindowSurface * surface) { - int index = windowStack.indexOf(surface); + QGraphicsSystemFbWindowSurface *s = static_cast(surface); + int index = windowStack.indexOf(s); if (index == -1 || index == (windowStack.size() - 1)) return; windowStack.move(index, index + 1); + setDirty(s->geometry()); } -void QGraphicsSystemFbScreen::top(QGraphicsSystemFbWindowSurface * surface) -{ - int index = windowStack.indexOf(surface); - if (index == -1) - return; - windowStack.move(index, 0); -} - -void QGraphicsSystemFbScreen::bottom(QGraphicsSystemFbWindowSurface * surface) -{ - int index = windowStack.indexOf(surface); - if (index == -1) - return; - windowStack.move(index, windowStack.size() - 1); -} - - void QGraphicsSystemFbScreen::pointerEvent(QMouseEvent & me) { QApplicationPrivate::handleMouseEvent(0, me); diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h index fba7a7a..bd69443 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -59,11 +59,9 @@ public: virtual void setDirty(const QRect &rect); virtual void removeWindowSurface(QGraphicsSystemFbWindowSurface * surface); - virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { windowStack.append(surface); } - virtual void raise(QGraphicsSystemFbWindowSurface * surface); - virtual void lower(QGraphicsSystemFbWindowSurface * surface); - virtual void top(QGraphicsSystemFbWindowSurface * surface); - virtual void bottom(QGraphicsSystemFbWindowSurface * surface); + virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { windowStack.prepend(surface); } + virtual void raise(QWindowSurface * surface); + virtual void lower(QWindowSurface * surface); virtual void pointerEvent(QMouseEvent & me); -- cgit v0.12 From 364825a39178fecc0c723ddc0ec7409b2f9b2956 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 13 Nov 2009 17:29:42 +0100 Subject: lower is to the bottom, not 1 lower, raise is to the top, not 1 higher --- src/plugins/graphicssystems/fb_base/fb_base.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index c4c009f..cb1b478 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -103,7 +103,7 @@ void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) int index = windowStack.indexOf(s); if (index <= 0) return; - windowStack.move(index, index - 1); + windowStack.move(index, 0); setDirty(s->geometry()); } @@ -113,7 +113,7 @@ void QGraphicsSystemFbScreen::lower(QWindowSurface * surface) int index = windowStack.indexOf(s); if (index == -1 || index == (windowStack.size() - 1)) return; - windowStack.move(index, index + 1); + windowStack.move(index, windowStack.size() - 1); setDirty(s->geometry()); } -- cgit v0.12 From 12bc7c80b94b5f3acbf87f268c4e68ba4bc89381 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 16 Nov 2009 13:57:53 +0100 Subject: remove an unnecessary call to QGraphicsSystemScreen::setDirty() in QGraphicsSystemCursor::pointerEvent() --- src/gui/painting/qgraphicssystemcursor.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp index 9bf5d02..08dcbbe 100644 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -100,7 +100,6 @@ void QGraphicsSystemCursor::pointerEvent(QMouseEvent & e) currentRect = graphic->image()->rect().translated(-graphic->hotspot().x(), -graphic->hotspot().y()); currentRect.translate(e.pos()); - screen->setDirty(currentRect); screen->pointerEvent(e); } -- cgit v0.12 From 993b3831d3b2704f492c17313a210497b6f9bb5f Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 16 Nov 2009 16:12:52 +0100 Subject: moved top-level raise/lower from QGraphicsSystemScreen to QWindowSurface, testlite support --- src/gui/kernel/qwidget_lite.cpp | 6 ++---- src/gui/painting/qgraphicssystem_p.h | 3 --- src/gui/painting/qwindowsurface_p.h | 3 +++ src/plugins/graphicssystems/fb_base/fb_base.cpp | 10 ++++++++++ src/plugins/graphicssystems/fb_base/fb_base.h | 4 ++++ .../graphicssystems/testlite/qwindowsurface_testlite.cpp | 11 +++++++++++ .../graphicssystems/testlite/qwindowsurface_testlite.h | 2 ++ 7 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index d52d432..cd4fa18 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -423,8 +423,7 @@ void QWidgetPrivate::raise_sys() Q_Q(QWidget); if (q->isWindow()) { QWindowSurface *surface = q->windowSurface(); - QGraphicsSystemScreen *screen = qt_screenForWidget(q); - screen->raise(surface); + surface->raise(); } } @@ -434,8 +433,7 @@ void QWidgetPrivate::lower_sys() if (q->isWindow()) { Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); QWindowSurface *surface = q->windowSurface(); - QGraphicsSystemScreen *screen = qt_screenForWidget(q); - screen->lower(surface); + surface->lower(); } else if (QWidget *p = q->parentWidget()) { setDirtyOpaqueRegion(); p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index 5b5848e..ddba22d 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -75,9 +75,6 @@ public: virtual QSize physicalSize() const = 0; virtual void setDirty(QRect) { } virtual void pointerEvent(QMouseEvent &) { } - - virtual void raise(QWindowSurface *) { qWarning("This plugin does not support raise()"); } - virtual void lower(QWindowSurface *) { qWarning("This plugin does not support lower()"); } }; #endif // Q_WS_LITE diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h index 88cc8ba..5e95d80 100644 --- a/src/gui/painting/qwindowsurface_p.h +++ b/src/gui/painting/qwindowsurface_p.h @@ -94,6 +94,9 @@ public: virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); virtual Qt::WindowFlags windowFlags() const; virtual WId winId() const; + + virtual void raise() { qWarning("This plugin does not support raise()"); } + virtual void lower() { qWarning("This plugin does not support lower()"); } #endif bool hasStaticContentsSupport() const; diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index cb1b478..b992b15 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -97,6 +97,11 @@ void QGraphicsSystemFbScreen::removeWindowSurface(QGraphicsSystemFbWindowSurface setDirty(surface->geometry()); } +void QGraphicsSystemFbWindowSurface::raise() +{ + mScreen->raise(this); +} + void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) { QGraphicsSystemFbWindowSurface *s = static_cast(surface); @@ -107,6 +112,11 @@ void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) setDirty(s->geometry()); } +void QGraphicsSystemFbWindowSurface::lower() +{ + mScreen->lower(this); +} + void QGraphicsSystemFbScreen::lower(QWindowSurface * surface) { QGraphicsSystemFbWindowSurface *s = static_cast(surface); diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h index bd69443..83c3e06 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -32,6 +32,10 @@ public: const QImage image() { return mImage; } void setGeometry(const QRect &rect); + + virtual void raise(); + virtual void lower(); + protected: QGraphicsSystemFbScreen *mScreen; QRect oldGeometry; diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 9e24f55..be86cb5 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -578,4 +578,15 @@ WId QTestLiteWindowSurface::winId() const return WId(0); } +void QTestLiteWindowSurface::raise() +{ + WId window = winId(); + XRaiseWindow(mGraphicsSystem->xd->display, window); +} + +void QTestLiteWindowSurface::lower() +{ + WId window = winId(); + XLowerWindow(mGraphicsSystem->xd->display, window); +} QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h index 59db81f..3603e93 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h @@ -79,6 +79,8 @@ public: Qt::WindowFlags windowFlags() const; void setVisible(bool visible); WId winId() const; + void raise(); + void lower(); private: QTestLiteGraphicsSystem *mGraphicsSystem; -- cgit v0.12 From b594232e02bab7f082c78ca354e02b4a7e9842e2 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 17 Nov 2009 09:07:01 +0100 Subject: remap global mouse event position to the toplevel's coordinates --- src/plugins/graphicssystems/fb_base/fb_base.cpp | 22 +++++++++++++++++++++- src/plugins/graphicssystems/fb_base/fb_base.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index b992b15..281d0e0 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -129,9 +129,29 @@ void QGraphicsSystemFbScreen::lower(QWindowSurface * surface) void QGraphicsSystemFbScreen::pointerEvent(QMouseEvent & me) { - QApplicationPrivate::handleMouseEvent(0, me); + QWidget * widget = topLevelAt(me.pos()); + if (!widget) { + QApplicationPrivate::handleMouseEvent(0, me); + return; + } + QPoint localPosition = me.pos(); + QPoint topLeft = widget->geometry().topLeft(); + localPosition.setX(localPosition.x() - topLeft.x()); + localPosition.setY(localPosition.y() - topLeft.y()); + QMouseEvent e(me.type(), localPosition, me.globalPos(), me.button(), me.buttons(), me.modifiers()); + QApplicationPrivate::handleMouseEvent(widget, e); } +QWidget * QGraphicsSystemFbScreen::topLevelAt(QPoint p) +{ + for(int i = 0; i < windowStack.size(); i++) { + if (windowStack[i]->geometry().contains(p, false)) { + qDebug() << "toplevel at" << p << windowStack[i]->window()->objectName(); + return windowStack[i]->window(); + } + } + return 0; +} QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window) : QWindowSurface(window), diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h index 83c3e06..18519ec 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -66,6 +66,7 @@ public: virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { windowStack.prepend(surface); } virtual void raise(QWindowSurface * surface); virtual void lower(QWindowSurface * surface); + virtual QWidget * topLevelAt(QPoint p); virtual void pointerEvent(QMouseEvent & me); -- cgit v0.12 From 8a38b9bf663998cfe17e041d3013669e77dffac2 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 17 Nov 2009 09:12:47 +0100 Subject: Verify that a window is visible before reporting it as the selected toplevel --- src/plugins/graphicssystems/fb_base/fb_base.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index 281d0e0..5a8daec 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -145,7 +145,8 @@ void QGraphicsSystemFbScreen::pointerEvent(QMouseEvent & me) QWidget * QGraphicsSystemFbScreen::topLevelAt(QPoint p) { for(int i = 0; i < windowStack.size(); i++) { - if (windowStack[i]->geometry().contains(p, false)) { + if (windowStack[i]->geometry().contains(p, false) && + windowStack[i]->visible()) { qDebug() << "toplevel at" << p << windowStack[i]->window()->objectName(); return windowStack[i]->window(); } -- cgit v0.12 From 20f7847fce7b41952121367e7889bc58597ca41a Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 17 Nov 2009 09:48:38 +0100 Subject: remove a qDebug() in topLevelAt() --- src/plugins/graphicssystems/fb_base/fb_base.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index 5a8daec..7e00381 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -147,7 +147,6 @@ QWidget * QGraphicsSystemFbScreen::topLevelAt(QPoint p) for(int i = 0; i < windowStack.size(); i++) { if (windowStack[i]->geometry().contains(p, false) && windowStack[i]->visible()) { - qDebug() << "toplevel at" << p << windowStack[i]->window()->objectName(); return windowStack[i]->window(); } } -- cgit v0.12 From 8fc2eec5b3282665f76f1e0313a03608bf4e7bc1 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 17 Nov 2009 15:06:10 +0100 Subject: Check if a window is minimized before drawing it, or reporting it via topLevelAt() --- src/plugins/graphicssystems/fb_base/fb_base.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index 7e00381..a091f73 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -69,6 +69,8 @@ QRegion QGraphicsSystemFbScreen::doRedraw() for (int i = windowStack.length() - 1; i >= 0; i--) { if (!windowStack[i]->visible()) continue; + if (windowStack[i]->window()->isMinimized()) + continue; QRect windowRect = windowStack[i]->geometry(); QRect intersect = windowRect.intersected(rect); QRect windowIntersect = intersect.translated(-windowRect.left(), @@ -146,7 +148,8 @@ QWidget * QGraphicsSystemFbScreen::topLevelAt(QPoint p) { for(int i = 0; i < windowStack.size(); i++) { if (windowStack[i]->geometry().contains(p, false) && - windowStack[i]->visible()) { + windowStack[i]->visible() && + !windowStack[i]->window()->isMinimized()) { return windowStack[i]->window(); } } -- cgit v0.12 From c357ab6fbb673f75e9f2ccb2da5d3a938eaadf1f Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 19 Nov 2009 11:43:20 +0100 Subject: added QGraphicsSystemScreen::topLevelAt(): find the window at a global position This is used to determine which widget to send a pointer event to, and to implement QApplication::widgetAt(). --- src/gui/kernel/qapplication_lite.cpp | 23 +++++++++-------------- src/gui/painting/qgraphicssystem.cpp | 13 +++++++++++++ src/gui/painting/qgraphicssystem_p.h | 1 + src/gui/painting/qgraphicssystemcursor.cpp | 3 +-- src/plugins/graphicssystems/fb_base/fb_base.cpp | 2 +- src/plugins/graphicssystems/fb_base/fb_base.h | 2 +- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 061ac5b..b0f5074 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -56,7 +56,7 @@ #include #include - +#include "private/qgraphicssystem_p.h" #include @@ -354,19 +354,14 @@ void QApplication::restoreOverrideCursor() QWidget *QApplication::topLevelAt(const QPoint &pos) { -//### We have to implement a windowsystem-aware way to do this - - //fallback implementation assuming widgets are in stacking order - - QWidgetList list = topLevelWidgets(); - for (int i = list.size()-1; i >= 0; --i) { - QWidget *w = list[i]; - //### mask is ignored - if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos)) - return w; - } - - return 0; + QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); + if (!gs) + return 0; + QGraphicsSystemScreen *screen = gs->screens().first(); + if (!screen) + return 0; + QWidget *w = screen->topLevelAt(pos); + return w; } void QApplication::beep() diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp index 2071127..948223d 100644 --- a/src/gui/painting/qgraphicssystem.cpp +++ b/src/gui/painting/qgraphicssystem.cpp @@ -85,6 +85,19 @@ QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType typ } #ifdef Q_WS_LITE +QWidget *QGraphicsSystemScreen::topLevelAt(const QPoint & pos) const +{ + QWidgetList list = QApplication::topLevelWidgets(); + for (int i = list.size()-1; i >= 0; --i) { + QWidget *w = list[i]; + //### mask is ignored + if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos)) + return w; + } + + return 0; +} + QList QGraphicsSystem::screens() const { return QList(); diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index ddba22d..1bfca58 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -75,6 +75,7 @@ public: virtual QSize physicalSize() const = 0; virtual void setDirty(QRect) { } virtual void pointerEvent(QMouseEvent &) { } + virtual QWidget *topLevelAt(const QPoint &point) const; }; #endif // Q_WS_LITE diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp index 08dcbbe..b919d0a 100644 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -57,8 +57,7 @@ QGraphicsSystemCursor::QGraphicsSystemCursor(QGraphicsSystemScreen *scr ) { graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); instance = this; - QWidget * widget = QApplication::widgetAt(QCursor::pos()); - changeCursor(widget); + setCursor(Qt::ArrowCursor); } QGraphicsSystemCursor::~QGraphicsSystemCursor() diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index a091f73..d872593 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -144,7 +144,7 @@ void QGraphicsSystemFbScreen::pointerEvent(QMouseEvent & me) QApplicationPrivate::handleMouseEvent(widget, e); } -QWidget * QGraphicsSystemFbScreen::topLevelAt(QPoint p) +QWidget * QGraphicsSystemFbScreen::topLevelAt(const QPoint & p) const { for(int i = 0; i < windowStack.size(); i++) { if (windowStack[i]->geometry().contains(p, false) && diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h index 18519ec..8c1bb56 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -66,7 +66,7 @@ public: virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { windowStack.prepend(surface); } virtual void raise(QWindowSurface * surface); virtual void lower(QWindowSurface * surface); - virtual QWidget * topLevelAt(QPoint p); + virtual QWidget * topLevelAt(const QPoint & p) const; virtual void pointerEvent(QMouseEvent & me); -- cgit v0.12 From 19689dd51a93668fda2273472985114e86a9b8d5 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 19 Nov 2009 15:15:17 +0100 Subject: Report cursor movement to QApplicationPrivate::handleMouseEvent() directly We had this running through qvnccursor -> QVNCGraphicsSystemScreen -> QApplicationPrivate, but that doesn't work with the generic Linux input plugin. --- src/gui/kernel/qapplication_lite.cpp | 4 ++++ src/gui/painting/qgraphicssystem_p.h | 5 +++-- src/gui/painting/qgraphicssystemcursor.cpp | 5 ++--- src/gui/painting/qgraphicssystemcursor.h | 2 +- src/plugins/graphicssystems/fb_base/fb_base.cpp | 15 --------------- src/plugins/graphicssystems/fb_base/fb_base.h | 2 -- src/plugins/graphicssystems/vnc/qvnccursor.cpp | 6 ++++-- src/plugins/graphicssystems/vnc/qvncserver.cpp | 3 +-- 8 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index b0f5074..f2be5c7 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -57,6 +57,7 @@ #include #include "private/qgraphicssystem_p.h" +#include "qgraphicssystemcursor.h" #include @@ -525,6 +526,9 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) static QWidget *implicit_mouse_grabber=0; + if (QGraphicsSystemCursor::instance) + QGraphicsSystemCursor::instance->pointerEvent(ev); + QPoint localPoint = ev.pos(); QPoint globalPoint = ev.globalPos(); QWidget *mouseWindow = tlw; diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index 1bfca58..0b0dfb5 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -56,6 +56,8 @@ #include "private/qpixmapdata_p.h" #include "private/qwindowsurface_p.h" +#include + QT_BEGIN_NAMESPACE class QPixmapFilter; @@ -73,8 +75,7 @@ public: virtual int depth() const = 0; virtual QImage::Format format() const = 0; virtual QSize physicalSize() const = 0; - virtual void setDirty(QRect) { } - virtual void pointerEvent(QMouseEvent &) { } + virtual void setDirty(const QRect &) {} virtual QWidget *topLevelAt(const QPoint &point) const; }; #endif // Q_WS_LITE diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp index b919d0a..6aef76c 100644 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -94,13 +94,12 @@ QRect QGraphicsSystemCursor::drawCursor(QPainter & painter) return prevRect; } -void QGraphicsSystemCursor::pointerEvent(QMouseEvent & e) +void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & e) { currentRect = graphic->image()->rect().translated(-graphic->hotspot().x(), -graphic->hotspot().y()); currentRect.translate(e.pos()); - - screen->pointerEvent(e); + screen->setDirty(QRect(QRect(e.pos(), QSize(1, 1)))); } void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor) diff --git a/src/gui/painting/qgraphicssystemcursor.h b/src/gui/painting/qgraphicssystemcursor.h index eab7203..de7ce84 100644 --- a/src/gui/painting/qgraphicssystemcursor.h +++ b/src/gui/painting/qgraphicssystemcursor.h @@ -73,7 +73,7 @@ public: // input methods virtual void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); virtual void setCursor(Qt::CursorShape shape); - virtual void pointerEvent(QMouseEvent & event); + virtual void pointerEvent(const QMouseEvent & event); virtual void changeCursor(QWidget * widget); virtual void changeCursor(QCursor * widgetCursor); diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index d872593..6ecfd1b 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -129,21 +129,6 @@ void QGraphicsSystemFbScreen::lower(QWindowSurface * surface) setDirty(s->geometry()); } -void QGraphicsSystemFbScreen::pointerEvent(QMouseEvent & me) -{ - QWidget * widget = topLevelAt(me.pos()); - if (!widget) { - QApplicationPrivate::handleMouseEvent(0, me); - return; - } - QPoint localPosition = me.pos(); - QPoint topLeft = widget->geometry().topLeft(); - localPosition.setX(localPosition.x() - topLeft.x()); - localPosition.setY(localPosition.y() - topLeft.y()); - QMouseEvent e(me.type(), localPosition, me.globalPos(), me.button(), me.buttons(), me.modifiers()); - QApplicationPrivate::handleMouseEvent(widget, e); -} - QWidget * QGraphicsSystemFbScreen::topLevelAt(const QPoint & p) const { for(int i = 0; i < windowStack.size(); i++) { diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h index 8c1bb56..8e54f47 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -68,8 +68,6 @@ public: virtual void lower(QWindowSurface * surface); virtual QWidget * topLevelAt(const QPoint & p) const; - virtual void pointerEvent(QMouseEvent & me); - QImage * image() const { return mScreenImage; } QPaintDevice * paintDevice() const { return mScreenImage; } diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.cpp b/src/plugins/graphicssystems/vnc/qvnccursor.cpp index 80ab750..a0107b5 100644 --- a/src/plugins/graphicssystems/vnc/qvnccursor.cpp +++ b/src/plugins/graphicssystems/vnc/qvnccursor.cpp @@ -60,8 +60,6 @@ QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCGraphicsSystemScreen *scr ) void QVNCCursor::setCursorMode(bool vnc) { -// if (vnc == useVncCursor) -// return; if (vnc) { screen->setDirty(prevRect); prevRect = QRect(); @@ -77,6 +75,8 @@ void QVNCCursor::setCursor(Qt::CursorShape shape) QGraphicsSystemCursor::setCursor(shape); if (useVncCursor) { server->setDirtyCursor(); + } else { + screen->setDirty(QRect(QRect(0,0,1,1)); } } @@ -85,6 +85,8 @@ void QVNCCursor::setCursor(const uchar *data, const uchar *mask, int width, int QGraphicsSystemCursor::setCursor(data, mask, width, height, hotX, hotY); if (useVncCursor) { server->setDirtyCursor(); + } else { + screen->setDirty(QRect(0,0,1,1)); } } diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp index ef6b4a1..fcff255 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -835,8 +835,7 @@ void QVNCServer::pointerEvent() if (buttonChange(buttons, ev.buttons, &button, &isPress)) type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; QMouseEvent me(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); - if(cursor) - cursor->pointerEvent(me); + QApplicationPrivate::handleMouseEvent(0, me); buttons = ev.buttons; handleMsg = false; } -- cgit v0.12 From 869c9dad8f4c42db47c448a4c644dc2e54c60c2b Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 19 Nov 2009 15:23:03 +0100 Subject: Add a cursor to linuxfb --- src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp index 291b118..2a0007b 100644 --- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp +++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp @@ -807,6 +807,7 @@ QLinuxFbGraphicsSystemScreen::QLinuxFbGraphicsSystemScreen(uchar * d, int w, mFormat); mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), bytesPerLine, mFormat); + cursor = new QGraphicsSystemCursor(this); } void QLinuxFbGraphicsSystemScreen::setGeometry(QRect rect) -- cgit v0.12 From e105e78d81b3696044af693ed65f88034c3e92da Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 19 Nov 2009 17:06:13 +0100 Subject: Compile --- src/gui/painting/qgraphicssystem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp index 948223d..f9382ec 100644 --- a/src/gui/painting/qgraphicssystem.cpp +++ b/src/gui/painting/qgraphicssystem.cpp @@ -52,6 +52,8 @@ #endif #ifdef Q_WS_LITE # include +# include +# include #endif #ifdef Q_WS_S60 # include -- cgit v0.12 From 4485749550e99b71ba14a2baaef492f1da3c0478 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 19 Nov 2009 18:00:25 +0100 Subject: missing ) in QVNCCursor::setCursor --- src/plugins/graphicssystems/vnc/qvnccursor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.cpp b/src/plugins/graphicssystems/vnc/qvnccursor.cpp index a0107b5..aa0f109 100644 --- a/src/plugins/graphicssystems/vnc/qvnccursor.cpp +++ b/src/plugins/graphicssystems/vnc/qvnccursor.cpp @@ -76,7 +76,7 @@ void QVNCCursor::setCursor(Qt::CursorShape shape) if (useVncCursor) { server->setDirtyCursor(); } else { - screen->setDirty(QRect(QRect(0,0,1,1)); + screen->setDirty(QRect(QRect(0,0,1,1))); } } -- cgit v0.12 From cd4c5e2af80e5161b301a9798686220eb4731be6 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 23 Nov 2009 15:14:38 +0100 Subject: enable enter/leave event dispatching where the entered widget is null With framebuffer backends (vnc, linuxfb), there can be screen coordinates where no toplevel exists. dispatchEnterLeave() still needs to be called to allow the cursor to be reset when leaving a widget that sets a cursor. --- src/gui/kernel/qapplication.cpp | 6 +++++- src/gui/kernel/qapplication_lite.cpp | 2 +- src/gui/kernel/qwidget_lite.cpp | 17 +++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index bbf7b40..bb90285 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -2660,7 +2660,11 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { #if defined(Q_WS_X11) qt_x11_enforce_cursor(parentOfLeavingCursor,true); #elif defined(Q_WS_LITE) - qt_lite_set_cursor(parentOfLeavingCursor, true); + if (enter == QApplication::desktop()) { + qt_lite_set_cursor(enter, true); + } else { + qt_lite_set_cursor(parentOfLeavingCursor, true); + } #endif } } diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index f2be5c7..cdaa855 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -558,7 +558,7 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) } if (!mouseWindow && !implicit_mouse_grabber) - return; //nowhere to send it + mouseWindow = QApplication::desktop(); if (mouseWindow && mouseWindow != tlw) { //we did not get a sensible localPoint from the window system, so let's calculate it diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index cd4fa18..88df81f 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -669,8 +669,13 @@ void QWidgetPrivate::setModal_sys() void qt_lite_set_cursor(QWidget * w, bool force) { static QPointer lastUnderMouse = 0; - if (w == 0) { // override cursor stack emptied - QCursor * override = QApplication::overrideCursor(); + + QCursor * override = QApplication::overrideCursor(); + + if (override && w != 0) + return; + + if (w == 0) { if (override) { if (QGraphicsSystemCursor::instance) { QGraphicsSystemCursor::instance->changeCursor(override); @@ -678,6 +683,8 @@ void qt_lite_set_cursor(QWidget * w, bool force) return; } w = QApplication::widgetAt(QCursor::pos()); + if (w == 0) // clear the override cursor while over empty space + w = QApplication::desktop(); } else if (force) { lastUnderMouse = w; } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse @@ -685,6 +692,12 @@ void qt_lite_set_cursor(QWidget * w, bool force) w = lastUnderMouse; } + if (w == QApplication::desktop()) { + if (QGraphicsSystemCursor::instance) { + QGraphicsSystemCursor::instance->changeCursor(w); + } + } + QWidget * curWin = QApplication::activeWindow(); if (!curWin && w && w->internalWinId()) return; -- cgit v0.12 From 52df0e48813c97e27644fb6052c541af39a8dc92 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 24 Nov 2009 11:03:33 +0100 Subject: mark the screen dirty after a cursor change --- src/gui/painting/qgraphicssystemcursor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp index 6aef76c..300c719 100644 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -116,6 +116,7 @@ void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor) // system cursor setCursor(shape); } + screen->setDirty(currentRect); } void QGraphicsSystemCursor::changeCursor(QWidget * widget) @@ -126,6 +127,7 @@ void QGraphicsSystemCursor::changeCursor(QWidget * widget) } else { // default cursor setCursor(Qt::ArrowCursor); + screen->setDirty(currentRect); } } -- cgit v0.12 From 4750df7a21748416541c88572ff46f83861745fd Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 24 Nov 2009 11:35:04 +0100 Subject: recalculate the cursor's current QRect when changing the cursor graphic --- src/gui/painting/qgraphicssystemcursor.cpp | 16 ++++++++++++---- src/gui/painting/qgraphicssystemcursor.h | 3 +++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp index 300c719..cad914d 100644 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -94,12 +94,18 @@ QRect QGraphicsSystemCursor::drawCursor(QPainter & painter) return prevRect; } +QRect QGraphicsSystemCursor::getCurrentRect() +{ + QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(), + -graphic->hotspot().y()); + rect.translate(QCursor::pos()); + return rect; +} + void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & e) { - currentRect = graphic->image()->rect().translated(-graphic->hotspot().x(), - -graphic->hotspot().y()); - currentRect.translate(e.pos()); - screen->setDirty(QRect(QRect(e.pos(), QSize(1, 1)))); + currentRect = getCurrentRect(); + screen->setDirty(currentRect); } void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor) @@ -116,6 +122,7 @@ void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor) // system cursor setCursor(shape); } + currentRect = getCurrentRect(); screen->setDirty(currentRect); } @@ -127,6 +134,7 @@ void QGraphicsSystemCursor::changeCursor(QWidget * widget) } else { // default cursor setCursor(Qt::ArrowCursor); + currentRect = getCurrentRect(); screen->setDirty(currentRect); } } diff --git a/src/gui/painting/qgraphicssystemcursor.h b/src/gui/painting/qgraphicssystemcursor.h index de7ce84..ea30319 100644 --- a/src/gui/painting/qgraphicssystemcursor.h +++ b/src/gui/painting/qgraphicssystemcursor.h @@ -92,6 +92,9 @@ protected: QWidget * currentWidget; // widget currently under the cursor QGraphicsSystemCursorImage * graphic; + +private: + QRect getCurrentRect(); }; QT_END_NAMESPACE -- cgit v0.12 From efa0d024fc262b89189c0589a0ee81fe083635b1 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 24 Nov 2009 13:57:27 +0100 Subject: Cursor shapes for the testlite backend --- .../testlite/qgraphicssystem_testlite.cpp | 55 +++++++++++++ .../testlite/qwindowsurface_testlite.cpp | 6 ++ .../testlite/qwindowsurface_testlite.h | 2 + src/plugins/graphicssystems/testlite/x11util.cpp | 93 +++++++++++++++++++++- src/plugins/graphicssystems/testlite/x11util.h | 1 + 5 files changed, 155 insertions(+), 2 deletions(-) diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp index 9991e75..64386b7 100644 --- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp @@ -44,12 +44,62 @@ #include #include +#include + + #include "x11util.h" QT_BEGIN_NAMESPACE +class MyCursor : QGraphicsSystemCursor +{ +public: + MyCursor(QGraphicsSystemScreen *screen) : QGraphicsSystemCursor(screen) {} + + // input methods + void setCursor(const uchar */*data*/, const uchar */*mask*/, int width, int height, int hotX, int hotY) {qDebug() << "setCursor data..." << width << height << hotX << hotY;} + + void setCursor(Qt::CursorShape shape) { + static int oldshape = -1; + if (shape != oldshape) { + qDebug() << "setCursor" << shape; QGraphicsSystemCursor::setCursor(shape); + oldshape = shape; + } + } + + void changeCursor(QWidget * widget) { + + QTestLiteWindowSurface *ws = 0; + if (widget) { + QWidget *window = widget->window(); + ws = static_cast(window->windowSurface()); + } + + //qDebug() << "changeCursor" << widget << ws; + if (!ws) + return; + + ws->setCursor(widget->cursor().shape()); + } + +// void changeCursor(QCursor * widgetCursor) { +// //qDebug() << "changeCursor widgetCursor"; +// QGraphicsSystemCursor::changeCursor(widgetCursor); +// } + + //#### remove this + void pointerEvent(const QMouseEvent & event) { + Q_UNUSED(event); +#if 0 + qDebug() << "pointerEvent" << event.globalPos(); +#endif + } +}; + + QTestLiteGraphicsSystem::QTestLiteGraphicsSystem() { + xd = new MyDisplay; mPrimaryScreen = new QTestLiteGraphicsSystemScreen(); @@ -62,6 +112,10 @@ QTestLiteGraphicsSystem::QTestLiteGraphicsSystem() QSize(xd->physicalWidth, xd->physicalHeight); mScreens.append(mPrimaryScreen); + + + (void)new MyCursor(mPrimaryScreen); + } QPixmapData *QTestLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const @@ -85,4 +139,5 @@ QPixmap QTestLiteGraphicsSystem::grabWindow(WId window, int x, int y, int width, } + QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index be86cb5..495b572 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -589,4 +589,10 @@ void QTestLiteWindowSurface::lower() WId window = winId(); XLowerWindow(mGraphicsSystem->xd->display, window); } + + +void QTestLiteWindowSurface::setCursor(Qt::CursorShape shape) +{ + xw->setCursorShape(shape); +} QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h index 3603e93..cedd66c 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h @@ -82,6 +82,8 @@ public: void raise(); void lower(); + void setCursor(Qt::CursorShape shape); + private: QTestLiteGraphicsSystem *mGraphicsSystem; QTestLiteGraphicsSystemScreen *mScreen; diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index 0c6f3c5..5830550 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -55,6 +55,7 @@ #include +#include //### remove stuff we don't want from qt_x11_p.h @@ -480,7 +481,7 @@ void MyWindow::setGeometry(int x, int y, int w, int h) } -void MyWindow::enterEvent(XCrossingEvent *e) +void MyWindow::enterEvent(XCrossingEvent *) { #ifdef MYX11_DEBUG qDebug() << "MyWindow::enterEvent" << hex << window; @@ -488,7 +489,7 @@ void MyWindow::enterEvent(XCrossingEvent *e) windowSurface->handleEnterEvent(); } -void MyWindow::leaveEvent(XCrossingEvent *e) +void MyWindow::leaveEvent(XCrossingEvent *) { #ifdef MYX11_DEBUG qDebug() << "MyWindow::enterEvent" << hex << window; @@ -782,3 +783,91 @@ void MyWindow::setVisible(bool visible) else XUnmapWindow(xd->display, window); } + + +void MyWindow::setCursorShape(int cshape) +{ + if (cshape < 0 || cshape > Qt::LastCursor) + return; + + static Cursor cursors[Qt::LastCursor+1] = {XNone}; + + Cursor cursor = cursors[cshape]; + if (!cursor) { + switch (cshape) { + case Qt::ArrowCursor: + cursor = XCreateFontCursor(xd->display, XC_left_ptr); + break; + case Qt::UpArrowCursor: + cursor = XCreateFontCursor(xd->display, XC_center_ptr); + break; + case Qt::CrossCursor: + cursor = XCreateFontCursor(xd->display, XC_crosshair); + break; + case Qt::WaitCursor: + cursor = XCreateFontCursor(xd->display, XC_watch); + break; + case Qt::IBeamCursor: + cursor = XCreateFontCursor(xd->display, XC_xterm); + break; + case Qt::SizeAllCursor: + cursor = XCreateFontCursor(xd->display, XC_fleur); + break; + case Qt::PointingHandCursor: + cursor = XCreateFontCursor(xd->display, XC_hand2); + break; + case Qt::SizeBDiagCursor: + cursor = XCreateFontCursor(xd->display, XC_top_right_corner); + break; + case Qt::SizeFDiagCursor: + cursor = XCreateFontCursor(xd->display, XC_bottom_right_corner); + break; + case Qt::SizeVerCursor: + case Qt::SplitVCursor: + cursor = XCreateFontCursor(xd->display, XC_sb_v_double_arrow); + break; + case Qt::SizeHorCursor: + case Qt::SplitHCursor: + cursor = XCreateFontCursor(xd->display, XC_sb_h_double_arrow); + break; + case Qt::WhatsThisCursor: + cursor = XCreateFontCursor(xd->display, XC_question_arrow); + break; + case Qt::ForbiddenCursor: + cursor = XCreateFontCursor(xd->display, XC_circle); + break; + case Qt::BusyCursor: + cursor = XCreateFontCursor(xd->display, XC_watch); + break; + + default: //default cursor for all the rest + break; + } + cursors[cshape] = cursor; + } + XDefineCursor(xd->display, window, cursor); +} + + +#if 0 + + + switch (cshape) { // map Q cursor to X cursor + case Qt::BlankCursor: + XColor bg, fg; + bg.red = 255 << 8; + bg.green = 255 << 8; + bg.blue = 255 << 8; + fg.red = 0; + fg.green = 0; + fg.blue = 0; + pm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16); + pmm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16); + hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8); + return; + break; + default: + qWarning("QCursor::update: Invalid cursor shape %d", cshape); + return; + } +#endif diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h index 39fc331..e9d4c7b 100644 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -109,6 +109,7 @@ public: Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); void setVisible(bool visible); + void setCursorShape(int cshape); public: //### -- cgit v0.12 From 7dea84cd015538dc327e489113919d75c8e275bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 16 Nov 2009 11:33:26 +0100 Subject: Added QBlittablePixmapData Is going to be used by everyone that reimplements QBlittable --- src/gui/image/image.pri | 2 + src/gui/image/qimage.h | 1 + src/gui/image/qpixmap_blitter.cpp | 65 +++++++++++++++++++++++++++++++ src/gui/image/qpixmap_blitter_p.h | 60 ++++++++++++++++++++++++++++ src/gui/image/qpixmapdata_p.h | 2 +- src/gui/painting/qgraphicssystem_p.h | 2 + src/gui/painting/qpaintengine_blitter.cpp | 31 ++++++++------- src/gui/painting/qpaintengine_blitter_p.h | 9 ++--- 8 files changed, 152 insertions(+), 20 deletions(-) create mode 100644 src/gui/image/qpixmap_blitter.cpp create mode 100644 src/gui/image/qpixmap_blitter_p.h diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 634c3f3..b232848 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -23,6 +23,7 @@ HEADERS += \ image/qpictureformatplugin.h \ image/qpixmap.h \ image/qpixmap_raster_p.h \ + miage/qpixmap_blitter_p.h \ image/qpixmapcache.h \ image/qpixmapcache_p.h \ image/qpixmapdata_p.h \ @@ -51,6 +52,7 @@ SOURCES += \ image/qiconengineplugin.cpp \ image/qmovie.cpp \ image/qpixmap_raster.cpp \ + image/qpixmap_blitter.cpp \ image/qnativeimage.cpp \ image/qimagepixmapcleanuphooks.cpp \ diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index d8809ef..f5c22bc 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -317,6 +317,7 @@ private: QImageData *d; friend class QRasterPixmapData; + friend class QBlittablePixmapData; friend class QPixmapCacheEntry; friend Q_GUI_EXPORT qint64 qt_image_id(const QImage &image); friend const QVector *qt_image_colortable(const QImage &image); diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp new file mode 100644 index 0000000..9730ecc --- /dev/null +++ b/src/gui/image/qpixmap_blitter.cpp @@ -0,0 +1,65 @@ +#include "qpixmap_blitter_p.h" + +#include +#include + +QBlittablePixmapData::QBlittablePixmapData(PixelType type) + : QPixmapData(type,BlitterClass), m_blittable(0), m_engine(0) +{ +} + +QBlittablePixmapData::~QBlittablePixmapData() +{ +} + +void QBlittablePixmapData::resize(int width, int height) +{ + delete m_blittable; + m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QRect(0,0,width,height)); + m_engine = 0; +} + +int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const +{ + QImage *image = m_blittable->lock(); + return image->metric(metric); +} + +void QBlittablePixmapData::fill(const QColor &color) +{ + if (m_blittable->capabilities() & QBlittable::SolidRectCapability) + m_blittable->fillRect(m_blittable->rect(),color); + else + m_blittable->lock()->fill(color.rgb()); +} + +QImage *QBlittablePixmapData::buffer() +{ + return m_blittable->lock(); +} + +QImage QBlittablePixmapData::toImage() +{ + return m_blittable->lock()->copy(); +} + +bool QBlittablePixmapData::hasAlphaChannel() +{ + return m_blittable->lock()->hasAlphaChannel(); +} + +void QBlittablePixmapData::fromImage(const QImage &image, + Qt::ImageConversionFlags flags) +{ + m_blittable = new QImageBlitter(image); + m_engine = 0; +} + +QPaintEngine *QBlittablePixmapData::paintEngine() const +{ + if (!m_engine) { + QBlittablePixmapData *that = const_cast(this); + that->m_engine = new QBlitterPaintEngine(that); + } + return m_engine; +} diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h new file mode 100644 index 0000000..5e93ef4 --- /dev/null +++ b/src/gui/image/qpixmap_blitter_p.h @@ -0,0 +1,60 @@ +#ifndef QPIXMAP_BLITTER_P_H +#define QPIXMAP_BLITTER_P_H + +#include +#include + +class QImageBlitter : public QBlittable +{ +public: + QImageBlitter(const QImage &img) + : QBlittable(img.rect(),0), image(img) + { + } + + void fillRect(const QRectF &, const QColor &) + { + //should never be called + } + void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) + { + //should never be called + } + + QImage *lock() + { + return ℑ + } + + void unlock() + { + } + +private: + QImage image; +}; + +class QBlittablePixmapData : public QPixmapData +{ +public: + QBlittablePixmapData(PixelType type); + ~QBlittablePixmapData(); + + QBlittable *blittable() const { return m_blittable; } + + void resize(int width, int height); + int metric(QPaintDevice::PaintDeviceMetric metric) const; + void fill(const QColor &color); + QImage *buffer(); + QImage toImage(); + bool hasAlphaChannel(); + void fromImage(const QImage &image, Qt::ImageConversionFlags flags); + + QPaintEngine *paintEngine() const; + +protected: + QBlitterPaintEngine *m_engine; + QBlittable *m_blittable; +}; + +#endif // QPIXMAP_BLITTER_P_H diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index 41e2923..292092f 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -73,7 +73,7 @@ public: }; #endif enum ClassId { RasterClass, X11Class, MacClass, DirectFBClass, - OpenGLClass, OpenVGClass, CustomClass = 1024 }; + OpenGLClass, OpenVGClass, BlitterClass, CustomClass = 1024 }; QPixmapData(PixelType pixelType, int classId); virtual ~QPixmapData(); diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index 0b0dfb5..275afc0 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -55,6 +55,7 @@ #include "private/qpixmapdata_p.h" #include "private/qwindowsurface_p.h" +#include "private/qpaintengine_blitter_p.h" #include @@ -85,6 +86,7 @@ class Q_GUI_EXPORT QGraphicsSystem public: virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0; + virtual QBlittable *createBlittable(const QRect &rect) { return 0; } virtual ~QGraphicsSystem() = 0; diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 367a8b5..b134d84 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -147,9 +147,9 @@ public: class QBlitterPaintEnginePrivate : public QPaintEngineExPrivate { public: - QBlitterPaintEnginePrivate(QPaintDevice *p) - : QPaintEngineExPrivate(), - raster(new QRasterPaintEngine(p)), isBlitterLocked(false), + QBlitterPaintEnginePrivate(QPixmapData *p) + : QPaintEngineExPrivate(), pixmap(p), + raster(new QRasterPaintEngine(&pixmap)), isBlitterLocked(false), capabillities(0), hasXForm(false) { if (QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem()) { @@ -235,6 +235,7 @@ public: raster->d_func()->systemStateChanged(); } + QPixmap pixmap; QRasterPaintEngine *raster; QRasterPaintEngineState *state; @@ -246,7 +247,7 @@ public: uint hasXForm; }; -QBlitterPaintEngine::QBlitterPaintEngine(QPaintDevice *p) +QBlitterPaintEngine::QBlitterPaintEngine(QPixmapData *p) : QPaintEngineEx(*(new QBlitterPaintEnginePrivate(p))) { } @@ -607,23 +608,19 @@ void QBlitterPaintEngine::setState(QPainterState *s) class QBlittablePrivate { public: + QBlittablePrivate(const QRect &rect, QBlittable::Capabilities caps) + : m_rect(rect), caps(caps) + {} QBlittable::Capabilities caps; + QRect m_rect; }; -QBlittable::QBlittable(Capabilities caps) - : d_ptr(new QBlittablePrivate) +QBlittable::QBlittable(const QRect &rect, Capabilities caps) + : d_ptr(new QBlittablePrivate(rect,caps)) { - d_ptr->caps = caps; } -QBlittable::QBlittable(QBlittablePrivate &d, Capabilities caps) - : d_ptr(&d) -{ - d_ptr->caps = caps; -} - - QBlittable::~QBlittable() { delete d_ptr; @@ -636,3 +633,9 @@ QBlittable::Capabilities QBlittable::capabilities() const return d->caps; } +QRect QBlittable::rect() const +{ + Q_D(const QBlittable); + return d->m_rect; +} + diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index 90493a4..16b7b2c 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -22,12 +22,13 @@ public: // Internal ones OutlineCapability = 0x0001000, }; - Q_DECLARE_FLAGS(Capabilities, Capability); + Q_DECLARE_FLAGS (Capabilities, Capability); - QBlittable(Capabilities caps); + QBlittable(const QRect &rect, Capabilities caps); virtual ~QBlittable(); Capabilities capabilities() const; + QRect rect() const; virtual void fillRect(const QRectF &rect, const QColor &color) = 0; virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect) = 0; @@ -37,8 +38,6 @@ public: protected: QBlittablePrivate *d_ptr; - - QBlittable(QBlittablePrivate &d, Capabilities caps); }; @@ -46,7 +45,7 @@ class Q_GUI_EXPORT QBlitterPaintEngine : public QPaintEngineEx { Q_DECLARE_PRIVATE(QBlitterPaintEngine); public: - QBlitterPaintEngine(QPaintDevice *p); + QBlitterPaintEngine(QPixmapData *p); ~QBlitterPaintEngine(); virtual QPainterState *createState(QPainterState *orig) const; -- cgit v0.12 From e6d223f9989ebe9805ddda007c9372143f9f1db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 20 Nov 2009 09:44:56 +0100 Subject: Made the blitter api work in lighthouse --- src/gui/image/qpixmap_blitter.cpp | 61 ++++++++++++-- src/gui/image/qpixmap_blitter_p.h | 11 +-- src/gui/image/qpixmapdata_p.h | 1 + src/gui/painting/qgraphicssystem_p.h | 2 +- src/gui/painting/qpaintengine_blitter.cpp | 51 ++++++------ src/gui/painting/qpaintengine_blitter_p.h | 3 +- src/gui/painting/qpaintengine_raster.cpp | 4 +- .../graphicssystems/minimaldfb/minimaldfb.pro | 8 +- .../minimaldfb/qblitter_directfb.cpp | 94 ++++++++++++++++++++++ .../graphicssystems/minimaldfb/qblitter_directfb.h | 24 ++++++ .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 65 ++++++++++----- .../minimaldfb/qgraphicssystem_minimaldfb.h | 4 +- .../minimaldfb/qwindowsurface_minimaldfb.cpp | 55 +++++-------- .../minimaldfb/qwindowsurface_minimaldfb.h | 5 +- 14 files changed, 287 insertions(+), 101 deletions(-) create mode 100644 src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp create mode 100644 src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 9730ecc..5ecc01d 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -3,8 +3,8 @@ #include #include -QBlittablePixmapData::QBlittablePixmapData(PixelType type) - : QPixmapData(type,BlitterClass), m_blittable(0), m_engine(0) +QBlittablePixmapData::QBlittablePixmapData(QPixmapData::PixelType type) + : QPixmapData(type,BlitterClass), m_engine(0), m_blittable(0) { } @@ -12,17 +12,62 @@ QBlittablePixmapData::~QBlittablePixmapData() { } +QBlittable *QBlittablePixmapData::blittable() +{ + if (!m_blittable) { + m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QRect(0,0,w,h)); + } + + return m_blittable; +} + +void QBlittablePixmapData::setBlittable(QBlittable *blittable) +{ + if (m_blittable) + delete m_blittable; + m_blittable = blittable; +} + void QBlittablePixmapData::resize(int width, int height) { delete m_blittable; - m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QRect(0,0,width,height)); + m_blittable = 0; + delete m_engine; m_engine = 0; + d = 32; + w = width; + h = height; +// d = image.depth(); + is_null = (w <= 0 || h <= 0); } +extern int qt_defaultDpiX(); +extern int qt_defaultDpiY(); int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const { - QImage *image = m_blittable->lock(); - return image->metric(metric); + switch (metric) { + case QPaintDevice::PdmWidth: + return w; + case QPaintDevice::PdmHeight: + return h; + case QPaintDevice::PdmWidthMM: + return qRound(w * 25.4 / qt_defaultDpiX()); + case QPaintDevice::PdmHeightMM: + return qRound(h * 25.4 / qt_defaultDpiY()); + case QPaintDevice::PdmDepth: + return 32; + case QPaintDevice::PdmDpiX: // fall-through + case QPaintDevice::PdmPhysicalDpiX: + return qt_defaultDpiX(); + case QPaintDevice::PdmDpiY: // fall-through + case QPaintDevice::PdmPhysicalDpiY: + return qt_defaultDpiY(); + default: + qWarning("QRasterPixmapData::metric(): Unhandled metric type %d", metric); + break; + } + + return 0; } void QBlittablePixmapData::fill(const QColor &color) @@ -38,18 +83,18 @@ QImage *QBlittablePixmapData::buffer() return m_blittable->lock(); } -QImage QBlittablePixmapData::toImage() +QImage QBlittablePixmapData::toImage() const { return m_blittable->lock()->copy(); } -bool QBlittablePixmapData::hasAlphaChannel() +bool QBlittablePixmapData::hasAlphaChannel() const { return m_blittable->lock()->hasAlphaChannel(); } void QBlittablePixmapData::fromImage(const QImage &image, - Qt::ImageConversionFlags flags) + Qt::ImageConversionFlags) { m_blittable = new QImageBlitter(image); m_engine = 0; diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index 5e93ef4..3ed2fe4 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -34,20 +34,21 @@ private: QImage image; }; -class QBlittablePixmapData : public QPixmapData +class Q_GUI_EXPORT QBlittablePixmapData : public QPixmapData { public: - QBlittablePixmapData(PixelType type); + QBlittablePixmapData(QPixmapData::PixelType type); ~QBlittablePixmapData(); - QBlittable *blittable() const { return m_blittable; } + QBlittable *blittable(); + void setBlittable(QBlittable *blittable); void resize(int width, int height); int metric(QPaintDevice::PaintDeviceMetric metric) const; void fill(const QColor &color); QImage *buffer(); - QImage toImage(); - bool hasAlphaChannel(); + QImage toImage() const; + bool hasAlphaChannel() const; void fromImage(const QImage &image, Qt::ImageConversionFlags flags); QPaintEngine *paintEngine() const; diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index 292092f..a668f0a 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -137,6 +137,7 @@ private: friend class QX11PixmapData; friend class QS60PixmapData; friend class QImagePixmapCleanupHooks; // Needs to set is_cached + friend class QBlittablPixmapData; friend class QGLTextureCache; //Needs to check the reference count friend class QExplicitlySharedDataPointer; diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index 275afc0..5fce93d 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -86,7 +86,7 @@ class Q_GUI_EXPORT QGraphicsSystem public: virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0; - virtual QBlittable *createBlittable(const QRect &rect) { return 0; } + virtual QBlittable *createBlittable(const QRect &) const { return 0; } virtual ~QGraphicsSystem() = 0; diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index b134d84..0632ae0 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -2,6 +2,7 @@ #include "private/qpaintengine_raster_p.h" #include "private/qpainter_p.h" #include "private/qapplication_p.h" +#include "private/qpixmap_blitter_p.h" #define STATE_XFORM_SCALE 0x00000001 #define STATE_XFORM_COMPLEX 0x00000002 @@ -147,21 +148,16 @@ public: class QBlitterPaintEnginePrivate : public QPaintEngineExPrivate { public: - QBlitterPaintEnginePrivate(QPixmapData *p) - : QPaintEngineExPrivate(), pixmap(p), - raster(new QRasterPaintEngine(&pixmap)), isBlitterLocked(false), - capabillities(0), hasXForm(false) - { - if (QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem()) { -// QBlittable *b = gs->createBlitter(p); -// if (b) { -// blitter=b; -// capabillities = new CapabilitiesToStateMask(blitter->capabilities()); -// blitter->unlock(); -// } else -// qWarning("No blitter returned from the graphics system. QBlitterPaintEngine will not work"); - } + QBlitterPaintEnginePrivate(QBlittablePixmapData *p) + : QPaintEngineExPrivate(), + isBlitterLocked(false), + hasXForm(false) + { + blitter= p->blittable(); + raster = new QRasterPaintEngine(p->buffer()); + capabillities = new CapabilitiesToStateMask(blitter->capabilities()); + lock(); } inline void lock() { @@ -179,31 +175,35 @@ public: } void fillRect(const QRectF &rect, const QColor &color) { - unlock(); + lock(); QRectF targetRect = rect; if (hasXForm) { targetRect = state->matrix.mapRect(rect); } QClipData *clipData = raster->state()->clip; if (clipData) { - if (clipData->hasRectClip) + if (clipData->hasRectClip) { + unlock(); blitter->fillRect(targetRect & clipData->clipRect, color); - else if (clipData->hasRegionClip) { + } else if (clipData->hasRegionClip) { QVector rects = clipData->clipRegion.rects(); for ( int i = 0; i < rects.size(); i++ ) { QRect intersectRect = rects.at(i).intersected(targetRect.toRect()); if (!intersectRect.isEmpty()) { + unlock(); blitter->fillRect(intersectRect,color); } } } - }else { + } else { if (targetRect.x() >= 0 && targetRect.y() >= 0 && targetRect.width() <= raster->paintDevice()->width() - && targetRect.height() <= raster->paintDevice()->height()) + && targetRect.height() <= raster->paintDevice()->height()) { + unlock(); blitter->fillRect(targetRect,color); - else { + } else { QRectF deviceRect(0,0,raster->paintDevice()->width(), raster->paintDevice()->height()); + unlock(); blitter->fillRect(deviceRect&targetRect,color); } } @@ -247,14 +247,13 @@ public: uint hasXForm; }; -QBlitterPaintEngine::QBlitterPaintEngine(QPixmapData *p) +QBlitterPaintEngine::QBlitterPaintEngine(QBlittablePixmapData *p) : QPaintEngineEx(*(new QBlitterPaintEnginePrivate(p))) { } QBlitterPaintEngine::~QBlitterPaintEngine() { - Q_D(QBlitterPaintEngine); } QPainterState *QBlitterPaintEngine::createState(QPainterState *orig) const @@ -407,17 +406,20 @@ void QBlitterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) void QBlitterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) { Q_D(QBlitterPaintEngine); + d->lock(); d->raster->clip(path, op); d->updateClip(); } void QBlitterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op){ Q_D(QBlitterPaintEngine); + d->lock(); d->raster->clip(rect,op); d->updateClip(); } void QBlitterPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) { Q_D(QBlitterPaintEngine); + d->lock(); d->raster->clip(region,op); d->updateClip(); } @@ -425,12 +427,14 @@ void QBlitterPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) void QBlitterPaintEngine::clipEnabledChanged() { Q_D(QBlitterPaintEngine); + d->lock(); d->raster->clipEnabledChanged(); } void QBlitterPaintEngine::penChanged() { Q_D(QBlitterPaintEngine); + d->lock(); d->raster->penChanged(); d->capabillities->updateDrawRectBits(STATE_PEN_ENABLED,qpen_style(d->state->pen) != Qt::NoPen); } @@ -589,6 +593,7 @@ void QBlitterPaintEngine::drawTextItem(const QPointF &pos, const QTextItem &ti) void QBlitterPaintEngine::setState(QPainterState *s) { Q_D(QBlitterPaintEngine); + d->lock(); QPaintEngineEx::setState(s); d->raster->setState(s); d->state = (QRasterPaintEngineState *) s; @@ -609,7 +614,7 @@ class QBlittablePrivate { public: QBlittablePrivate(const QRect &rect, QBlittable::Capabilities caps) - : m_rect(rect), caps(caps) + : caps(caps), m_rect(rect) {} QBlittable::Capabilities caps; QRect m_rect; diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index 16b7b2c..8cd2f74 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -6,6 +6,7 @@ class QRasterPaintEngine; class QBlittablePrivate; class QBlitterPaintEnginePrivate; +class QBlittablePixmapData; // ### find name class Q_GUI_EXPORT QBlittable @@ -45,7 +46,7 @@ class Q_GUI_EXPORT QBlitterPaintEngine : public QPaintEngineEx { Q_DECLARE_PRIVATE(QBlitterPaintEngine); public: - QBlitterPaintEngine(QPixmapData *p); + QBlitterPaintEngine(QBlittablePixmapData *p); ~QBlitterPaintEngine(); virtual QPainterState *createState(QPainterState *orig) const; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 3f33319..5e3203a 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -458,8 +458,8 @@ bool QRasterPaintEngine::begin(QPaintDevice *device) if (device->devType() == QInternal::Pixmap) { QPixmap *pixmap = static_cast(device); - if (pixmap->data->classId() == QPixmapData::RasterClass) - d->device = pixmap->data->buffer(); + if (pixmap->data->classId() == QPixmapData::RasterClass || pixmap->data->classId() == QPixmapData::BlitterClass) + d->device = pixmap->data->buffer(); } else { d->device = device; } diff --git a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro index d4c93fd..8822a5b 100644 --- a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro +++ b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro @@ -3,11 +3,11 @@ include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems -QMAKE_CXXFLAGS += -I/usr/include/directfb -LIBS += -ldirectfb -lfusion -ldirect -lpthread +QMAKE_CXXFLAGS += -I/usr/local/include/directfb +LIBS += -L/usr/local/lib -ldirectfb -lfusion -ldirect -lpthread -SOURCES = main.cpp qgraphicssystem_minimaldfb.cpp qwindowsurface_minimaldfb.cpp -HEADERS = qgraphicssystem_minimaldfb.h qwindowsurface_minimaldfb.h +SOURCES = main.cpp qgraphicssystem_minimaldfb.cpp qwindowsurface_minimaldfb.cpp qblitter_directfb.cpp +HEADERS = qgraphicssystem_minimaldfb.h qwindowsurface_minimaldfb.h qblitter_directfb.h target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems INSTALLS += target diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp new file mode 100644 index 0000000..6800543 --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp @@ -0,0 +1,94 @@ +#include "qblitter_directfb.h" +#include "qgraphicssystem_minimaldfb.h" + +#include + +#include + +QDirectFbBlitter::QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface) + : QBlittable(rect, QBlittable::Capabilities(QBlittable::SolidRectCapability + |QBlittable::SourcePixmapCapability + |QBlittable::SourceOverPixmapCapability + |QBlittable::SourceOverScaledPixmapCapability)) +// 0)) +{ + DFBSurfaceDescription surfaceDesc; + surfaceDesc.width = rect.width(); + surfaceDesc.height = rect.height(); + surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT); + + if (surface) { + m_surface = surface; + } else { + IDirectFB *dfb = QDirectFbGraphicsSystem::dfbInterface(); + dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); + } +} + +void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color) +{ + m_surface->SetColor(m_surface, color.red(), color.green(), color.blue(), color.alpha()); + m_surface->SetDrawingFlags(m_surface, DSDRAW_NOFX); + m_surface->FillRectangle(m_surface, rect.x(), rect.y(), + rect.width(), rect.height()); +} + +void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &srcRect) +{ + quint32 blittingFlags = pixmap.hasAlphaChannel() ? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; + + m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags)); + m_surface->SetColor(m_surface, 0xff, 0xff, 0xff, 255); + +// QPixmapData *data = pixmap.pixmapData(); +// Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); +// QDirectFBPixmapData *dfbData = static_cast(data); +// IDirectFBSurface *s = dfbData->directFBSurface(); +// const DFBRectangle sRect = { srcRect.x(), srcRect.y(), rect.width(), rect.height() }; +// +// DFBResult result; +// if (rect.width() == srcRect.width() && rect.height() == srcRect.height()) +// result = surface->Blit(surface, s, &sRect, rect.x(), rect.y()); +// else { +// const DFBRectangle dRect = { rect.x(), rect.y(), rect.width(), rect.height() }; +// result = surface->StretchBlit(surface, s, &sRect, &dRect); +// } +// if (result != DFB_OK) +// DirectFBError("QDirectFBBlitter::drawPixmap()", result); + +} + +QImage *QDirectFbBlitter::lock() +{ + if (m_image.isNull()) { + if(!m_surface) + qDebug() << "Trying to lock null surface"; + if (!this->rect().isValid()) { + qDebug() << "No valid blitter rect"; + return 0; + } + + + + void *mem; + int bpl; + const DFBResult result = m_surface->Lock(m_surface, DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast(&mem), &bpl); + if (result == DFB_OK) { + QImage::Format format = QDirectFbGraphicsSystem::imageFormatFromSurface(m_surface); + int w, h; + m_surface->GetSize(m_surface,&w,&h); + m_image = QImage(static_cast(mem),w,h,format); + } else { + DirectFBError("Failed to lock image", result); + } + + } + + return &m_image; +} + +void QDirectFbBlitter::unlock() +{ + m_surface->Unlock(m_surface); + m_image = QImage(); +} diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h new file mode 100644 index 0000000..d60a390 --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h @@ -0,0 +1,24 @@ +#ifndef QDIRECTFBBLITTER_H +#define QDIRECTFBBLITTER_H + +#include + +#include + +class QDirectFbBlitter : public QBlittable +{ +public: + QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface = 0); + virtual ~QDirectFbBlitter(){ } + + virtual void fillRect(const QRectF &rect, const QColor &color); + virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect); + + virtual QImage *lock(); + virtual void unlock(); + + IDirectFBSurface *m_surface; + QImage m_image; +}; + +#endif // QDIRECTFBBLITTER_H diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index bf46d4c..a59cfd2 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -41,7 +41,13 @@ #include "qgraphicssystem_minimaldfb.h" #include "qwindowsurface_minimaldfb.h" -#include +#include "qblitter_directfb.h" + +#include +#include + +#include +#include #include #include @@ -51,7 +57,7 @@ QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int { DFBResult result = dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &m_layer); if (result != DFB_OK) { - DirectFBError("QDirectFbGraphicsSystemScreen::connect: " + DirectFBError("QDirectFbGraphicsSystemScreen " "Unable to get primary display layer!", result); } m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); @@ -106,30 +112,34 @@ IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect) return window; } +IDirectFB *QDirectFbGraphicsSystem::dfb = 0; + QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() { - DFBResult result = DFB_OK; - - { // pass command line arguments to DirectFB - const QStringList args = QCoreApplication::arguments(); - int argc = args.size(); - char **argv = new char*[argc]; - - for (int i = 0; i < argc; ++i) - argv[i] = qstrdup(args.at(i).toLocal8Bit().constData()); + if (!dfb) { + DFBResult result = DFB_OK; + + { // pass command line arguments to DirectFB + const QStringList args = QCoreApplication::arguments(); + int argc = args.size(); + char **argv = new char*[argc]; + + for (int i = 0; i < argc; ++i) + argv[i] = qstrdup(args.at(i).toLocal8Bit().constData()); + + result = DirectFBInit(&argc, &argv); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen: error initializing DirectFB", + result); + } + delete[] argv; + } - result = DirectFBInit(&argc, &argv); + result = DirectFBCreate(&dfb); if (result != DFB_OK) { - DirectFBError("QDirectFBScreen: error initializing DirectFB", + DirectFBError("QDirectFBScreen: error creating DirectFB interface", result); } - delete[] argv; - } - - result = DirectFBCreate(&dfb); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreen: error creating DirectFB interface", - result); } mPrimaryScreen = new QDirectFbGraphicsSystemScreen(dfb,0); @@ -138,12 +148,20 @@ QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() QPixmapData *QDirectFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const { - return new QRasterPixmapData(type); + return new QBlittablePixmapData(type); +// return new QRasterPixmapData(type); } QWindowSurface *QDirectFbGraphicsSystem::createWindowSurface(QWidget *widget) const { return new QDirectFbWindowSurface (mPrimaryScreen, widget); +// return new QRasterWindowSurface(widget); +} + +QBlittable *QDirectFbGraphicsSystem::createBlittable(const QRect &rect) const +{ + return new QDirectFbBlitter(rect); +// return 0; } QImage::Format QDirectFbGraphicsSystem::imageFormatFromSurface(IDirectFBSurface *surface) @@ -186,4 +204,9 @@ QImage::Format QDirectFbGraphicsSystem::imageFormatFromSurface(IDirectFBSurface } +IDirectFB *QDirectFbGraphicsSystem::dfbInterface() +{ + return dfb; +} + QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h index fbc5498..148086c 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h @@ -77,13 +77,15 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QWindowSurface *createWindowSurface(QWidget *widget) const; + QBlittable *createBlittable(const QRect &rect) const; QList screens() const { return mScreens; } static QImage::Format imageFormatFromSurface(IDirectFBSurface *surface); + static IDirectFB *dfbInterface(); private: - IDirectFB *dfb; + static IDirectFB *dfb; QDirectFbGraphicsSystemScreen *mPrimaryScreen; QList mScreens; }; diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index e75a43c..86d16d3 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -41,6 +41,9 @@ #include "qwindowsurface_minimaldfb.h" #include "qgraphicssystem_minimaldfb.h" +#include "qblitter_directfb.h" +#include + #include QT_BEGIN_NAMESPACE @@ -55,6 +58,13 @@ QDirectFbWindowSurface::QDirectFbWindowSurface if (result != DFB_OK) { DirectFBError("QDirectFbWindowSurface::QDirectFbWindowSurface: unable to get windows surface",result); } + QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); + pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); + pmdata->resize(window->width(),window->height()); + pmdata->setBlittable(blitter); + + m_pixmap = new QPixmap(pmdata); + } QDirectFbWindowSurface::~QDirectFbWindowSurface() @@ -63,7 +73,7 @@ QDirectFbWindowSurface::~QDirectFbWindowSurface() QPaintDevice *QDirectFbWindowSurface::paintDevice() { - return m_image; + return m_pixmap; } void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) @@ -71,6 +81,7 @@ void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const Q_UNUSED(widget); Q_UNUSED(offset); + m_dfbSurface->Unlock(m_dfbSurface); const quint8 windowOpacity = quint8(widget->windowOpacity() * 0xff); m_dfbWindow->SetOpacity(m_dfbWindow,windowOpacity); @@ -85,11 +96,7 @@ void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const void QDirectFbWindowSurface::setGeometry(const QRect &rect) { // qDebug() << "QDirectF.bWindowSurface::setGeometry:" << (long)this << rect; - bool wasLocked = false; - if (m_lock){ - m_dfbSurface->Unlock(m_dfbSurface); - wasLocked = true; - } + m_dfbSurface->Release(m_dfbSurface); QWindowSurface::setGeometry(rect); m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), @@ -98,10 +105,15 @@ void QDirectFbWindowSurface::setGeometry(const QRect &rect) // m_dfbWindow->MoveTo(m_dfbWindow,rect.x(),rect.y()); DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); if (result != DFB_OK) - qDebug() << "could not resurface"; + DirectFBError("QDirectFbWindowSurface::setGeometry() failed to retrieve new surface",result); + + QPixmap *oldpixmap = m_pixmap; + QDirectFbBlitter *blitter = new QDirectFbBlitter(rect, m_dfbSurface); + pmdata->resize(rect.width(),rect.height()); + pmdata->setBlittable(blitter); + m_pixmap = new QPixmap(pmdata); + delete oldpixmap; - if (wasLocked) - lockSurfaceToImage(); } bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) @@ -112,36 +124,11 @@ bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) void QDirectFbWindowSurface::beginPaint(const QRegion ®ion) { Q_UNUSED(region); - if (!m_lock) - lockSurfaceToImage(); } void QDirectFbWindowSurface::endPaint(const QRegion ®ion) { Q_UNUSED(region); - if (m_lock){ - m_dfbSurface->Unlock(m_dfbSurface); - m_lock = false; - } -} - -void QDirectFbWindowSurface::lockSurfaceToImage() -{ - if (m_lock) - return; - m_lock = true; - - int w,h; - m_dfbSurface->GetSize(m_dfbSurface,&w,&h); - uchar *data; - int bpl; - DFBResult result = m_dfbSurface->Lock(m_dfbSurface,static_cast(DSLF_READ|DSLF_WRITE),reinterpret_cast(&data),&bpl); - if (!result == DFB_OK) { - DirectFBError("QDirectFbWindowSurface::lockSurfaceToImage() failed to lock surface",result); - return; - } - QImage::Format format = QDirectFbGraphicsSystem::imageFormatFromSurface(m_dfbSurface); - m_image = new QImage(data,w,h,bpl,format); } QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h index fe88878..98575ff 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h @@ -43,6 +43,8 @@ #define QWINDOWSURFACE_MINIMAL_H #include +#include + #include QT_BEGIN_NAMESPACE @@ -68,7 +70,8 @@ private: void lockSurfaceToImage(); QDirectFbGraphicsSystemScreen *m_screen; - QImage *m_image; + QPixmap *m_pixmap; + QBlittablePixmapData *pmdata; bool m_lock; IDirectFBWindow *m_dfbWindow; -- cgit v0.12 From 79b6ad01115cc9208e8a22d8dc925215da9792ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 24 Nov 2009 13:25:23 +0100 Subject: Cleanup blitter and minimaldfb A QBlittable is now aware if it is locked or not. Created a seperate header file for DirectFB convenience functions --- src/gui/image/qpixmap_blitter.cpp | 5 +- src/gui/image/qpixmap_blitter_p.h | 8 +- src/gui/painting/qpaintengine_blitter.cpp | 28 +++++- src/gui/painting/qpaintengine_blitter_p.h | 6 +- .../graphicssystems/minimaldfb/minimaldfb.pro | 21 +++-- .../minimaldfb/qblitter_directfb.cpp | 86 ++++++++--------- .../graphicssystems/minimaldfb/qblitter_directfb.h | 5 +- .../minimaldfb/qdirectfbconvenience.cpp | 43 +++++++++ .../minimaldfb/qdirectfbconvenience.h | 22 +++++ .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 102 ++++++--------------- .../minimaldfb/qgraphicssystem_minimaldfb.h | 4 +- .../minimaldfb/qwindowsurface_minimaldfb.cpp | 8 +- 12 files changed, 188 insertions(+), 150 deletions(-) create mode 100644 src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp create mode 100644 src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 5ecc01d..82e0045 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -10,6 +10,8 @@ QBlittablePixmapData::QBlittablePixmapData(QPixmapData::PixelType type) QBlittablePixmapData::~QBlittablePixmapData() { + delete m_blittable; + delete m_engine; } QBlittable *QBlittablePixmapData::blittable() @@ -34,10 +36,9 @@ void QBlittablePixmapData::resize(int width, int height) m_blittable = 0; delete m_engine; m_engine = 0; - d = 32; + d = QApplicationPrivate::graphicsSystem()->screens().at(0)->depth(); w = width; h = height; -// d = image.depth(); is_null = (w <= 0 || h <= 0); } extern int qt_defaultDpiX(); diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index 3ed2fe4..5e01a12 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -21,12 +21,13 @@ public: //should never be called } - QImage *lock() +protected: + QImage *doLock() { return ℑ } - void unlock() + void doUnlock() { } @@ -36,6 +37,7 @@ private: class Q_GUI_EXPORT QBlittablePixmapData : public QPixmapData { +// Q_DECLARE_PRIVATE(QBlittablePixmapData); public: QBlittablePixmapData(QPixmapData::PixelType type); ~QBlittablePixmapData(); @@ -52,10 +54,10 @@ public: void fromImage(const QImage &image, Qt::ImageConversionFlags flags); QPaintEngine *paintEngine() const; - protected: QBlitterPaintEngine *m_engine; QBlittable *m_blittable; + }; #endif // QPIXMAP_BLITTER_P_H diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 0632ae0..7336dcc 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -157,7 +157,6 @@ public: blitter= p->blittable(); raster = new QRasterPaintEngine(p->buffer()); capabillities = new CapabilitiesToStateMask(blitter->capabilities()); - lock(); } inline void lock() { @@ -175,12 +174,12 @@ public: } void fillRect(const QRectF &rect, const QColor &color) { - lock(); +// lock(); QRectF targetRect = rect; if (hasXForm) { targetRect = state->matrix.mapRect(rect); } - QClipData *clipData = raster->state()->clip; + QClipData *clipData = state->clip; if (clipData) { if (clipData->hasRectClip) { unlock(); @@ -614,10 +613,12 @@ class QBlittablePrivate { public: QBlittablePrivate(const QRect &rect, QBlittable::Capabilities caps) - : caps(caps), m_rect(rect) + : caps(caps), m_rect(rect), locked(false), cachedImg(0) {} QBlittable::Capabilities caps; QRect m_rect; + bool locked; + QImage *cachedImg; }; @@ -644,3 +645,22 @@ QRect QBlittable::rect() const return d->m_rect; } +QImage *QBlittable::lock() +{ + Q_D(QBlittable); + if (!d->locked) { + d->cachedImg = doLock(); + d->locked = true; + } + + return d->cachedImg; +} + +void QBlittable::unlock() +{ + Q_D(QBlittable); + if (d->locked) { + doUnlock(); + d->locked = false; + } +} diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index 8cd2f74..6a5462e 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -34,10 +34,12 @@ public: virtual void fillRect(const QRectF &rect, const QColor &color) = 0; virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect) = 0; - virtual QImage *lock() = 0; - virtual void unlock() = 0; + QImage *lock(); + void unlock(); protected: + virtual QImage *doLock() = 0; + virtual void doUnlock() = 0; QBlittablePrivate *d_ptr; }; diff --git a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro index 8822a5b..c3f20ff 100644 --- a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro +++ b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro @@ -1,13 +1,20 @@ TARGET = qminimaldfb include(../../qpluginbase.pri) - QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - QMAKE_CXXFLAGS += -I/usr/local/include/directfb -LIBS += -L/usr/local/lib -ldirectfb -lfusion -ldirect -lpthread - -SOURCES = main.cpp qgraphicssystem_minimaldfb.cpp qwindowsurface_minimaldfb.cpp qblitter_directfb.cpp -HEADERS = qgraphicssystem_minimaldfb.h qwindowsurface_minimaldfb.h qblitter_directfb.h - +LIBS += -L/usr/local/lib \ + -ldirectfb \ + -lfusion \ + -ldirect \ + -lpthread +SOURCES = main.cpp \ + qgraphicssystem_minimaldfb.cpp \ + qwindowsurface_minimaldfb.cpp \ + qblitter_directfb.cpp \ + qdirectfbconvenience.cpp +HEADERS = qgraphicssystem_minimaldfb.h \ + qwindowsurface_minimaldfb.h \ + qblitter_directfb.h \ + qdirectfbconvenience.h target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems INSTALLS += target diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp index 6800543..05221ce 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp @@ -1,5 +1,8 @@ #include "qblitter_directfb.h" #include "qgraphicssystem_minimaldfb.h" +#include "qdirectfbconvenience.h" + +#include #include @@ -10,17 +13,16 @@ QDirectFbBlitter::QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface) |QBlittable::SourcePixmapCapability |QBlittable::SourceOverPixmapCapability |QBlittable::SourceOverScaledPixmapCapability)) -// 0)) { - DFBSurfaceDescription surfaceDesc; - surfaceDesc.width = rect.width(); - surfaceDesc.height = rect.height(); - surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT); - if (surface) { m_surface = surface; } else { - IDirectFB *dfb = QDirectFbGraphicsSystem::dfbInterface(); + DFBSurfaceDescription surfaceDesc; + surfaceDesc.width = rect.width(); + surfaceDesc.height = rect.height(); + surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT); + + IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); } } @@ -40,55 +42,47 @@ void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, con m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags)); m_surface->SetColor(m_surface, 0xff, 0xff, 0xff, 255); -// QPixmapData *data = pixmap.pixmapData(); -// Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); -// QDirectFBPixmapData *dfbData = static_cast(data); -// IDirectFBSurface *s = dfbData->directFBSurface(); -// const DFBRectangle sRect = { srcRect.x(), srcRect.y(), rect.width(), rect.height() }; -// -// DFBResult result; -// if (rect.width() == srcRect.width() && rect.height() == srcRect.height()) -// result = surface->Blit(surface, s, &sRect, rect.x(), rect.y()); -// else { -// const DFBRectangle dRect = { rect.x(), rect.y(), rect.width(), rect.height() }; -// result = surface->StretchBlit(surface, s, &sRect, &dRect); -// } -// if (result != DFB_OK) -// DirectFBError("QDirectFBBlitter::drawPixmap()", result); + QPixmapData *data = pixmap.pixmapData(); + Q_ASSERT(data->classId() == QPixmapData::BlitterClass); + QBlittablePixmapData *blitPm = static_cast(data); + QDirectFbBlitter *dfbBlitter = static_cast(blitPm->blittable()); -} + IDirectFBSurface *s = dfbBlitter->m_surface; + const DFBRectangle sRect = { srcRect.x(), srcRect.y(), rect.width(), rect.height() }; -QImage *QDirectFbBlitter::lock() -{ - if (m_image.isNull()) { - if(!m_surface) - qDebug() << "Trying to lock null surface"; - if (!this->rect().isValid()) { - qDebug() << "No valid blitter rect"; - return 0; + DFBResult result; + if (rect.width() == srcRect.width() && rect.height() == srcRect.height()) + result = m_surface->Blit(m_surface, s, &sRect, rect.x(), rect.y()); + else { + const DFBRectangle dRect = { rect.x(), rect.y(), rect.width(), rect.height() }; + result = m_surface->StretchBlit(m_surface, s, &sRect, &dRect); } + if (result != DFB_OK) + DirectFBError("QDirectFBBlitter::drawPixmap()", result); +} - - void *mem; - int bpl; - const DFBResult result = m_surface->Lock(m_surface, DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast(&mem), &bpl); - if (result == DFB_OK) { - QImage::Format format = QDirectFbGraphicsSystem::imageFormatFromSurface(m_surface); - int w, h; - m_surface->GetSize(m_surface,&w,&h); - m_image = QImage(static_cast(mem),w,h,format); - } else { - DirectFBError("Failed to lock image", result); - } - +QImage *QDirectFbBlitter::doLock() +{ + Q_ASSERT(m_surface); + Q_ASSERT(rect().isValid()); + + void *mem; + int bpl; + const DFBResult result = m_surface->Lock(m_surface, DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast(&mem), &bpl); + if (result == DFB_OK) { + QImage::Format format = QDirectFbConvenience::imageFormatFromSurface(m_surface); + int w, h; + m_surface->GetSize(m_surface,&w,&h); + m_image = QImage(static_cast(mem),w,h,format); + } else { + DirectFBError("Failed to lock image", result); } return &m_image; } -void QDirectFbBlitter::unlock() +void QDirectFbBlitter::doUnlock() { m_surface->Unlock(m_surface); - m_image = QImage(); } diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h index d60a390..252bf80 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h @@ -14,8 +14,9 @@ public: virtual void fillRect(const QRectF &rect, const QColor &color); virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect); - virtual QImage *lock(); - virtual void unlock(); +protected: + virtual QImage *doLock(); + virtual void doUnlock(); IDirectFBSurface *m_surface; QImage m_image; diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp new file mode 100644 index 0000000..d958482 --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp @@ -0,0 +1,43 @@ +#include "qdirectfbconvenience.h" + +IDirectFB *QDirectFbConvenience::dfb = 0; + +QImage::Format QDirectFbConvenience::imageFormatFromSurface(IDirectFBSurface *surface) +{ + DFBSurfacePixelFormat format; + surface->GetPixelFormat(surface, &format); + + switch (format) { + case DSPF_LUT8: + return QImage::Format_Indexed8; + case DSPF_RGB24: + return QImage::Format_RGB888; + case DSPF_ARGB4444: + return QImage::Format_ARGB4444_Premultiplied; + case DSPF_RGB444: + return QImage::Format_RGB444; + case DSPF_RGB555: + case DSPF_ARGB1555: + return QImage::Format_RGB555; + case DSPF_RGB16: + return QImage::Format_RGB16; + case DSPF_ARGB6666: + return QImage::Format_ARGB6666_Premultiplied; + case DSPF_RGB18: + return QImage::Format_RGB666; + case DSPF_RGB32: + return QImage::Format_RGB32; + case DSPF_ARGB: { + DFBSurfaceCapabilities caps; + const DFBResult result = surface->GetCapabilities(surface, &caps); + Q_ASSERT(result == DFB_OK); + Q_UNUSED(result); + return (caps & DSCAPS_PREMULTIPLIED + ? QImage::Format_ARGB32_Premultiplied + : QImage::Format_ARGB32); } + default: + break; + } + return QImage::Format_Invalid; + +} diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h new file mode 100644 index 0000000..7e426db --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h @@ -0,0 +1,22 @@ +#ifndef QDIRECTFBCONVENIENCE_H +#define QDIRECTFBCONVENIENCE_H + +#include + +#include + +class QDirectFbConvenience +{ +public: + static QImage::Format imageFormatFromSurface(IDirectFBSurface *surface); + + //This is set by the graphicssystem constructor + static IDirectFB *dfbInterface() { return dfb; } + +private: + static void setDfbInterface(IDirectFB *dfbInterface) {dfb = dfbInterface;} + static IDirectFB *dfb; + friend class QDirectFbGraphicsSystem; +}; + +#endif // QDIRECTFBCONVENIENCE_H diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index a59cfd2..117e4b5 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -42,6 +42,7 @@ #include "qgraphicssystem_minimaldfb.h" #include "qwindowsurface_minimaldfb.h" #include "qblitter_directfb.h" +#include "qdirectfbconvenience.h" #include #include @@ -65,7 +66,7 @@ QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int IDirectFBSurface *topLevelSurface; //This line gives a warning m_layer->GetSurface(m_layer, &topLevelSurface); - m_format = QDirectFbGraphicsSystem::imageFormatFromSurface(topLevelSurface); + m_format = QDirectFbConvenience::imageFormatFromSurface(topLevelSurface); result = m_layer->GetScreen(m_layer,&m_screen); if (result != DFB_OK) { @@ -73,9 +74,9 @@ QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int } int w(0),h(0); + //Asking the screen for its size gives the desktop geometry on X11 - //Thats not something we want, so as the topLevelSorface instead -// m_screen->GetSize(m_screen,&w,&h); + //Thats not something we want, so ask the topLevelSorface instead topLevelSurface->GetSize(topLevelSurface,&w,&h); m_geometry = QRect(0,0,w,h); @@ -112,35 +113,32 @@ IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect) return window; } -IDirectFB *QDirectFbGraphicsSystem::dfb = 0; QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() { - if (!dfb) { - DFBResult result = DFB_OK; - - { // pass command line arguments to DirectFB - const QStringList args = QCoreApplication::arguments(); - int argc = args.size(); - char **argv = new char*[argc]; - - for (int i = 0; i < argc; ++i) - argv[i] = qstrdup(args.at(i).toLocal8Bit().constData()); - - result = DirectFBInit(&argc, &argv); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreen: error initializing DirectFB", - result); - } - delete[] argv; - } - - result = DirectFBCreate(&dfb); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreen: error creating DirectFB interface", - result); - } + IDirectFB *dfb; + DFBResult result = DFB_OK; + + const QStringList args = QCoreApplication::arguments(); + int argc = args.size(); + char **argv = new char*[argc]; + + for (int i = 0; i < argc; ++i) + argv[i] = qstrdup(args.at(i).toLocal8Bit().constData()); + + result = DirectFBInit(&argc, &argv); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen: error initializing DirectFB", + result); + } + delete[] argv; + + result = DirectFBCreate(&dfb); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen: error creating DirectFB interface", + result); } + QDirectFbConvenience::setDfbInterface(dfb); mPrimaryScreen = new QDirectFbGraphicsSystemScreen(dfb,0); mScreens.append(mPrimaryScreen); @@ -149,64 +147,16 @@ QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() QPixmapData *QDirectFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const { return new QBlittablePixmapData(type); -// return new QRasterPixmapData(type); } QWindowSurface *QDirectFbGraphicsSystem::createWindowSurface(QWidget *widget) const { return new QDirectFbWindowSurface (mPrimaryScreen, widget); -// return new QRasterWindowSurface(widget); } QBlittable *QDirectFbGraphicsSystem::createBlittable(const QRect &rect) const { return new QDirectFbBlitter(rect); -// return 0; -} - -QImage::Format QDirectFbGraphicsSystem::imageFormatFromSurface(IDirectFBSurface *surface) -{ - DFBSurfacePixelFormat format; - surface->GetPixelFormat(surface, &format); - - switch (format) { - case DSPF_LUT8: - return QImage::Format_Indexed8; - case DSPF_RGB24: - return QImage::Format_RGB888; - case DSPF_ARGB4444: - return QImage::Format_ARGB4444_Premultiplied; - case DSPF_RGB444: - return QImage::Format_RGB444; - case DSPF_RGB555: - case DSPF_ARGB1555: - return QImage::Format_RGB555; - case DSPF_RGB16: - return QImage::Format_RGB16; - case DSPF_ARGB6666: - return QImage::Format_ARGB6666_Premultiplied; - case DSPF_RGB18: - return QImage::Format_RGB666; - case DSPF_RGB32: - return QImage::Format_RGB32; - case DSPF_ARGB: { - DFBSurfaceCapabilities caps; - const DFBResult result = surface->GetCapabilities(surface, &caps); - Q_ASSERT(result == DFB_OK); - Q_UNUSED(result); - return (caps & DSCAPS_PREMULTIPLIED - ? QImage::Format_ARGB32_Premultiplied - : QImage::Format_ARGB32); } - default: - break; - } - return QImage::Format_Invalid; - -} - -IDirectFB *QDirectFbGraphicsSystem::dfbInterface() -{ - return dfb; } QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h index 148086c..462e963 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h @@ -81,11 +81,9 @@ public: QList screens() const { return mScreens; } - static QImage::Format imageFormatFromSurface(IDirectFBSurface *surface); - static IDirectFB *dfbInterface(); + private: - static IDirectFB *dfb; QDirectFbGraphicsSystemScreen *mPrimaryScreen; QList mScreens; }; diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 86d16d3..3dcf5be 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -60,7 +60,9 @@ QDirectFbWindowSurface::QDirectFbWindowSurface } QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); - pmdata->resize(window->width(),window->height()); + int width,height; + m_dfbSurface->GetSize(m_dfbSurface, &width, &height); + pmdata->resize(width,height); pmdata->setBlittable(blitter); m_pixmap = new QPixmap(pmdata); @@ -95,14 +97,10 @@ void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const void QDirectFbWindowSurface::setGeometry(const QRect &rect) { -// qDebug() << "QDirectF.bWindowSurface::setGeometry:" << (long)this << rect; - m_dfbSurface->Release(m_dfbSurface); QWindowSurface::setGeometry(rect); m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), rect.width(), rect.height()); -// m_dfbWindow->Resize(m_dfbWindow,rect.width(),rect.height()); -// m_dfbWindow->MoveTo(m_dfbWindow,rect.x(),rect.y()); DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); if (result != DFB_OK) DirectFBError("QDirectFbWindowSurface::setGeometry() failed to retrieve new surface",result); -- cgit v0.12 From cd33927ac31c37ed3feb6a5a3be28d3d152bda19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 25 Nov 2009 10:54:54 +0100 Subject: Fix QBlittablePixmapData::fromImage There is still a stride problem when running the browser demo --- src/gui/image/qpixmap_blitter.cpp | 28 +++++++++++++++++----------- src/gui/image/qpixmap_blitter_p.h | 33 +-------------------------------- src/gui/image/qpixmapdata_p.h | 1 - 3 files changed, 18 insertions(+), 44 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 82e0045..35d6ddb 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -1,5 +1,7 @@ #include "qpixmap_blitter_p.h" +#include + #include #include @@ -14,10 +16,11 @@ QBlittablePixmapData::~QBlittablePixmapData() delete m_engine; } -QBlittable *QBlittablePixmapData::blittable() +QBlittable *QBlittablePixmapData::blittable() const { if (!m_blittable) { - m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QRect(0,0,w,h)); + QBlittablePixmapData *that = const_cast(this); + that->m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QRect(0,0,w,h)); } return m_blittable; @@ -73,32 +76,35 @@ int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const void QBlittablePixmapData::fill(const QColor &color) { - if (m_blittable->capabilities() & QBlittable::SolidRectCapability) - m_blittable->fillRect(m_blittable->rect(),color); + if (blittable()->capabilities() & QBlittable::SolidRectCapability) + blittable()->fillRect(m_blittable->rect(),color); else - m_blittable->lock()->fill(color.rgb()); + blittable()->lock()->fill(color.rgb()); } QImage *QBlittablePixmapData::buffer() { - return m_blittable->lock(); + return blittable()->lock(); } QImage QBlittablePixmapData::toImage() const { - return m_blittable->lock()->copy(); + return blittable()->lock()->copy(); } bool QBlittablePixmapData::hasAlphaChannel() const { - return m_blittable->lock()->hasAlphaChannel(); + return blittable()->lock()->hasAlphaChannel(); } void QBlittablePixmapData::fromImage(const QImage &image, - Qt::ImageConversionFlags) + Qt::ImageConversionFlags flags) { - m_blittable = new QImageBlitter(image); - m_engine = 0; + resize(image.width(),image.height()); + QImage *thisImg = blittable()->lock(); + QPainter p(thisImg); + p.drawImage(0,0,image,flags); + } QPaintEngine *QBlittablePixmapData::paintEngine() const diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index 5e01a12..ca834dc 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -4,37 +4,6 @@ #include #include -class QImageBlitter : public QBlittable -{ -public: - QImageBlitter(const QImage &img) - : QBlittable(img.rect(),0), image(img) - { - } - - void fillRect(const QRectF &, const QColor &) - { - //should never be called - } - void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) - { - //should never be called - } - -protected: - QImage *doLock() - { - return ℑ - } - - void doUnlock() - { - } - -private: - QImage image; -}; - class Q_GUI_EXPORT QBlittablePixmapData : public QPixmapData { // Q_DECLARE_PRIVATE(QBlittablePixmapData); @@ -42,7 +11,7 @@ public: QBlittablePixmapData(QPixmapData::PixelType type); ~QBlittablePixmapData(); - QBlittable *blittable(); + QBlittable *blittable() const; void setBlittable(QBlittable *blittable); void resize(int width, int height); diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index a668f0a..292092f 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -137,7 +137,6 @@ private: friend class QX11PixmapData; friend class QS60PixmapData; friend class QImagePixmapCleanupHooks; // Needs to set is_cached - friend class QBlittablPixmapData; friend class QGLTextureCache; //Needs to check the reference count friend class QExplicitlySharedDataPointer; -- cgit v0.12 From 33e4969e7c7244943d48433cdb5ac086c517737a Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 25 Nov 2009 14:07:54 +0100 Subject: simplify QGraphicsSystemCursor, update vnc and testlite plugins --- src/gui/kernel/qwidget_lite.cpp | 13 ++++++---- src/gui/painting/qgraphicssystemcursor.cpp | 17 +++---------- src/gui/painting/qgraphicssystemcursor.h | 7 +++--- .../testlite/qgraphicssystem_testlite.cpp | 24 ++++--------------- src/plugins/graphicssystems/testlite/x11util.cpp | 1 + src/plugins/graphicssystems/vnc/qvnccursor.cpp | 28 +++++++--------------- src/plugins/graphicssystems/vnc/qvnccursor.h | 4 +--- 7 files changed, 30 insertions(+), 64 deletions(-) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 88df81f..0f4dec7 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -678,7 +678,7 @@ void qt_lite_set_cursor(QWidget * w, bool force) if (w == 0) { if (override) { if (QGraphicsSystemCursor::instance) { - QGraphicsSystemCursor::instance->changeCursor(override); + QGraphicsSystemCursor::instance->changeCursor(override, QApplication::topLevelAt(QCursor::pos())); } return; } @@ -692,10 +692,12 @@ void qt_lite_set_cursor(QWidget * w, bool force) w = lastUnderMouse; } - if (w == QApplication::desktop()) { + if (w == QApplication::desktop() && !override) { if (QGraphicsSystemCursor::instance) { - QGraphicsSystemCursor::instance->changeCursor(w); + QCursor c(Qt::ArrowCursor); + QGraphicsSystemCursor::instance->changeCursor(&c, w); } + return; } QWidget * curWin = QApplication::activeWindow(); @@ -704,11 +706,12 @@ void qt_lite_set_cursor(QWidget * w, bool force) QWidget* cW = w && !w->internalWinId() ? w : curWin; if (!cW || cW->window() != w->window() || - !cW->isVisible() || !cW->underMouse() || QApplication::overrideCursor()) + !cW->isVisible() || !cW->underMouse() || override) return; if (QGraphicsSystemCursor::instance) { - QGraphicsSystemCursor::instance->changeCursor(w); + QCursor c = w->cursor(); + QGraphicsSystemCursor::instance->changeCursor(&c, w); } } QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp index cad914d..3afaf4b 100644 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -104,12 +104,14 @@ QRect QGraphicsSystemCursor::getCurrentRect() void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & e) { + Q_UNUSED(e); currentRect = getCurrentRect(); screen->setDirty(currentRect); } -void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor) +void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) { + Q_UNUSED(widget); Qt::CursorShape shape = widgetCursor->shape(); if (shape == Qt::BitmapCursor) { @@ -126,19 +128,6 @@ void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor) screen->setDirty(currentRect); } -void QGraphicsSystemCursor::changeCursor(QWidget * widget) -{ - if (widget) { - QCursor widgetCursor = widget->cursor(); - changeCursor(&widgetCursor); - } else { - // default cursor - setCursor(Qt::ArrowCursor); - currentRect = getCurrentRect(); - screen->setDirty(currentRect); - } -} - // End of display and pointer event handling code // Beginning of built-in cursor graphics // from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp diff --git a/src/gui/painting/qgraphicssystemcursor.h b/src/gui/painting/qgraphicssystemcursor.h index ea30319..1e26db2 100644 --- a/src/gui/painting/qgraphicssystemcursor.h +++ b/src/gui/painting/qgraphicssystemcursor.h @@ -71,11 +71,8 @@ public: virtual ~QGraphicsSystemCursor(); // input methods - virtual void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); - virtual void setCursor(Qt::CursorShape shape); virtual void pointerEvent(const QMouseEvent & event); - virtual void changeCursor(QWidget * widget); - virtual void changeCursor(QCursor * widgetCursor); + virtual void changeCursor(QCursor * widgetCursor, QWidget * widget); // output methods virtual QRect drawCursor(QPainter &); @@ -94,6 +91,8 @@ protected: QGraphicsSystemCursorImage * graphic; private: + void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + void setCursor(Qt::CursorShape shape); QRect getCurrentRect(); }; diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp index 64386b7..450905c 100644 --- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp @@ -56,37 +56,23 @@ class MyCursor : QGraphicsSystemCursor public: MyCursor(QGraphicsSystemScreen *screen) : QGraphicsSystemCursor(screen) {} - // input methods - void setCursor(const uchar */*data*/, const uchar */*mask*/, int width, int height, int hotX, int hotY) {qDebug() << "setCursor data..." << width << height << hotX << hotY;} - - void setCursor(Qt::CursorShape shape) { - static int oldshape = -1; - if (shape != oldshape) { - qDebug() << "setCursor" << shape; QGraphicsSystemCursor::setCursor(shape); - oldshape = shape; - } - } - - void changeCursor(QWidget * widget) { - + void changeCursor(QCursor * cursor, QWidget * widget) { QTestLiteWindowSurface *ws = 0; if (widget) { QWidget *window = widget->window(); ws = static_cast(window->windowSurface()); + } else { + // No X11 cursor control when there is no widget under the cursor + return; } //qDebug() << "changeCursor" << widget << ws; if (!ws) return; - ws->setCursor(widget->cursor().shape()); + ws->setCursor(cursor->shape()); } -// void changeCursor(QCursor * widgetCursor) { -// //qDebug() << "changeCursor widgetCursor"; -// QGraphicsSystemCursor::changeCursor(widgetCursor); -// } - //#### remove this void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index 5830550..e2fbd62 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -846,6 +846,7 @@ void MyWindow::setCursorShape(int cshape) cursors[cshape] = cursor; } XDefineCursor(xd->display, window, cursor); + XFlush(xd->display); } diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.cpp b/src/plugins/graphicssystems/vnc/qvnccursor.cpp index aa0f109..55d1c61 100644 --- a/src/plugins/graphicssystems/vnc/qvnccursor.cpp +++ b/src/plugins/graphicssystems/vnc/qvnccursor.cpp @@ -58,36 +58,26 @@ QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCGraphicsSystemScreen *scr ) { } -void QVNCCursor::setCursorMode(bool vnc) +void QVNCCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) { - if (vnc) { - screen->setDirty(prevRect); - prevRect = QRect(); - server->setDirtyCursor(); - } else { - server->setDirtyCursor(); - } - useVncCursor = vnc; -} - -void QVNCCursor::setCursor(Qt::CursorShape shape) -{ - QGraphicsSystemCursor::setCursor(shape); + QGraphicsSystemCursor::changeCursor(widgetCursor, widget); if (useVncCursor) { server->setDirtyCursor(); } else { - screen->setDirty(QRect(QRect(0,0,1,1))); + screen->setDirty(QRect(0,0,1,1)); } } -void QVNCCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) +void QVNCCursor::setCursorMode(bool vnc) { - QGraphicsSystemCursor::setCursor(data, mask, width, height, hotX, hotY); - if (useVncCursor) { + if (vnc) { + screen->setDirty(prevRect); + prevRect = QRect(); server->setDirtyCursor(); } else { - screen->setDirty(QRect(0,0,1,1)); + server->setDirtyCursor(); } + useVncCursor = vnc; } QRect QVNCCursor::drawCursor(QPainter & painter) diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.h b/src/plugins/graphicssystems/vnc/qvnccursor.h index 1a53da7..a90b7e2 100644 --- a/src/plugins/graphicssystems/vnc/qvnccursor.h +++ b/src/plugins/graphicssystems/vnc/qvnccursor.h @@ -57,9 +57,7 @@ public: // input methods void setCursorMode(bool vnc); - void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); - void setCursor(Qt::CursorShape shape); - + void changeCursor(QCursor * widgetCursor, QWidget * widget); // output methods QRect drawCursor(QPainter &); -- cgit v0.12 From a684c3429445ca88736ac8065a9d7ecfe58f3857 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 25 Nov 2009 15:02:50 +0100 Subject: QGraphicsSystemCursor::getInstance() method to replace direct instance pointer access --- src/gui/kernel/qapplication_lite.cpp | 5 +++-- src/gui/kernel/qwidget_lite.cpp | 20 +++++++++----------- src/gui/painting/qgraphicssystemcursor.h | 4 +++- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index cdaa855..a42bfd7 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -526,8 +526,9 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) static QWidget *implicit_mouse_grabber=0; - if (QGraphicsSystemCursor::instance) - QGraphicsSystemCursor::instance->pointerEvent(ev); + QPointer cursor = QGraphicsSystemCursor::getInstance(); + if (cursor) + cursor->pointerEvent(ev); QPoint localPoint = ev.pos(); QPoint globalPoint = ev.globalPos(); diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 0f4dec7..5a629c0 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -675,11 +675,13 @@ void qt_lite_set_cursor(QWidget * w, bool force) if (override && w != 0) return; + QPointer cursor = QGraphicsSystemCursor::getInstance(); + if (!cursor) + return; + if (w == 0) { if (override) { - if (QGraphicsSystemCursor::instance) { - QGraphicsSystemCursor::instance->changeCursor(override, QApplication::topLevelAt(QCursor::pos())); - } + cursor->changeCursor(override, QApplication::topLevelAt(QCursor::pos())); return; } w = QApplication::widgetAt(QCursor::pos()); @@ -693,10 +695,8 @@ void qt_lite_set_cursor(QWidget * w, bool force) } if (w == QApplication::desktop() && !override) { - if (QGraphicsSystemCursor::instance) { - QCursor c(Qt::ArrowCursor); - QGraphicsSystemCursor::instance->changeCursor(&c, w); - } + QCursor c(Qt::ArrowCursor); + cursor->changeCursor(&c, w); return; } @@ -709,9 +709,7 @@ void qt_lite_set_cursor(QWidget * w, bool force) !cW->isVisible() || !cW->underMouse() || override) return; - if (QGraphicsSystemCursor::instance) { - QCursor c = w->cursor(); - QGraphicsSystemCursor::instance->changeCursor(&c, w); - } + QCursor c = w->cursor(); + cursor->changeCursor(&c, w); } QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystemcursor.h b/src/gui/painting/qgraphicssystemcursor.h index 1e26db2..f4d911f 100644 --- a/src/gui/painting/qgraphicssystemcursor.h +++ b/src/gui/painting/qgraphicssystemcursor.h @@ -78,9 +78,10 @@ public: virtual QRect drawCursor(QPainter &); virtual QRect dirtyRect(); - static QPointer instance; + static QPointer getInstance() { return instance; } protected: + static QPointer instance; QRect currentRect; // next place to draw the cursor QRect prevRect; // last place the cursor was drawn @@ -91,6 +92,7 @@ protected: QGraphicsSystemCursorImage * graphic; private: + void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); void setCursor(Qt::CursorShape shape); QRect getCurrentRect(); -- cgit v0.12 From 19039afd151f2c2401659904b89968d302149493 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 26 Nov 2009 12:53:59 +0100 Subject: remove an unused member from QGraphicsSystemCursor --- src/gui/painting/qgraphicssystemcursor.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/painting/qgraphicssystemcursor.h b/src/gui/painting/qgraphicssystemcursor.h index f4d911f..d385ac0 100644 --- a/src/gui/painting/qgraphicssystemcursor.h +++ b/src/gui/painting/qgraphicssystemcursor.h @@ -87,7 +87,6 @@ protected: QRect prevRect; // last place the cursor was drawn QGraphicsSystemScreen * screen; // Where to request an update - QWidget * currentWidget; // widget currently under the cursor QGraphicsSystemCursorImage * graphic; -- cgit v0.12 From c290785d0f8e1ef7af4bdff683aab40b8ff33681 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 26 Nov 2009 13:39:06 +0100 Subject: move software cursor from QGraphicsSystemCursor into QGraphicsSystemSoftwareCursor --- src/gui/painting/qgraphicssystemcursor.cpp | 72 +-------------------- src/gui/painting/qgraphicssystemcursor.h | 24 ++----- src/plugins/graphicssystems/fb_base/fb_base.cpp | 74 +++++++++++++++++++++- src/plugins/graphicssystems/fb_base/fb_base.h | 26 +++++++- .../linuxfb/qgraphicssystem_linuxfb.cpp | 2 +- .../testlite/qgraphicssystem_testlite.cpp | 8 --- src/plugins/graphicssystems/vnc/qvnccursor.cpp | 12 ++-- src/plugins/graphicssystems/vnc/qvnccursor.h | 5 +- 8 files changed, 111 insertions(+), 112 deletions(-) diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp index 3afaf4b..022dc64 100644 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -53,79 +53,9 @@ QT_BEGIN_NAMESPACE QPointer QGraphicsSystemCursor::instance = 0; QGraphicsSystemCursor::QGraphicsSystemCursor(QGraphicsSystemScreen *scr ) - :currentRect(QRect()), prevRect(QRect()), screen(scr) + : screen(scr) { - graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); instance = this; - setCursor(Qt::ArrowCursor); -} - -QGraphicsSystemCursor::~QGraphicsSystemCursor() -{ -} - -void QGraphicsSystemCursor::setCursor(Qt::CursorShape shape) -{ - graphic->set(shape); -} - -void QGraphicsSystemCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) -{ - graphic->set(data, mask, width, height, hotX, hotY); -} - -QRect QGraphicsSystemCursor::dirtyRect() -{ - if (!prevRect.isNull()) { - QRect rect = prevRect; - prevRect = QRect(); - return rect; - } - return QRect(); -} - -QRect QGraphicsSystemCursor::drawCursor(QPainter & painter) -{ - if (currentRect.isNull()) - return QRect(); - - prevRect = currentRect; - painter.drawImage(prevRect, *graphic->image()); - return prevRect; -} - -QRect QGraphicsSystemCursor::getCurrentRect() -{ - QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(), - -graphic->hotspot().y()); - rect.translate(QCursor::pos()); - return rect; -} - -void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & e) -{ - Q_UNUSED(e); - currentRect = getCurrentRect(); - screen->setDirty(currentRect); -} - -void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) -{ - Q_UNUSED(widget); - Qt::CursorShape shape = widgetCursor->shape(); - - if (shape == Qt::BitmapCursor) { - // application supplied cursor - const QBitmap * map = widgetCursor->bitmap(); - const QBitmap * mask = widgetCursor->mask(); - QPoint spot = widgetCursor->hotSpot(); - setCursor(map->toImage().bits(), mask->toImage().bits(), map->width(), map->height(), spot.x(), spot.y()); - } else { - // system cursor - setCursor(shape); - } - currentRect = getCurrentRect(); - screen->setDirty(currentRect); } // End of display and pointer event handling code diff --git a/src/gui/painting/qgraphicssystemcursor.h b/src/gui/painting/qgraphicssystemcursor.h index d385ac0..42727a8 100644 --- a/src/gui/painting/qgraphicssystemcursor.h +++ b/src/gui/painting/qgraphicssystemcursor.h @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE // Cursor graphics management -class QGraphicsSystemCursorImage { +class Q_GUI_EXPORT QGraphicsSystemCursorImage { public: QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) { set(data, mask, width, height, hotX, hotY); } @@ -68,33 +68,17 @@ private: class Q_GUI_EXPORT QGraphicsSystemCursor : public QObject { public: QGraphicsSystemCursor(QGraphicsSystemScreen *); - virtual ~QGraphicsSystemCursor(); // input methods - virtual void pointerEvent(const QMouseEvent & event); - virtual void changeCursor(QCursor * widgetCursor, QWidget * widget); - - // output methods - virtual QRect drawCursor(QPainter &); - virtual QRect dirtyRect(); + virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } + virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0; static QPointer getInstance() { return instance; } protected: - static QPointer instance; - - QRect currentRect; // next place to draw the cursor - QRect prevRect; // last place the cursor was drawn + static QPointer instance; // limit 1 cursor at a time QGraphicsSystemScreen * screen; // Where to request an update - - QGraphicsSystemCursorImage * graphic; - -private: - - void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); - void setCursor(Qt::CursorShape shape); - QRect getCurrentRect(); }; QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index 6ecfd1b..27cb8a4 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -3,9 +3,81 @@ #include #include #include - +#include #include +QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen *scr) + : QGraphicsSystemCursor(scr), currentRect(QRect()), prevRect(QRect()) +{ + graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); + setCursor(Qt::ArrowCursor); +} + +QRect QGraphicsSystemSoftwareCursor::getCurrentRect() +{ + QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(), + -graphic->hotspot().y()); + rect.translate(QCursor::pos()); + return rect; +} + + +void QGraphicsSystemSoftwareCursor::pointerEvent(const QMouseEvent & e) +{ + Q_UNUSED(e); + currentRect = getCurrentRect(); + screen->setDirty(currentRect); +} + +QRect QGraphicsSystemSoftwareCursor::drawCursor(QPainter & painter) +{ + if (currentRect.isNull()) + return QRect(); + + prevRect = currentRect; + painter.drawImage(prevRect, *graphic->image()); + return prevRect; +} + +QRect QGraphicsSystemSoftwareCursor::dirtyRect() +{ + if (!prevRect.isNull()) { + QRect rect = prevRect; + prevRect = QRect(); + return rect; + } + return QRect(); +} + +void QGraphicsSystemSoftwareCursor::setCursor(Qt::CursorShape shape) +{ + graphic->set(shape); +} + +void QGraphicsSystemSoftwareCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) +{ + graphic->set(data, mask, width, height, hotX, hotY); +} + +void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) +{ + Q_UNUSED(widget); + Qt::CursorShape shape = widgetCursor->shape(); + + if (shape == Qt::BitmapCursor) { + // application supplied cursor + const QBitmap * map = widgetCursor->bitmap(); + const QBitmap * mask = widgetCursor->mask(); + QPoint spot = widgetCursor->hotSpot(); + setCursor(map->toImage().bits(), mask->toImage().bits(), map->width(), map->height(), spot.x(), spot.y()); + } else { + // system cursor + setCursor(shape); + } + currentRect = getCurrentRect(); + screen->setDirty(currentRect); +} + QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0) { mScreenImage = new QImage(mGeometry.size(), mFormat); diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h index 8e54f47..9abd5d0 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -15,6 +15,30 @@ class QPainter; class QGraphicsSystemFbWindowSurface; class QGraphicsSystemFbScreen; +class QGraphicsSystemSoftwareCursor : public QGraphicsSystemCursor +{ +public: + QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen * scr); + + // output methods + QRect dirtyRect(); + virtual QRect drawCursor(QPainter & painter); + + // input methods + virtual void pointerEvent(const QMouseEvent & event); + virtual void changeCursor(QCursor * widgetCursor, QWidget * widget); + +protected: + QGraphicsSystemCursorImage * graphic; + +private: + void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + void setCursor(Qt::CursorShape shape); + QRect currentRect; // next place to draw the cursor + QRect prevRect; // last place the cursor was drawn + QRect getCurrentRect(); +}; + class QGraphicsSystemFbWindowSurface : public QWindowSurface { public: @@ -74,7 +98,7 @@ public: protected: QList windowStack; QRegion repaintRegion; - QGraphicsSystemCursor * cursor; + QGraphicsSystemSoftwareCursor * cursor; QTimer redrawTimer; protected slots: diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp index 2a0007b..f5ca6e7 100644 --- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp +++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp @@ -807,7 +807,7 @@ QLinuxFbGraphicsSystemScreen::QLinuxFbGraphicsSystemScreen(uchar * d, int w, mFormat); mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), bytesPerLine, mFormat); - cursor = new QGraphicsSystemCursor(this); + cursor = new QGraphicsSystemSoftwareCursor(this); } void QLinuxFbGraphicsSystemScreen::setGeometry(QRect rect) diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp index 450905c..bdcac37 100644 --- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp @@ -72,14 +72,6 @@ public: ws->setCursor(cursor->shape()); } - - //#### remove this - void pointerEvent(const QMouseEvent & event) { - Q_UNUSED(event); -#if 0 - qDebug() << "pointerEvent" << event.globalPos(); -#endif - } }; diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.cpp b/src/plugins/graphicssystems/vnc/qvnccursor.cpp index 55d1c61..fb214d8 100644 --- a/src/plugins/graphicssystems/vnc/qvnccursor.cpp +++ b/src/plugins/graphicssystems/vnc/qvnccursor.cpp @@ -54,13 +54,13 @@ QT_BEGIN_NAMESPACE QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCGraphicsSystemScreen *scr ) - :QGraphicsSystemCursor::QGraphicsSystemCursor(scr), useVncCursor(false), server(srvr) + :QGraphicsSystemSoftwareCursor(scr), useVncCursor(false), server(srvr) { } void QVNCCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) { - QGraphicsSystemCursor::changeCursor(widgetCursor, widget); + QGraphicsSystemSoftwareCursor::changeCursor(widgetCursor, widget); if (useVncCursor) { server->setDirtyCursor(); } else { @@ -71,8 +71,7 @@ void QVNCCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) void QVNCCursor::setCursorMode(bool vnc) { if (vnc) { - screen->setDirty(prevRect); - prevRect = QRect(); + screen->setDirty(dirtyRect()); server->setDirtyCursor(); } else { server->setDirtyCursor(); @@ -85,10 +84,7 @@ QRect QVNCCursor::drawCursor(QPainter & painter) if (useVncCursor) return QRect(); - if (currentRect.isNull()) - return QRect(); - - return QGraphicsSystemCursor::drawCursor(painter); + return QGraphicsSystemSoftwareCursor::drawCursor(painter); } void QVNCCursor::clearClientCursor() diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.h b/src/plugins/graphicssystems/vnc/qvnccursor.h index a90b7e2..8ea0f45 100644 --- a/src/plugins/graphicssystems/vnc/qvnccursor.h +++ b/src/plugins/graphicssystems/vnc/qvnccursor.h @@ -41,7 +41,7 @@ #ifndef QVNCCURSOR_H #define QVNCCURSOR_H -#include "qgraphicssystemcursor.h" +#include "../fb_base/fb_base.h" #include #include #include @@ -51,13 +51,14 @@ QT_BEGIN_NAMESPACE class QVNCGraphicsSystemScreen; class QVNCServer; -class QVNCCursor : public QGraphicsSystemCursor { +class QVNCCursor : public QGraphicsSystemSoftwareCursor { public: QVNCCursor(QVNCServer *, QVNCGraphicsSystemScreen *); // input methods void setCursorMode(bool vnc); void changeCursor(QCursor * widgetCursor, QWidget * widget); + // output methods QRect drawCursor(QPainter &); -- cgit v0.12 From 55fc5c3bbb6c1f7d16f26459f66922af7961642d Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 26 Nov 2009 14:49:34 +0100 Subject: added some documentation for QGraphicsSystemCursor --- src/gui/painting/qgraphicssystemcursor.cpp | 44 +++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp index 022dc64..3fc836d 100644 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ #include "qgraphicssystemcursor.h" -//#include "qlighthousegraphicsscreen.h" #include #include @@ -52,6 +51,49 @@ QT_BEGIN_NAMESPACE QPointer QGraphicsSystemCursor::instance = 0; +/*! + \class QGraphicsSystemCursor + + \brief The QGraphicsSystemCursor class provides information about + pointer device events (movement, buttons), and requests to change + the currently displayed cursor. + + Note that QGraphicsSystemCursor does not include any graphics for + display. An application that sets a QCursor may provide its own + graphics. + + \sa QGraphicsSystemCursorImage +*/ + +/*! + \fn virtual void pointerEvent(const QMouseEvent & event) + + This method is called by Qt whenever a QMouseEvent is generated by the + underlying pointer input. \a event is a reference to the QMouseEvent in + question. A default do-nothing implementation is provided. + + \sa QApplicationPrivate::handleMouseEvent() +*/ + +/*! + \fn virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) + + \brief This method is called by Qt whenever the cursor graphic should be changed. + + Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor. + + \a widgetCursor is a pointer to the QCursor that should be displayed. + + \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note + that this may be 0 if the current position is not occupied by a displayed widget. + + \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos() +*/ + +/*! + Constructs a QGraphicsSystemCursor + +*/ QGraphicsSystemCursor::QGraphicsSystemCursor(QGraphicsSystemScreen *scr ) : screen(scr) { -- cgit v0.12 From de3fbd3316797e73a67fbd1a0f7191c66ab88233 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 26 Nov 2009 17:01:25 +0100 Subject: Implement setWindowTitle() on Lighthouse --- src/gui/kernel/qwidget_lite.cpp | 9 +++++++-- src/gui/painting/qwindowsurface_p.h | 1 + .../testlite/qwindowsurface_testlite.cpp | 4 ++++ .../graphicssystems/testlite/qwindowsurface_testlite.h | 1 + src/plugins/graphicssystems/testlite/x11util.cpp | 18 ++++++++++++++++++ src/plugins/graphicssystems/testlite/x11util.h | 2 ++ 6 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 5a629c0..8601855 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -187,8 +187,13 @@ void QWidgetPrivate::updateCursor() const void QWidgetPrivate::setWindowTitle_sys(const QString &caption) { - Q_UNUSED(caption); - // XXX + Q_Q(QWidget); + if (!q->isWindow()) + return; + + if (QWindowSurface *surface = q->windowSurface()) + surface->setWindowTitle(caption); + } void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/) diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h index 5e95d80..1c0334c 100644 --- a/src/gui/painting/qwindowsurface_p.h +++ b/src/gui/painting/qwindowsurface_p.h @@ -95,6 +95,7 @@ public: virtual Qt::WindowFlags windowFlags() const; virtual WId winId() const; + virtual void setWindowTitle(const QString &) {} virtual void raise() { qWarning("This plugin does not support raise()"); } virtual void lower() { qWarning("This plugin does not support lower()"); } #endif diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 495b572..13dbae1 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -590,6 +590,10 @@ void QTestLiteWindowSurface::lower() XLowerWindow(mGraphicsSystem->xd->display, window); } +void QTestLiteWindowSurface::setWindowTitle(const QString &title) +{ + xw->setWindowTitle(title); +} void QTestLiteWindowSurface::setCursor(Qt::CursorShape shape) { diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h index cedd66c..43d1b23 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h @@ -81,6 +81,7 @@ public: WId winId() const; void raise(); void lower(); + void setWindowTitle(const QString &title); void setCursor(Qt::CursorShape shape); diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index e2fbd62..8c0b6c1 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -397,6 +397,24 @@ MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) wmProtocolsAtom, XA_ATOM, 32, PropModeAppend, (unsigned char *) &wmDeleteWindowAtom, 1); + + + setWindowTitle(QLatin1String("Qt Lighthouse")); + +} + + +void MyWindow::setWindowTitle(const QString &title) + +{ + QByteArray ba = title.toLatin1(); //We're not making a general solution here... + XTextProperty windowName; + windowName.value = (unsigned char *)ba.constData(); + windowName.encoding = XA_STRING; + windowName.format = 8; + windowName.nitems = ba.length(); + + XSetWMName(xd->display, window, &windowName); } MyWindow::~MyWindow() diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h index e9d4c7b..fc88297 100644 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -111,6 +111,8 @@ public: void setVisible(bool visible); void setCursorShape(int cshape); + void setWindowTitle(const QString &title); + public: //### int xpos, ypos; -- cgit v0.12 From b699cdad144e0a23f1dabf26c05fde2f4e3ec6f9 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 4 Dec 2009 13:37:02 +0100 Subject: caching of X11 cursors, with an expiration after 3 seconds This also contains a stub for Qt::BitmapCursor cursors. Conversion to the X11 bitmap format is missing. --- .../testlite/qgraphicssystem_testlite.cpp | 2 +- .../testlite/qwindowsurface_testlite.cpp | 4 +- .../testlite/qwindowsurface_testlite.h | 2 +- src/plugins/graphicssystems/testlite/x11util.cpp | 273 ++++++++++++++++----- src/plugins/graphicssystems/testlite/x11util.h | 61 ++++- 5 files changed, 282 insertions(+), 60 deletions(-) diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp index bdcac37..72d364a 100644 --- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp @@ -70,7 +70,7 @@ public: if (!ws) return; - ws->setCursor(cursor->shape()); + ws->setCursor(cursor); } }; diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 13dbae1..fde54a1 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -595,8 +595,8 @@ void QTestLiteWindowSurface::setWindowTitle(const QString &title) xw->setWindowTitle(title); } -void QTestLiteWindowSurface::setCursor(Qt::CursorShape shape) +void QTestLiteWindowSurface::setCursor(QCursor *cursor) { - xw->setCursorShape(shape); + xw->setCursor(cursor); } QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h index 43d1b23..9f9f052 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h @@ -83,7 +83,7 @@ public: void lower(); void setWindowTitle(const QString &title); - void setCursor(Qt::CursorShape shape); + void setCursor(QCursor * cursor); private: QTestLiteGraphicsSystem *mGraphicsSystem; diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index 8c0b6c1..1a421e8 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -57,6 +57,10 @@ #include +#include +#include +#include +#include //### remove stuff we don't want from qt_x11_p.h #undef ATOM @@ -325,6 +329,7 @@ MyDisplay::MyDisplay() wmProtocolsAtom = XInternAtom (display, "WM_PROTOCOLS", False); wmDeleteWindowAtom = XInternAtom (display, "WM_DELETE_WINDOW", False); + cursors = new MyX11Cursors(display); } @@ -401,6 +406,7 @@ MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) setWindowTitle(QLatin1String("Qt Lighthouse")); + currentCursor = -1; } @@ -802,71 +808,228 @@ void MyWindow::setVisible(bool visible) XUnmapWindow(xd->display, window); } +MyX11Cursors::MyX11Cursors(Display * d) : firstExpired(0), lastExpired(0), display(d), removalDelay(3) +{ + connect(&timer, SIGNAL(timeout()), this, SLOT(timeout())); +} -void MyWindow::setCursorShape(int cshape) +void MyX11Cursors::insertNode(MyX11CursorNode * node) { - if (cshape < 0 || cshape > Qt::LastCursor) - return; + QDateTime now = QDateTime::currentDateTime(); + QDateTime timeout = now.addSecs(removalDelay); + node->setExpiration(timeout); + node->setPost(0); + if (lastExpired) { + lastExpired->setPost(node); + node->setAnte(lastExpired); + } + lastExpired = node; + if (!firstExpired) { + firstExpired = node; + node->setAnte(0); + int interval = removalDelay * 1000; + timer.setInterval(interval); + timer.start(); + } +} - static Cursor cursors[Qt::LastCursor+1] = {XNone}; +void MyX11Cursors::removeNode(MyX11CursorNode * node) +{ + MyX11CursorNode *pre = node->ante(); + MyX11CursorNode *post = node->post(); + if (pre) + pre->setPost(post); + if (post) + post->setAnte(pre); + if (node == lastExpired) + lastExpired = pre; + if (node == firstExpired) { + firstExpired = post; + if (!firstExpired) { + timer.stop(); + return; + } + int interval = QDateTime::currentDateTime().secsTo(firstExpired->expiration()) * 1000; + timer.stop(); + timer.setInterval(interval); + timer.start(); + } +} - Cursor cursor = cursors[cshape]; - if (!cursor) { - switch (cshape) { - case Qt::ArrowCursor: - cursor = XCreateFontCursor(xd->display, XC_left_ptr); - break; - case Qt::UpArrowCursor: - cursor = XCreateFontCursor(xd->display, XC_center_ptr); - break; - case Qt::CrossCursor: - cursor = XCreateFontCursor(xd->display, XC_crosshair); - break; - case Qt::WaitCursor: - cursor = XCreateFontCursor(xd->display, XC_watch); - break; - case Qt::IBeamCursor: - cursor = XCreateFontCursor(xd->display, XC_xterm); - break; - case Qt::SizeAllCursor: - cursor = XCreateFontCursor(xd->display, XC_fleur); - break; - case Qt::PointingHandCursor: - cursor = XCreateFontCursor(xd->display, XC_hand2); - break; - case Qt::SizeBDiagCursor: - cursor = XCreateFontCursor(xd->display, XC_top_right_corner); - break; - case Qt::SizeFDiagCursor: - cursor = XCreateFontCursor(xd->display, XC_bottom_right_corner); - break; - case Qt::SizeVerCursor: - case Qt::SplitVCursor: - cursor = XCreateFontCursor(xd->display, XC_sb_v_double_arrow); - break; - case Qt::SizeHorCursor: - case Qt::SplitHCursor: - cursor = XCreateFontCursor(xd->display, XC_sb_h_double_arrow); - break; - case Qt::WhatsThisCursor: - cursor = XCreateFontCursor(xd->display, XC_question_arrow); - break; - case Qt::ForbiddenCursor: - cursor = XCreateFontCursor(xd->display, XC_circle); - break; - case Qt::BusyCursor: - cursor = XCreateFontCursor(xd->display, XC_watch); - break; +void MyX11Cursors::incrementUseCount(int id) +{ + MyX11CursorNode * node = lookupMap.value(id); + Q_ASSERT(node); + if (!node->refCount) + removeNode(node); + node->refCount++; +} - default: //default cursor for all the rest - break; +void MyX11Cursors::decrementUseCount(int id) +{ + MyX11CursorNode * node = lookupMap.value(id); + Q_ASSERT(node); + node->refCount--; + if (!node->refCount) + insertNode(node); +} + +void MyX11Cursors::createNode(int id, Cursor c) +{ + MyX11CursorNode * node = new MyX11CursorNode(id, c); + lookupMap.insert(id, node); +} + +void MyX11Cursors::timeout() +{ + MyX11CursorNode * node; + node = firstExpired; + QDateTime now = QDateTime::currentDateTime(); + while (node && now.secsTo(node->expiration()) < 1) { + Cursor c = node->cursor(); + int id = node->id(); + lookupMap.take(id); + MyX11CursorNode * tmp = node; + node = node->post(); + delete tmp; + XFreeCursor(display, c); + } + firstExpired = node; + if (node == 0) { + timer.stop(); + lastExpired = 0; + } + else { + int interval = QDateTime::currentDateTime().secsTo(firstExpired->expiration()) * 1000; + timer.setInterval(interval); + timer.start(); + } +} + +Cursor MyX11Cursors::cursor(int id) +{ + MyX11CursorNode * node = lookupMap.value(id); + Q_ASSERT(node); + return node->cursor(); +} + +void MyWindow::setCursor(QCursor * cursor) +{ + int id = cursor->handle(); + if (id == currentCursor) + return; + Cursor c; + if (!xd->cursors->exists(id)) { + if (cursor->shape() == Qt::BitmapCursor) + c = createCursorBitmap(cursor); + else + c = createCursorShape(cursor->shape()); + if (!c) { + return; } - cursors[cshape] = cursor; + xd->cursors->createNode(id, c); + } else { + xd->cursors->incrementUseCount(id); + c = xd->cursors->cursor(id); } - XDefineCursor(xd->display, window, cursor); + + if (currentCursor != -1) + xd->cursors->decrementUseCount(currentCursor); + currentCursor = id; + + XDefineCursor(xd->display, window, c); XFlush(xd->display); } +Cursor MyWindow::createCursorBitmap(QCursor * cursor) +{ +/* + XColor bg, fg; + bg.red = 255 << 8; + bg.green = 255 << 8; + bg.blue = 255 << 8; + fg.red = 0; + fg.green = 0; + fg.blue = 0; + QPoint spot = cursor->hotSpot(); + Window rootwin = window; + + const QBitmap * map = cursor->bitmap(); + char * mapBits = reinterpret_cast(map->toImage().bits()); + const QBitmap * mask = cursor->mask(); + char * maskBits = reinterpret_cast(mask->toImage().bits()); + + Pixmap cp = XCreateBitmapFromData(xd->display, rootwin, mapBits, map->width(), map->height()); + Pixmap mp = XCreateBitmapFromData(xd->display, rootwin, maskBits, map->width(), map->height()); + Cursor c = XCreatePixmapCursor(xd->display, cp, mp, &fg, &bg, spot.x(), spot.y()); + XFreePixmap(xd->display, cp); + XFreePixmap(xd->display, mp); + + return c; +*/ + // correct pixmap cursor parsing not implemented yet + return createCursorShape(Qt::ArrowCursor); +} + +Cursor MyWindow::createCursorShape(int cshape) +{ + Cursor cursor = 0; + + if (cshape < 0 || cshape > Qt::LastCursor) + return 0; + + switch (cshape) { + case Qt::ArrowCursor: + cursor = XCreateFontCursor(xd->display, XC_left_ptr); + break; + case Qt::UpArrowCursor: + cursor = XCreateFontCursor(xd->display, XC_center_ptr); + break; + case Qt::CrossCursor: + cursor = XCreateFontCursor(xd->display, XC_crosshair); + break; + case Qt::WaitCursor: + cursor = XCreateFontCursor(xd->display, XC_watch); + break; + case Qt::IBeamCursor: + cursor = XCreateFontCursor(xd->display, XC_xterm); + break; + case Qt::SizeAllCursor: + cursor = XCreateFontCursor(xd->display, XC_fleur); + break; + case Qt::PointingHandCursor: + cursor = XCreateFontCursor(xd->display, XC_hand2); + break; + case Qt::SizeBDiagCursor: + cursor = XCreateFontCursor(xd->display, XC_top_right_corner); + break; + case Qt::SizeFDiagCursor: + cursor = XCreateFontCursor(xd->display, XC_bottom_right_corner); + break; + case Qt::SizeVerCursor: + case Qt::SplitVCursor: + cursor = XCreateFontCursor(xd->display, XC_sb_v_double_arrow); + break; + case Qt::SizeHorCursor: + case Qt::SplitHCursor: + cursor = XCreateFontCursor(xd->display, XC_sb_h_double_arrow); + break; + case Qt::WhatsThisCursor: + cursor = XCreateFontCursor(xd->display, XC_question_arrow); + break; + case Qt::ForbiddenCursor: + cursor = XCreateFontCursor(xd->display, XC_circle); + break; + case Qt::BusyCursor: + cursor = XCreateFontCursor(xd->display, XC_watch); + break; + + default: //default cursor for all the rest + break; + } + return cursor; +} + #if 0 diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h index fc88297..2a73f3e 100644 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -44,6 +44,8 @@ #include #include +#include +#include #include @@ -52,6 +54,7 @@ class MyWindow; +class MyX11Cursors; class MyDisplay : public QObject { @@ -77,6 +80,8 @@ public: //### int physicalHeight; QList windowList; + + MyX11Cursors * cursors; }; class QTestLiteWindowSurface; //### abstract callback interface, anyone? @@ -109,7 +114,9 @@ public: Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); void setVisible(bool visible); - void setCursorShape(int cshape); + void setCursor(QCursor * cursor); + Cursor createCursorShape(int cshape); + Cursor createCursorBitmap(QCursor * cursor); void setWindowTitle(const QString &title); @@ -123,10 +130,62 @@ public: //### GC gc; QTestLiteWindowSurface *windowSurface; + + int currentCursor; +}; + +class MyX11CursorNode +{ +public: + MyX11CursorNode(int id, Cursor c) { idValue = id; cursorValue = c; refCount = 1; } + QDateTime expiration() { return t; } + void setExpiration(QDateTime val) { t = val; } + MyX11CursorNode * ante() { return before; } + void setAnte(MyX11CursorNode *node) { before = node; } + MyX11CursorNode * post() { return after; } + void setPost(MyX11CursorNode *node) { after = node; } + Cursor cursor() { return cursorValue; } + int id() { return idValue; } + unsigned int refCount; + +private: + MyX11CursorNode *before; + MyX11CursorNode *after; + QDateTime t; + Cursor cursorValue; + int idValue; + + Display * display; }; +class MyX11Cursors : public QObject +{ + Q_OBJECT +public: + MyX11Cursors(Display * d); + ~MyX11Cursors() { timer.stop(); } + void incrementUseCount(int id); + void decrementUseCount(int id); + void createNode(int id, Cursor c); + bool exists(int id) { return lookupMap.contains(id); } + Cursor cursor(int id); +public slots: + void timeout(); +private: + void removeNode(MyX11CursorNode *node); + void insertNode(MyX11CursorNode *node); + // linked list of cursors currently not assigned to any window + MyX11CursorNode *firstExpired; + MyX11CursorNode *lastExpired; + QHash lookupMap; + QTimer timer; + + Display *display; + + int removalDelay; +}; #endif // MYX11UTIL_H -- cgit v0.12 From 3b82e91bcfb19f52ce4d030eff146852d9cde08f Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 4 Dec 2009 13:15:52 +0100 Subject: Add experimental OpenKODE support --- .../qws/linux-x86-openkode-g++/qmake.conf | 22 ++ .../qws/linux-x86-openkode-g++/qplatformdefs.h | 42 ++++ src/gui/egl/qegl.cpp | 2 +- src/plugins/graphicssystems/openkode/frag.glslf | 8 + src/plugins/graphicssystems/openkode/frag.h | 37 +++ src/plugins/graphicssystems/openkode/main.cpp | 71 ++++++ src/plugins/graphicssystems/openkode/openkode.pro | 14 ++ .../openkode/qgraphicssystem_openkode.cpp | 237 +++++++++++++++++++ .../openkode/qgraphicssystem_openkode.h | 95 ++++++++ .../openkode/qwindowsurface_openkode.cpp | 256 +++++++++++++++++++++ .../openkode/qwindowsurface_openkode.h | 78 +++++++ src/plugins/graphicssystems/openkode/vert.glslv | 14 ++ src/plugins/graphicssystems/openkode/vert.h | 63 +++++ 13 files changed, 938 insertions(+), 1 deletion(-) create mode 100644 mkspecs/unsupported/qws/linux-x86-openkode-g++/qmake.conf create mode 100644 mkspecs/unsupported/qws/linux-x86-openkode-g++/qplatformdefs.h create mode 100644 src/plugins/graphicssystems/openkode/frag.glslf create mode 100644 src/plugins/graphicssystems/openkode/frag.h create mode 100644 src/plugins/graphicssystems/openkode/main.cpp create mode 100644 src/plugins/graphicssystems/openkode/openkode.pro create mode 100644 src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.cpp create mode 100644 src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.h create mode 100644 src/plugins/graphicssystems/openkode/qwindowsurface_openkode.cpp create mode 100644 src/plugins/graphicssystems/openkode/qwindowsurface_openkode.h create mode 100644 src/plugins/graphicssystems/openkode/vert.glslv create mode 100644 src/plugins/graphicssystems/openkode/vert.h diff --git a/mkspecs/unsupported/qws/linux-x86-openkode-g++/qmake.conf b/mkspecs/unsupported/qws/linux-x86-openkode-g++/qmake.conf new file mode 100644 index 0000000..36ad503 --- /dev/null +++ b/mkspecs/unsupported/qws/linux-x86-openkode-g++/qmake.conf @@ -0,0 +1,22 @@ +# +# qmake configuration for building with linux-g++ +# + +include(../../../common/g++.conf) +include(../../../common/linux.conf) +include(../../../common/qws.conf) + +load(qt_config) + +# ### HACK - This should be a configure check +OPENKODE_DIR = $(OPENKODE_DIR) + +QMAKE_INCDIR_OPENGL_ES2 = $${OPENKODE_DIR}/include +QMAKE_LIBDIR_OPENGL_ES2 = $${OPENKODE_DIR}/lib-target +QMAKE_LIBS_OPENGL_ES2 = $${QMAKE_RPATH}/$${OPENKODE_DIR}/lib-target -lGLESv2_CM + +QMAKE_INCDIR_EGL = $$QMAKE_INCDIR_OPENGL_ES2 +QMAKE_LIBDIR_EGL = $$QMAKE_LIBDIR_OPENGL_ES2 +QMAKE_LIBS_EGL = $${QMAKE_RPATH}/$${OPENKODE_DIR}/lib-target -lEGL + +QMAKE_LIBS += $${QMAKE_RPATH}/$${OPENKODE_DIR}/lib-target diff --git a/mkspecs/unsupported/qws/linux-x86-openkode-g++/qplatformdefs.h b/mkspecs/unsupported/qws/linux-x86-openkode-g++/qplatformdefs.h new file mode 100644 index 0000000..86d84e8 --- /dev/null +++ b/mkspecs/unsupported/qws/linux-x86-openkode-g++/qplatformdefs.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec 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 "../../../linux-g++/qplatformdefs.h" diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index c0e4890..0f51846 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -188,7 +188,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties } } if (ctx == EGL_NO_CONTEXT) { - ctx = eglCreateContext(dpy, cfg, 0, contextProps.properties()); + ctx = eglCreateContext(dpy, cfg, EGL_NO_CONTEXT, contextProps.properties()); if (ctx == EGL_NO_CONTEXT) { qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << errorString(eglGetError()); return false; diff --git a/src/plugins/graphicssystems/openkode/frag.glslf b/src/plugins/graphicssystems/openkode/frag.glslf new file mode 100644 index 0000000..a593434 --- /dev/null +++ b/src/plugins/graphicssystems/openkode/frag.glslf @@ -0,0 +1,8 @@ +uniform sampler2D tex_samp; + +varying vec2 texcoord_var; + +void main() +{ + gl_FragColor = texture2D(tex_samp, texcoord_var); +} diff --git a/src/plugins/graphicssystems/openkode/frag.h b/src/plugins/graphicssystems/openkode/frag.h new file mode 100644 index 0000000..6575cb5 --- /dev/null +++ b/src/plugins/graphicssystems/openkode/frag.h @@ -0,0 +1,37 @@ +0x4e,0x56,0x75,0x63,0x01,0x00,0x00,0x00,0x09,0x00,0x06,0x00,0x06,0x00,0x50,0x00, +0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x50,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x40,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x27,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x50,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0xe8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x70,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x11,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xb0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x12,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0xc0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x2b,0x00,0x00,0x00,0x7a,0x00,0x00,0x00,0xd0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x2c,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x68,0x69,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff, +0x00,0x00,0x00,0x80,0x04,0x00,0x00,0x90,0x00,0x02,0x01,0x82,0x04,0x02,0x02,0x82, +0x01,0x00,0x40,0xf6,0x85,0xc7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x3a,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x2a,0x00,0x06,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0x3b,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x49,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x04,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0x00,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x00,0x00,0x00,0x74,0x65,0x78,0x63, +0x6f,0x6f,0x72,0x64,0x5f,0x76,0x61,0x72,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/src/plugins/graphicssystems/openkode/main.cpp b/src/plugins/graphicssystems/openkode/main.cpp new file mode 100644 index 0000000..e9c1083 --- /dev/null +++ b/src/plugins/graphicssystems/openkode/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qgraphicssystem_openkode.h" + +QT_BEGIN_NAMESPACE + +class QOpenKODEGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QOpenKODEGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "OpenKODE"; + return list; +} + +QGraphicsSystem* QOpenKODEGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "openkode") + return new QOpenKODEGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(openkode, QOpenKODEGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openkode/openkode.pro b/src/plugins/graphicssystems/openkode/openkode.pro new file mode 100644 index 0000000..f8f0bcb --- /dev/null +++ b/src/plugins/graphicssystems/openkode/openkode.pro @@ -0,0 +1,14 @@ +TARGET = qopenkodegraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp qgraphicssystem_openkode.cpp qwindowsurface_openkode.cpp +HEADERS = qgraphicssystem_openkode.h qwindowsurface_openkode.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target + +# openkode specific stuff +INCLUDEPATH += $(OPENKODE_DIR)/include +LIBS += $${QMAKE_RPATH}/$(OPENKODE_DIR)/lib-target -L$(OPENKODE_DIR)/lib-target -lKD -lEGL -lGLESv2_CM diff --git a/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.cpp b/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.cpp new file mode 100644 index 0000000..51364e4 --- /dev/null +++ b/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.cpp @@ -0,0 +1,237 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicssystem_openkode.h" +#include "qwindowsurface_openkode.h" +#include + +#include +#include + +#include +#include +#include + +#include "GLES2/gl2ext.h" + + +QT_BEGIN_NAMESPACE + +QOpenKODEGraphicsSystemScreen::QOpenKODEGraphicsSystemScreen() +{ + KDDesktopNV *kdDesktop = KD_NULL; + KDDisplayNV *kdDisplay = KD_NULL; + + qDebug() << "QOpenKODEGraphicsSystemScreen::QOpenKODEGraphicsSystemScreen()"; + + // Get the default desktop and display + kdDesktop = kdGetDesktopNV(KD_DEFAULT_DESKTOP_NV, KD_NULL); + if (!kdDesktop || kdDesktop == (void*)-1) { + qErrnoWarning(kdGetError(), "Could not obtain KDDesktopNV pointer"); + return; + } + + kdDisplay = kdGetDisplayNV(KD_DEFAULT_DISPLAY_NV, KD_NULL); + if (!kdDisplay || kdDisplay == (void*)-1) { + qErrnoWarning(kdGetError(), "Could not obtain KDDisplayNV pointer"); + kdReleaseDesktopNV(kdDesktop); + return; + } + + KDDisplayModeNV mode; + if (kdGetDisplayModeNV(kdDisplay, &mode)) { + qErrnoWarning(kdGetError(), "Could not get display mode"); + return; + } + + qDebug() << " - display mode " << mode.width << "x" << mode.height << " refresh " << mode.refresh; + + KDint desktopSize[] = { mode.width, mode.height }; + + if (kdSetDesktopPropertyivNV(kdDesktop, KD_DESKTOPPROPERTY_SIZE_NV, desktopSize)) { + qErrnoWarning(kdGetError(), "Could not set desktop size"); + return; + } + + // Once we've set up the desktop and display we don't need them anymore +// kdReleaseDisplayNV(kdDisplay); TODO!!! + kdReleaseDesktopNV(kdDesktop); + + const int defaultDpi = 72; + mGeometry = QRect(0, 0, mode.width, mode.height); + mPhysicalSize = QSize(mode.width * 25.4 / defaultDpi, mode.height * 25.4 / defaultDpi); + + mDepth = 24; + mFormat = QImage::Format_RGB888; + + if (!mContext.openDisplay(0)) { + qWarning("qEglContext: Unable to open display!"); + return; + } + + qDebug() << " - QEglContext::openDisplay OK"; + + QEglProperties properties; + properties.setPixelFormat(QImage::Format_RGB888); + properties.setValue(EGL_BUFFER_SIZE, EGL_DONT_CARE); + properties.setRenderableType(QEgl::OpenGL); + + if (!mContext.chooseConfig(properties, QEgl::BestPixelFormat)) { + qWarning("qEglContext: Unable to choose config!"); + return; + } + + qDebug() << " - QEglContext::openDisplay OK"; +} + +static GLuint NvKdTestLoadShaders(const char *vertex_shader_binary, + const char *fragment_shader_binary, + GLuint vertex_shader_binary_size, + GLuint fragment_shader_binary_size) +{ + GLuint prog; + GLuint vertShader; + GLuint fragShader; + + // Create the program + prog = glCreateProgram(); + + // Create the GL shader objects + vertShader = glCreateShader(GL_VERTEX_SHADER); + fragShader = glCreateShader(GL_FRAGMENT_SHADER); + + // Load the binary data into the shader objects + glShaderBinary(1, &vertShader, + GL_NVIDIA_PLATFORM_BINARY_NV, vertex_shader_binary, vertex_shader_binary_size); + glShaderBinary(1, &fragShader, + GL_NVIDIA_PLATFORM_BINARY_NV, fragment_shader_binary, fragment_shader_binary_size); + + // Attach the shaders to the program + glAttachShader(prog, vertShader); + glAttachShader(prog, fragShader); + + // Delete the shaders + glDeleteShader(vertShader); + glDeleteShader(fragShader); + + // Link and validate the shader program + glLinkProgram(prog); + glValidateProgram(prog); + + return prog; +} + +class QOpenKODEEventLoopHelper : public QThread +{ +public: + QOpenKODEEventLoopHelper(QSemaphore *m) + : eventMutex(m) + { + m->acquire(); + } + +protected: + void run() + { + qDebug() << "initializing KD"; + kdInitializeNV(); + qDebug() << "done initializing KD"; + eventMutex->release(); + + const KDEvent *event; + while ((event = kdWaitEvent(-1)) != 0) { + qDebug() << "!!! received event!"; + kdDefaultEvent(event); + } + + qDebug() << "exiting event loop"; + } + +private: + QSemaphore *eventMutex; +}; + +QOpenKODEGraphicsSystem::QOpenKODEGraphicsSystem() + : eventMutex(1) +{ + QOpenKODEEventLoopHelper *loop = new QOpenKODEEventLoopHelper(&eventMutex); + loop->start(); + eventMutex.acquire(); // block until initialization done + + mPrimaryScreen = new QOpenKODEGraphicsSystemScreen(); + + mScreens.append(mPrimaryScreen); + +} + +QPixmapData *QOpenKODEGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QOpenKODEGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + return new QOpenKODEWindowSurface(mPrimaryScreen, widget); +} + +GLuint QOpenKODEGraphicsSystem::blitterProgram() +{ + static GLuint shaderProgram = 0; + if (!shaderProgram) { + + const char vertShaderBinary[] = { +# include "vert.h" + }; + const char fragShaderBinary[] = { +# include "frag.h" + }; + + shaderProgram = NvKdTestLoadShaders(vertShaderBinary, fragShaderBinary, + sizeof(vertShaderBinary), sizeof(fragShaderBinary)); + + if (!shaderProgram) + qFatal("QOpenKodeGraphicsSystem(): Cannot load shaders!"); + } + return shaderProgram; +} + + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.h b/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.h new file mode 100644 index 0000000..972c42e --- /dev/null +++ b/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_OPENKODE_H +#define QGRAPHICSSYSTEM_OPENKODE_H + +#include + +#include +#include + +# include + +QT_BEGIN_NAMESPACE + +struct KDDesktopNV; + +class QOpenKODEGraphicsSystemScreen : public QGraphicsSystemScreen +{ +public: + QOpenKODEGraphicsSystemScreen(); + ~QOpenKODEGraphicsSystemScreen() {} + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; + QEglContext mContext; +}; + +class QOpenKODEGraphicsSystem : public QGraphicsSystem +{ +public: + QOpenKODEGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList screens() const { return mScreens; } + + static GLuint blitterProgram(); + +private: + QOpenKODEGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; + QSemaphore eventMutex; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.cpp b/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.cpp new file mode 100644 index 0000000..33c76e4 --- /dev/null +++ b/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.cpp @@ -0,0 +1,256 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsurface_openkode.h" +#include "qgraphicssystem_openkode.h" +#include + +#include "KD/kd.h" +#include "KD/NV_display.h" + +QT_BEGIN_NAMESPACE + +QOpenKODEWindowSurface::QOpenKODEWindowSurface + (QOpenKODEGraphicsSystemScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen) +{ + qDebug() << "QOpenKODEWindowSurface::QOpenKODEWindowSurface:" << window << window->width() << "x" << window->height() + << "pos" << window->x() << "x" << window->y(); + + if (!mContext.openDisplay(0)) { + qWarning("qEglContext: Unable to open display!"); + return; + } + + QEglProperties properties; + properties.setPixelFormat(QImage::Format_RGB888); + properties.setValue(EGL_BUFFER_SIZE, EGL_DONT_CARE); + properties.setRenderableType(QEgl::OpenGL); + + if (!mContext.chooseConfig(properties, QEgl::BestPixelFormat)) { + qWarning("qEglContext: Unable to choose config!"); + return; + } + + createWindow(window); +} + +void QOpenKODEWindowSurface::createWindow(QWidget *window) +{ + kdWindow = kdCreateWindow(mContext.display(), mContext.config(), KD_NULL); + + if (!kdWindow) { + qErrnoWarning(kdGetError(), "Error creating native window"); + return; + } + + const KDint windowSize[2] = { window->width(), window->height() }; + if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { + qErrnoWarning(kdGetError(), "Could not set native window size"); + return; + } + + const KDboolean windowExclusive[] = { false }; + if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, windowExclusive)) { + qErrnoWarning(kdGetError(), "Could not set exclusive bit"); + return; + } + + const KDint windowPos[2] = { window->x(), window->y() }; + if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { + qErrnoWarning(kdGetError(), "Could not set native window position"); + return; + } + + EGLNativeWindowType nativeWindow; + + if (kdRealizeWindow(kdWindow, &nativeWindow)) { + qErrnoWarning(kdGetError(), "Could not realize native window"); + return; + } + + // Create an EGL window surface for the native window + EGLint windowAttrs[3] = { EGL_NONE }; + EGLSurface eglSurface = eglCreateWindowSurface(mContext.display(), + mContext.config(), + nativeWindow, + windowAttrs); + if (!eglSurface) { + qWarning("EGL couldn't create window surface: 0x%x", eglGetError()); + return; + } + + mContext.setSurface(eglSurface); + + if (!mContext.createContext()) { + qDebug() << "Unable to create context!"; + return; + } +} + +QOpenKODEWindowSurface::~QOpenKODEWindowSurface() +{ +} + +QPaintDevice *QOpenKODEWindowSurface::paintDevice() +{ + //qDebug() << "QOpenKODEWindowSurface::paintDevice"; + return &mImage; +} + +// ### TODO - this updates the entire toplevel, should only update the region +void QOpenKODEWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + if (!offset.isNull()) { + qWarning("Offset flushing not supported yet"); + return; + } + + if (!mContext.makeCurrent()) { + qWarning("EGL couldn't make context/surface current: 0x%x", eglGetError()); + return; + } + + QRect boundingRect = region.boundingRect(); + + int x, y, w, h; + QImage blitImage; + if (true || boundingRect == mImage.rect()) { // TODO - check optimization + blitImage = mImage; + x = y = 0; + w = mImage.width(); + h = mImage.height(); + } else { + blitImage = mImage.copy(boundingRect); + w = boundingRect.width(); + h = boundingRect.height(); + x = boundingRect.x(); + y = boundingRect.y(); + } + +// qDebug() << "flush" << widget << offset << region.boundingRect() << mImage.format() << blitImage.format(); + + GLuint shaderProgram = QOpenKODEGraphicsSystem::blitterProgram(); + + glUseProgram(shaderProgram); + + GLuint index = glGetUniformLocation(shaderProgram, "window"); + glUniform2f(index, GLfloat(mImage.width()), GLfloat(mImage.height())); + + // attributes + GLuint posId = glGetAttribLocation(shaderProgram, "pos_attr"); + GLuint texcoordId = glGetAttribLocation(shaderProgram, "texcoord_attr"); + + // sampler + index = glGetUniformLocation(shaderProgram, "tex_samp"); + + glUniform1i(index, 0); + + glDisable(GL_DEPTH_TEST); + glActiveTexture(GL_TEXTURE0); + + GLuint texId; + GLfloat coords[8] = {x, y, x, y + h, x + w, y + h, x + w, y }; + GLfloat texcoords[8] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0 }; + + // Generate texture for checkered background + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glGenTextures(1, &texId); + glBindTexture(GL_TEXTURE_2D, texId); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, blitImage.bits()); + + // Enable vertex attribute associated with vertex position + glEnableVertexAttribArray(posId); + glEnableVertexAttribArray(texcoordId); + + // Set the quad vertices + glVertexAttribPointer(posId, 2, GL_FLOAT, 0, 0, coords); + glVertexAttribPointer(texcoordId, 2, GL_FLOAT, 0, 0, texcoords); + + // Draw the quad + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + + // Cleanup + glDisableVertexAttribArray(posId); + glDisableVertexAttribArray(texcoordId); + + // Release all textures + glBindTexture(GL_TEXTURE_2D, 0); + if (texId) + glDeleteTextures(1, &texId); + + mContext.swapBuffers(); + mContext.doneCurrent(); +} + +void QOpenKODEWindowSurface::setGeometry(const QRect &rect) +{ + qDebug() << "QOpenKODEWindowSurface::setGeometry:" << rect; + QWindowSurface::setGeometry(rect); + if (mImage.size() != rect.size()) + mImage = QImage(rect.size(), mScreen->format()); + + mContext.destroySurface(); + kdDestroyWindow(kdWindow); + createWindow(window()); +} + +bool QOpenKODEWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QOpenKODEWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QOpenKODEWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.h b/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.h new file mode 100644 index 0000000..1c70f55 --- /dev/null +++ b/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_OPENKODE_H +#define QWINDOWSURFACE_OPENKODE_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QOpenKODEGraphicsSystemScreen; + +class QOpenKODEWindowSurface : public QWindowSurface +{ +public: + QOpenKODEWindowSurface + (QOpenKODEGraphicsSystemScreen *screen, QWidget *window); + ~QOpenKODEWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + +private: + QOpenKODEGraphicsSystemScreen *mScreen; + QImage mImage; + struct KDWindow *kdWindow; + QEglContext mContext; + + void createWindow(QWidget *window); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/graphicssystems/openkode/vert.glslv b/src/plugins/graphicssystems/openkode/vert.glslv new file mode 100644 index 0000000..57b5866 --- /dev/null +++ b/src/plugins/graphicssystems/openkode/vert.glslv @@ -0,0 +1,14 @@ +uniform vec2 window; // window size + +// Per-vertex attributes] +attribute vec2 pos_attr; +attribute vec2 texcoord_attr; + +// Output vertex color +varying vec2 texcoord_var; + +void main() +{ + gl_Position = vec4( (2.0 * pos_attr / window -1.0) * vec2(1.0, -1.0), 0.0, 1.0); + texcoord_var = texcoord_attr; +} diff --git a/src/plugins/graphicssystems/openkode/vert.h b/src/plugins/graphicssystems/openkode/vert.h new file mode 100644 index 0000000..bdf564d --- /dev/null +++ b/src/plugins/graphicssystems/openkode/vert.h @@ -0,0 +1,63 @@ +0x4e,0x56,0x75,0x63,0x01,0x00,0x00,0x00,0x0a,0x00,0x06,0x00,0x06,0x00,0x50,0x00, +0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0xf0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x60,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x24,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x70,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x26,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0xe8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0xb0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x28,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x10,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x20,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x30,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x2b,0x00,0x00,0x00,0x39,0x01,0x00,0x00,0xb0,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x05,0x08,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0f,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x01,0x02,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xff,0xff,0xff,0xff,0x04,0x05,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x80,0x3f,0x00,0x00,0x00,0x40,0x00,0x00,0x80,0xbf,0x00,0x00,0x00,0x00, +0x05,0x00,0x00,0x10,0x80,0xc7,0x00,0x24,0x05,0x02,0x00,0x10,0x80,0xc7,0x00,0x24, +0x01,0x02,0x81,0xc0,0x80,0x07,0x60,0x00,0x05,0x02,0x00,0x90,0x80,0x07,0x00,0x00, +0x09,0x00,0x01,0xe1,0x80,0x87,0x40,0x00,0x05,0x00,0x00,0x10,0x80,0xc7,0x00,0x24, +0x01,0x00,0x81,0xc0,0x80,0x07,0x60,0x00,0x09,0x04,0x00,0xa0,0x80,0x47,0x00,0xe4, +0x05,0x02,0x00,0x90,0x80,0x07,0x00,0x00,0x05,0x04,0x00,0x10,0x88,0xc7,0x03,0x04, +0x01,0x00,0x01,0xe1,0x88,0x87,0x40,0x00,0x09,0xf8,0x00,0x10,0x88,0xc7,0x03,0x04, +0x0d,0x00,0x00,0x10,0x88,0xc7,0x40,0x24,0x11,0x04,0x00,0x10,0x88,0xc7,0x23,0x04, +0x15,0x06,0x00,0x10,0x89,0xc7,0x23,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xa1,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0xad,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x28,0x00,0x02,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0xb6,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xb7,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0xbe,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x05,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xbf,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0xc9,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xca,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xcb,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0xd9,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xda,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xdb,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0xe8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x02,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0x00,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x50,0x4f,0x53, +0x49,0x54,0x49,0x4f,0x4e,0x00,0x00,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x00,0x00, +0x70,0x6f,0x73,0x5f,0x61,0x74,0x74,0x72,0x00,0x00,0x00,0x74,0x65,0x78,0x63,0x6f, +0x6f,0x72,0x64,0x5f,0x61,0x74,0x74,0x72,0x00,0x00,0x00,0x74,0x65,0x78,0x63,0x6f, +0x6f,0x72,0x64,0x5f,0x76,0x61,0x72,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 -- cgit v0.12 From 56c9fe5f9ba08f20885454fee7cbb488fd4968eb Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 4 Dec 2009 14:03:48 +0100 Subject: temporarily disable backingstore subsurfaces until they compile again with embedded-lite --- configure | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure index dae8910..4818560 100755 --- a/configure +++ b/configure @@ -6075,7 +6075,8 @@ fi if [ "$CFG_OPENGL" = "es1" ] || [ "$CFG_OPENGL" = "es1cl" ] || [ "$CFG_OPENGL" = "es2" ]; then if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then - QCONFIG_FLAGS="$QCONFIG_FLAGS Q_BACKINGSTORE_SUBSURFACES" +### TODO # QCONFIG_FLAGS="$QCONFIG_FLAGS Q_BACKINGSTORE_SUBSURFACES" + echo "### Q_BACKINGSTORE_SUBSURFACES disabled, re-enable once it compiles again" QCONFIG_FLAGS="$QCONFIG_FLAGS Q_USE_EGLWINDOWSURFACE" fi QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_ES" -- cgit v0.12 From 4190f781a81da9d2a2470d75fcf2cf2946504b34 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 4 Dec 2009 14:14:16 +0100 Subject: make sure that x11 is disabled when building embedded_lite --- src/opengl/opengl.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index b2474ed..0f752c1 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -10,7 +10,7 @@ unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui include(../qbase.pri) -!win32:!embedded:!mac:CONFIG += x11 +!win32:!embedded:!mac:!embedded_lite:CONFIG += x11 contains(QT_CONFIG, opengl):CONFIG += opengl contains(QT_CONFIG, opengles1):CONFIG += opengles1 contains(QT_CONFIG, opengles1cl):CONFIG += opengles1cl -- cgit v0.12 From 2447284a73dd8ce6268614d5709c5a1dcffbde3a Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 4 Dec 2009 14:14:41 +0100 Subject: compile with Q_WS_LITE --- src/opengl/qgl_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 8e472e5..2160f4f 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -336,7 +336,7 @@ public: static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *ctx) { return ctx->d_ptr->group->extensionFuncs(); } #endif -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_LITE) static QGLExtensionFuncs qt_extensionFuncs; static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *) { return qt_extensionFuncs; } #endif -- cgit v0.12 From 52613f91fe4c8bb4faa93c50cc3fab2d8082fc30 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 4 Dec 2009 14:15:02 +0100 Subject: compile again after recent API changes --- src/gui/egl/qegl_lite.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/egl/qegl_lite.cpp b/src/gui/egl/qegl_lite.cpp index 40439c6..60b862b 100644 --- a/src/gui/egl/qegl_lite.cpp +++ b/src/gui/egl/qegl_lite.cpp @@ -52,11 +52,11 @@ QT_BEGIN_NAMESPACE -bool QEglContext::createSurface(QPaintDevice *device, const QEglProperties *properties) +EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties *properties) { Q_UNUSED(device); Q_UNUSED(properties); - return false; + return 0; } EGLDisplay QEglContext::getDisplay(QPaintDevice *device) -- cgit v0.12 From 426334321319054fedf8993bba6482ce90a2c4ee Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 8 Dec 2009 11:54:00 +0100 Subject: fix application supplied image cursors --- src/gui/painting/qgraphicssystemcursor.cpp | 7 +++++++ src/gui/painting/qgraphicssystemcursor.h | 1 + src/plugins/graphicssystems/fb_base/fb_base.cpp | 9 ++++++--- src/plugins/graphicssystems/fb_base/fb_base.h | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp index 3fc836d..9a0e135 100644 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -513,6 +513,13 @@ void QGraphicsSystemCursorImage::set(Qt::CursorShape id) hot = cursor->hot; } +void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) +{ + hot.setX(hx); + hot.setY(hy); + cursorImage = *image; +} + void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) { diff --git a/src/gui/painting/qgraphicssystemcursor.h b/src/gui/painting/qgraphicssystemcursor.h index 42727a8..0d57d52 100644 --- a/src/gui/painting/qgraphicssystemcursor.h +++ b/src/gui/painting/qgraphicssystemcursor.h @@ -58,6 +58,7 @@ public: QImage * image() { return &cursorImage; } QPoint hotspot() { return hot; } void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + void set(const QImage * image, int hx, int hy); void set(Qt::CursorShape); private: static void createSystemCursor(int id); diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index 27cb8a4..f9ea97f 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -54,6 +54,11 @@ void QGraphicsSystemSoftwareCursor::setCursor(Qt::CursorShape shape) graphic->set(shape); } +void QGraphicsSystemSoftwareCursor::setCursor(const QImage * image, int hotx, int hoty) +{ + graphic->set(image, hotx, hoty); +} + void QGraphicsSystemSoftwareCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) { graphic->set(data, mask, width, height, hotX, hotY); @@ -66,10 +71,8 @@ void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget if (shape == Qt::BitmapCursor) { // application supplied cursor - const QBitmap * map = widgetCursor->bitmap(); - const QBitmap * mask = widgetCursor->mask(); QPoint spot = widgetCursor->hotSpot(); - setCursor(map->toImage().bits(), mask->toImage().bits(), map->width(), map->height(), spot.x(), spot.y()); + setCursor(&widgetCursor->pixmap().toImage(), spot.x(), spot.y()); } else { // system cursor setCursor(shape); diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h index 9abd5d0..58f340d 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -34,6 +34,7 @@ protected: private: void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); void setCursor(Qt::CursorShape shape); + void setCursor(const QImage * image, int hotx, int hoty); QRect currentRect; // next place to draw the cursor QRect prevRect; // last place the cursor was drawn QRect getCurrentRect(); -- cgit v0.12 From 698033071fe28f85f4e762f8347da4c2956b56ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 25 Nov 2009 14:40:16 +0100 Subject: Delete the surface --- src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp | 5 +++++ src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp index 05221ce..71be882 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp @@ -27,6 +27,11 @@ QDirectFbBlitter::QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface) } } +QDirectFbBlitter::~QDirectFbBlitter() +{ + delete m_surface; +} + void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color) { m_surface->SetColor(m_surface, color.red(), color.green(), color.blue(), color.alpha()); diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h index 252bf80..c1fbc14 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h @@ -9,7 +9,7 @@ class QDirectFbBlitter : public QBlittable { public: QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface = 0); - virtual ~QDirectFbBlitter(){ } + virtual ~QDirectFbBlitter(); virtual void fillRect(const QRectF &rect, const QColor &color); virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect); -- cgit v0.12 From 6dc5eb70382fb7f1741142b6919e1754e365029c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 27 Nov 2009 10:07:40 +0100 Subject: We dont need a new pixmap here :) --- src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 3dcf5be..43bfd9b 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -105,13 +105,9 @@ void QDirectFbWindowSurface::setGeometry(const QRect &rect) if (result != DFB_OK) DirectFBError("QDirectFbWindowSurface::setGeometry() failed to retrieve new surface",result); - QPixmap *oldpixmap = m_pixmap; QDirectFbBlitter *blitter = new QDirectFbBlitter(rect, m_dfbSurface); pmdata->resize(rect.width(),rect.height()); pmdata->setBlittable(blitter); - m_pixmap = new QPixmap(pmdata); - delete oldpixmap; - } bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) -- cgit v0.12 From d8d65804ed67ff58fe8679d3a1831c9dfad3624a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 9 Dec 2009 09:41:08 +0100 Subject: Added basic mouseinput support for minimaldfb --- .../graphicssystems/minimaldfb/minimaldfb.pro | 6 +- .../minimaldfb/qblitter_directfb.cpp | 2 +- .../minimaldfb/qdirectfbconvenience.cpp | 232 +++++++++++++++++++++ .../minimaldfb/qdirectfbconvenience.h | 15 ++ .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 104 +++++++++ .../graphicssystems/minimaldfb/qdirectfbinput.h | 49 +++++ .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 7 +- .../minimaldfb/qgraphicssystem_minimaldfb.h | 7 +- .../minimaldfb/qwindowsurface_minimaldfb.cpp | 3 +- 9 files changed, 418 insertions(+), 7 deletions(-) create mode 100644 src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp create mode 100644 src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h diff --git a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro index c3f20ff..8b20c45 100644 --- a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro +++ b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro @@ -11,10 +11,12 @@ SOURCES = main.cpp \ qgraphicssystem_minimaldfb.cpp \ qwindowsurface_minimaldfb.cpp \ qblitter_directfb.cpp \ - qdirectfbconvenience.cpp + qdirectfbconvenience.cpp \ + qdirectfbinput.cpp HEADERS = qgraphicssystem_minimaldfb.h \ qwindowsurface_minimaldfb.h \ qblitter_directfb.h \ - qdirectfbconvenience.h + qdirectfbconvenience.h \ + qdirectfbinput.h target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems INSTALLS += target diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp index 71be882..8d54c21 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp @@ -29,7 +29,7 @@ QDirectFbBlitter::QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface) QDirectFbBlitter::~QDirectFbBlitter() { - delete m_surface; + m_surface->Release(m_surface); } void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp index d958482..f0293bd 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp @@ -41,3 +41,235 @@ QImage::Format QDirectFbConvenience::imageFormatFromSurface(IDirectFBSurface *su return QImage::Format_Invalid; } + +Qt::MouseButton QDirectFbConvenience::mouseButton(DFBInputDeviceButtonIdentifier identifier) +{ + switch (identifier){ + case DIBI_LEFT: + return Qt::LeftButton; + case DIBI_MIDDLE: + return Qt::MidButton; + case DIBI_RIGHT: + return Qt::RightButton; + default: + return Qt::NoButton; + } +} + +Qt::MouseButtons QDirectFbConvenience::mouseButtons(DFBInputDeviceButtonMask mask) +{ + Qt::MouseButtons buttons = Qt::NoButton; + + if (mask & DIBM_LEFT) { + buttons |= Qt::LeftButton; + } + if (mask & DIBM_MIDDLE) { + buttons |= Qt::MidButton; + } + if (mask & DIBM_RIGHT) { + buttons |= Qt::RightButton; + } + return buttons; +} + +QEvent::Type QDirectFbConvenience::eventType(DFBWindowEventType type) +{ + switch(type) { + case DWET_BUTTONDOWN: + return QEvent::MouseButtonPress; + case DWET_BUTTONUP: + return QEvent::MouseButtonRelease; + case DWET_MOTION: + return QEvent::MouseMove; + case DWET_WHEEL: + return QEvent::Wheel; + default: + return QEvent::None; + } +} +QDirectFbKeyMap *QDirectFbConvenience::dfbKeymap = 0; +QDirectFbKeyMap *QDirectFbConvenience::keyMap() +{ + if (!dfbKeymap) + dfbKeymap = new QDirectFbKeyMap(); + return dfbKeymap; +} + +QDirectFbKeyMap::QDirectFbKeyMap() +{ + insert(DIKS_BACKSPACE , Qt::Key_Backspace); + insert(DIKS_TAB , Qt::Key_Tab); + insert(DIKS_RETURN , Qt::Key_Return); + insert(DIKS_ESCAPE , Qt::Key_Escape); + insert(DIKS_DELETE , Qt::Key_Delete); + + insert(DIKS_CURSOR_LEFT , Qt::Key_Left); + insert(DIKS_CURSOR_RIGHT , Qt::Key_Right); + insert(DIKS_CURSOR_UP , Qt::Key_Up); + insert(DIKS_CURSOR_DOWN , Qt::Key_Down); + insert(DIKS_INSERT , Qt::Key_Insert); + insert(DIKS_HOME , Qt::Key_Home); + insert(DIKS_END , Qt::Key_End); + insert(DIKS_PAGE_UP , Qt::Key_PageUp); + insert(DIKS_PAGE_DOWN , Qt::Key_PageDown); + insert(DIKS_PRINT , Qt::Key_Print); + insert(DIKS_PAUSE , Qt::Key_Pause); + insert(DIKS_SELECT , Qt::Key_Select); + insert(DIKS_GOTO , Qt::Key_OpenUrl); + insert(DIKS_CLEAR , Qt::Key_Clear); + insert(DIKS_MENU , Qt::Key_Menu); + insert(DIKS_HELP , Qt::Key_Help); + + insert(DIKS_INTERNET , Qt::Key_HomePage); + insert(DIKS_MAIL , Qt::Key_LaunchMail); + insert(DIKS_FAVORITES , Qt::Key_Favorites); + + insert(DIKS_BACK , Qt::Key_Back); + insert(DIKS_FORWARD , Qt::Key_Forward); + insert(DIKS_VOLUME_UP , Qt::Key_VolumeUp); + insert(DIKS_VOLUME_DOWN , Qt::Key_VolumeDown); + insert(DIKS_MUTE , Qt::Key_VolumeMute); + insert(DIKS_PLAYPAUSE , Qt::Key_Pause); + insert(DIKS_PLAY , Qt::Key_MediaPlay); + insert(DIKS_STOP , Qt::Key_MediaStop); + insert(DIKS_RECORD , Qt::Key_MediaRecord); + insert(DIKS_PREVIOUS , Qt::Key_MediaPrevious); + insert(DIKS_NEXT , Qt::Key_MediaNext); + + insert(DIKS_F1 , Qt::Key_F1); + insert(DIKS_F2 , Qt::Key_F2); + insert(DIKS_F3 , Qt::Key_F3); + insert(DIKS_F4 , Qt::Key_F4); + insert(DIKS_F5 , Qt::Key_F5); + insert(DIKS_F6 , Qt::Key_F6); + insert(DIKS_F7 , Qt::Key_F7); + insert(DIKS_F8 , Qt::Key_F8); + insert(DIKS_F9 , Qt::Key_F9); + insert(DIKS_F10 , Qt::Key_F10); + insert(DIKS_F11 , Qt::Key_F11); + insert(DIKS_F12 , Qt::Key_F12); + + insert(DIKS_SHIFT , Qt::Key_Shift); + insert(DIKS_CONTROL , Qt::Key_Control); + insert(DIKS_ALT , Qt::Key_Alt); + insert(DIKS_ALTGR , Qt::Key_AltGr); + + insert(DIKS_META , Qt::Key_Meta); + insert(DIKS_SUPER , Qt::Key_Super_L); // ??? + insert(DIKS_HYPER , Qt::Key_Hyper_L); // ??? + + insert(DIKS_CAPS_LOCK , Qt::Key_CapsLock); + insert(DIKS_NUM_LOCK , Qt::Key_NumLock); + insert(DIKS_SCROLL_LOCK , Qt::Key_ScrollLock); + + insert(DIKS_DEAD_ABOVEDOT , Qt::Key_Dead_Abovedot); + insert(DIKS_DEAD_ABOVERING , Qt::Key_Dead_Abovering); + insert(DIKS_DEAD_ACUTE , Qt::Key_Dead_Acute); + insert(DIKS_DEAD_BREVE , Qt::Key_Dead_Breve); + insert(DIKS_DEAD_CARON , Qt::Key_Dead_Caron); + insert(DIKS_DEAD_CEDILLA , Qt::Key_Dead_Cedilla); + insert(DIKS_DEAD_CIRCUMFLEX , Qt::Key_Dead_Circumflex); + insert(DIKS_DEAD_DIAERESIS , Qt::Key_Dead_Diaeresis); + insert(DIKS_DEAD_DOUBLEACUTE , Qt::Key_Dead_Doubleacute); + insert(DIKS_DEAD_GRAVE , Qt::Key_Dead_Grave); + insert(DIKS_DEAD_IOTA , Qt::Key_Dead_Iota); + insert(DIKS_DEAD_MACRON , Qt::Key_Dead_Macron); + insert(DIKS_DEAD_OGONEK , Qt::Key_Dead_Ogonek); + insert(DIKS_DEAD_SEMIVOICED_SOUND , Qt::Key_Dead_Semivoiced_Sound); + insert(DIKS_DEAD_TILDE , Qt::Key_Dead_Tilde); + insert(DIKS_DEAD_VOICED_SOUND , Qt::Key_Dead_Voiced_Sound); + insert(DIKS_SPACE , Qt::Key_Space); + insert(DIKS_EXCLAMATION_MARK , Qt::Key_Exclam); + insert(DIKS_QUOTATION , Qt::Key_QuoteDbl); + insert(DIKS_NUMBER_SIGN , Qt::Key_NumberSign); + insert(DIKS_DOLLAR_SIGN , Qt::Key_Dollar); + insert(DIKS_PERCENT_SIGN , Qt::Key_Percent); + insert(DIKS_AMPERSAND , Qt::Key_Ampersand); + insert(DIKS_APOSTROPHE , Qt::Key_Apostrophe); + insert(DIKS_PARENTHESIS_LEFT , Qt::Key_ParenLeft); + insert(DIKS_PARENTHESIS_RIGHT , Qt::Key_ParenRight); + insert(DIKS_ASTERISK , Qt::Key_Asterisk); + insert(DIKS_PLUS_SIGN , Qt::Key_Plus); + insert(DIKS_COMMA , Qt::Key_Comma); + insert(DIKS_MINUS_SIGN , Qt::Key_Minus); + insert(DIKS_PERIOD , Qt::Key_Period); + insert(DIKS_SLASH , Qt::Key_Slash); + insert(DIKS_0 , Qt::Key_0); + insert(DIKS_1 , Qt::Key_1); + insert(DIKS_2 , Qt::Key_2); + insert(DIKS_3 , Qt::Key_3); + insert(DIKS_4 , Qt::Key_4); + insert(DIKS_5 , Qt::Key_5); + insert(DIKS_6 , Qt::Key_6); + insert(DIKS_7 , Qt::Key_7); + insert(DIKS_8 , Qt::Key_8); + insert(DIKS_9 , Qt::Key_9); + insert(DIKS_COLON , Qt::Key_Colon); + insert(DIKS_SEMICOLON , Qt::Key_Semicolon); + insert(DIKS_LESS_THAN_SIGN , Qt::Key_Less); + insert(DIKS_EQUALS_SIGN , Qt::Key_Equal); + insert(DIKS_GREATER_THAN_SIGN , Qt::Key_Greater); + insert(DIKS_QUESTION_MARK , Qt::Key_Question); + insert(DIKS_AT , Qt::Key_At); + insert(DIKS_CAPITAL_A , Qt::Key_A); + insert(DIKS_CAPITAL_B , Qt::Key_B); + insert(DIKS_CAPITAL_C , Qt::Key_C); + insert(DIKS_CAPITAL_D , Qt::Key_D); + insert(DIKS_CAPITAL_E , Qt::Key_E); + insert(DIKS_CAPITAL_F , Qt::Key_F); + insert(DIKS_CAPITAL_G , Qt::Key_G); + insert(DIKS_CAPITAL_H , Qt::Key_H); + insert(DIKS_CAPITAL_I , Qt::Key_I); + insert(DIKS_CAPITAL_J , Qt::Key_J); + insert(DIKS_CAPITAL_K , Qt::Key_K); + insert(DIKS_CAPITAL_L , Qt::Key_L); + insert(DIKS_CAPITAL_M , Qt::Key_M); + insert(DIKS_CAPITAL_N , Qt::Key_N); + insert(DIKS_CAPITAL_O , Qt::Key_O); + insert(DIKS_CAPITAL_P , Qt::Key_P); + insert(DIKS_CAPITAL_Q , Qt::Key_Q); + insert(DIKS_CAPITAL_R , Qt::Key_R); + insert(DIKS_CAPITAL_S , Qt::Key_S); + insert(DIKS_CAPITAL_T , Qt::Key_T); + insert(DIKS_CAPITAL_U , Qt::Key_U); + insert(DIKS_CAPITAL_V , Qt::Key_V); + insert(DIKS_CAPITAL_W , Qt::Key_W); + insert(DIKS_CAPITAL_X , Qt::Key_X); + insert(DIKS_CAPITAL_Y , Qt::Key_Y); + insert(DIKS_CAPITAL_Z , Qt::Key_Z); + insert(DIKS_SQUARE_BRACKET_LEFT , Qt::Key_BracketLeft); + insert(DIKS_BACKSLASH , Qt::Key_Backslash); + insert(DIKS_SQUARE_BRACKET_RIGHT , Qt::Key_BracketRight); + insert(DIKS_CIRCUMFLEX_ACCENT , Qt::Key_AsciiCircum); + insert(DIKS_UNDERSCORE , Qt::Key_Underscore); + insert(DIKS_SMALL_A , Qt::Key_A); + insert(DIKS_SMALL_B , Qt::Key_B); + insert(DIKS_SMALL_C , Qt::Key_C); + insert(DIKS_SMALL_D , Qt::Key_D); + insert(DIKS_SMALL_E , Qt::Key_E); + insert(DIKS_SMALL_F , Qt::Key_F); + insert(DIKS_SMALL_G , Qt::Key_G); + insert(DIKS_SMALL_H , Qt::Key_H); + insert(DIKS_SMALL_I , Qt::Key_I); + insert(DIKS_SMALL_J , Qt::Key_J); + insert(DIKS_SMALL_K , Qt::Key_K); + insert(DIKS_SMALL_L , Qt::Key_L); + insert(DIKS_SMALL_M , Qt::Key_M); + insert(DIKS_SMALL_N , Qt::Key_N); + insert(DIKS_SMALL_O , Qt::Key_O); + insert(DIKS_SMALL_P , Qt::Key_P); + insert(DIKS_SMALL_Q , Qt::Key_Q); + insert(DIKS_SMALL_R , Qt::Key_R); + insert(DIKS_SMALL_S , Qt::Key_S); + insert(DIKS_SMALL_T , Qt::Key_T); + insert(DIKS_SMALL_U , Qt::Key_U); + insert(DIKS_SMALL_V , Qt::Key_V); + insert(DIKS_SMALL_W , Qt::Key_W); + insert(DIKS_SMALL_X , Qt::Key_X); + insert(DIKS_SMALL_Y , Qt::Key_Y); + insert(DIKS_SMALL_Z , Qt::Key_Z); + insert(DIKS_CURLY_BRACKET_LEFT , Qt::Key_BraceLeft); + insert(DIKS_VERTICAL_BAR , Qt::Key_Bar); + insert(DIKS_CURLY_BRACKET_RIGHT , Qt::Key_BraceRight); + insert(DIKS_TILDE , Qt::Key_AsciiTilde); +} diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h index 7e426db..0ae1410 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h @@ -2,9 +2,18 @@ #define QDIRECTFBCONVENIENCE_H #include +#include +#include #include +class QDirectFbKeyMap: public QHash +{ +public: + QDirectFbKeyMap(); +}; + + class QDirectFbConvenience { public: @@ -12,10 +21,16 @@ public: //This is set by the graphicssystem constructor static IDirectFB *dfbInterface() { return dfb; } + static Qt::MouseButton mouseButton(DFBInputDeviceButtonIdentifier identifier); + static Qt::MouseButtons mouseButtons(DFBInputDeviceButtonMask mask); + static QEvent::Type eventType(DFBWindowEventType type); + + static QDirectFbKeyMap *keyMap(); private: static void setDfbInterface(IDirectFB *dfbInterface) {dfb = dfbInterface;} static IDirectFB *dfb; + static QDirectFbKeyMap *dfbKeymap; friend class QDirectFbGraphicsSystem; }; diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp new file mode 100644 index 0000000..4ba4ff8 --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -0,0 +1,104 @@ +#include "qdirectfbinput.h" +#include "qdirectfbconvenience.h" + +#include +#include +#include +#include +#include + +#include + +InputSocketWaiter::InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent) + : QThread(parent), eventBuffer(eventBuffer) + { + this->start(); + } + +void InputSocketWaiter::run() +{ + while (1) { + eventBuffer->WaitForEvent(eventBuffer); + emit newEvent(); + } +} + +QDirectFbInput::QDirectFbInput(QObject *parent) + : QObject(parent) +{ + DFBResult ok = DirectFBCreate(&dfbInterface); + if (ok != DFB_OK) + DirectFBError("Failed to initialise QDirectFBInput", ok); + + ok = dfbInterface->CreateEventBuffer(dfbInterface,&eventBuffer); + if (ok != DFB_OK) + DirectFBError("Failed to initialise eventbuffer", ok); + + dfbInterface->GetDisplayLayer(dfbInterface,DLID_PRIMARY, &dfbDisplayLayer); + + InputSocketWaiter *inputHandler = new InputSocketWaiter(eventBuffer,this); + connect(inputHandler,SIGNAL(newEvent()),this,SLOT(handleEvents())); +} + +void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) +{ + tlwMap.insert(id,tlw); + IDirectFBWindow *window; + dfbDisplayLayer->GetWindow(dfbDisplayLayer,id,&window); + +// window->DisableEvents(window,DWET_ALL); + window->EnableEvents(window,DFBWindowEventType(DWET_ALL)); + window->SetKeySelection(window,DWKS_ALL,NULL,0); + window->AttachEventBuffer(window,eventBuffer); +} + +void QDirectFbInput::handleEvents() +{ + DFBResult hasEvent = eventBuffer->HasEvent(eventBuffer); + while(hasEvent == DFB_OK){ + DFBEvent event; + DFBResult ok = eventBuffer->GetEvent(eventBuffer,&event); + if (ok != DFB_OK) + DirectFBError("Failed to get event",ok); + if (event.clazz == DFEC_WINDOW) { + switch (event.window.type) { + case DWET_BUTTONDOWN: + case DWET_BUTTONUP: +// case DWET_MOTION: + case DWET_WHEEL: + handleMouseEvents(event); + break; + case DWET_KEYDOWN: + qDebug() << "FOOOOBAR!"; + } + + } else + qDebug() << "WHAT!"; + + hasEvent = eventBuffer->HasEvent(eventBuffer); + } +} + +void QDirectFbInput::handleMouseEvents(const DFBEvent &event) +{ + QEvent::Type type = QDirectFbConvenience::eventType(event.window.type); + QPoint p(event.window.cx, event.window.cy); + QPoint globalPos = globalPoint(event); + Qt::MouseButton button = QDirectFbConvenience::mouseButton(event.window.button); + Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); + + qDebug() << QDirectFbConvenience::keyMap()->value(event.window.key_symbol); + QMouseEvent mouseEvent(type,p,globalPos,button, buttons,(Qt::KeyboardModifiers)0); + QWidget *tlw = tlwMap.value(event.window.window_id); + QApplicationPrivate::handleMouseEvent(tlw,mouseEvent); +} + +inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const +{ + IDirectFBWindow *window; + dfbDisplayLayer->GetWindow(dfbDisplayLayer,event.window.window_id,&window); + int x,y; + window->GetPosition(window,&x,&y); + return QPoint(event.window.cx +x, event.window.cy + y); +} + diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h new file mode 100644 index 0000000..529d51a --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h @@ -0,0 +1,49 @@ +#ifndef QDIRECTFBINPUT_H +#define QDIRECTFBINPUT_H + +#include +#include +#include +#include +#include + +#include + +class InputSocketWaiter : public QThread +{ + Q_OBJECT +public: + InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent); +protected: + void run(); +signals: + void newEvent(); +private: + IDirectFBEventBuffer *eventBuffer; +}; + +class QDirectFbInput : public QObject +{ + Q_OBJECT +public: + QDirectFbInput(QObject *parent = 0); + + void addWindow(DFBWindowID id, QWidget *tlw); + +public slots: + void handleEvents(); + +private: + + void handleMouseEvents(const DFBEvent & event); + IDirectFB *dfbInterface; + IDirectFBDisplayLayer *dfbDisplayLayer; + IDirectFBEventBuffer *eventBuffer; + + QHashtlwMap; + + inline QPoint globalPoint(const DFBEvent &event) const; + +}; + +#endif // QDIRECTFBINPUT_H diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index 117e4b5..3f10aec 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -55,6 +55,7 @@ QT_BEGIN_NAMESPACE QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int display) + :QGraphicsSystemScreen() , m_input(this) { DFBResult result = dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &m_layer); if (result != DFB_OK) { @@ -90,7 +91,7 @@ QDirectFbGraphicsSystemScreen::~QDirectFbGraphicsSystemScreen() { } -IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect) +IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect, QWidget *tlw) { IDirectFBWindow *window; @@ -110,6 +111,10 @@ IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect) if (result != DFB_OK) { DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); } + + DFBWindowID id; + window->GetID(window, &id); + m_input.addWindow(id,tlw); return window; } diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h index 462e963..6068495 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h @@ -42,6 +42,8 @@ #ifndef QGRAPHICSSYSTEM_MINIMAL_H #define QGRAPHICSSYSTEM_MINIMAL_H +#include "qdirectfbinput.h" + #include #include @@ -58,7 +60,7 @@ public: QImage::Format format() const { return m_format; } QSize physicalSize() const { return m_physicalSize; } - IDirectFBWindow *createWindow(const QRect &); + IDirectFBWindow *createWindow(const QRect &,QWidget *tlw); public: QRect m_geometry; @@ -66,8 +68,11 @@ public: QImage::Format m_format; QSize m_physicalSize; + QDirectFbInput m_input; + IDirectFBScreen *m_screen; IDirectFBDisplayLayer *m_layer; + }; class QDirectFbGraphicsSystem : public QGraphicsSystem diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 43bfd9b..6c8b2b4 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -53,7 +53,7 @@ QDirectFbWindowSurface::QDirectFbWindowSurface : QWindowSurface(window), m_screen(screen), m_lock(false) { window->setWindowSurface(this); - m_dfbWindow = m_screen->createWindow(window->rect()); + m_dfbWindow = m_screen->createWindow(window->rect(),window); DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); if (result != DFB_OK) { DirectFBError("QDirectFbWindowSurface::QDirectFbWindowSurface: unable to get windows surface",result); @@ -66,7 +66,6 @@ QDirectFbWindowSurface::QDirectFbWindowSurface pmdata->setBlittable(blitter); m_pixmap = new QPixmap(pmdata); - } QDirectFbWindowSurface::~QDirectFbWindowSurface() -- cgit v0.12 From 932346c345d7759b0e9280434a0371c8e9d67b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 9 Dec 2009 11:02:15 +0100 Subject: Quick fix for bitmap type --- src/gui/image/qpixmap_blitter.cpp | 3 +-- src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp | 4 +--- .../graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp | 5 ++++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 35d6ddb..08b0c3c 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -103,8 +103,7 @@ void QBlittablePixmapData::fromImage(const QImage &image, resize(image.width(),image.height()); QImage *thisImg = blittable()->lock(); QPainter p(thisImg); - p.drawImage(0,0,image,flags); - + p.drawImage(blittable()->rect(),image,image.rect()); } QPaintEngine *QBlittablePixmapData::paintEngine() const diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 4ba4ff8..cb9b411 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -64,12 +64,10 @@ void QDirectFbInput::handleEvents() switch (event.window.type) { case DWET_BUTTONDOWN: case DWET_BUTTONUP: -// case DWET_MOTION: + case DWET_MOTION: case DWET_WHEEL: handleMouseEvents(event); break; - case DWET_KEYDOWN: - qDebug() << "FOOOOBAR!"; } } else diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index 3f10aec..b4766f3 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -151,7 +151,10 @@ QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() QPixmapData *QDirectFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const { - return new QBlittablePixmapData(type); + if (type == QPixmapData::BitmapType) + return new QRasterPixmapData(type); + else + return new QBlittablePixmapData(type); } QWindowSurface *QDirectFbGraphicsSystem::createWindowSurface(QWidget *widget) const -- cgit v0.12 From 53b0e8047e22930bd10a8f1d5ce573b6b190fbad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 9 Dec 2009 13:12:50 +0100 Subject: Fix stupid stride error in qblitter_directfb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit How many times am I going to make that mistake?"£$%"^ --- src/gui/image/qpixmap_blitter.cpp | 2 +- src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp | 2 +- .../graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 08b0c3c..18761a9 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -103,7 +103,7 @@ void QBlittablePixmapData::fromImage(const QImage &image, resize(image.width(),image.height()); QImage *thisImg = blittable()->lock(); QPainter p(thisImg); - p.drawImage(blittable()->rect(),image,image.rect()); + p.drawImage(0,0,image,flags); } QPaintEngine *QBlittablePixmapData::paintEngine() const diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp index 8d54c21..3c58970 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp @@ -79,7 +79,7 @@ QImage *QDirectFbBlitter::doLock() QImage::Format format = QDirectFbConvenience::imageFormatFromSurface(m_surface); int w, h; m_surface->GetSize(m_surface,&w,&h); - m_image = QImage(static_cast(mem),w,h,format); + m_image = QImage(static_cast(mem),w,h,bpl,format); } else { DirectFBError("Failed to lock image", result); } diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index b4766f3..b7aab7a 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -97,15 +97,14 @@ IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect, DFBWindowDescription description; memset(&description,0,sizeof(DFBWindowDescription)); -// description.flags = DWDESC_SURFACE_CAPS; + description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS|DWDESC_OPTIONS|DWDESC_CAPS); description.width = rect.width(); description.height = rect.height(); description.posx = rect.x(); description.posy = rect.y(); -// description.flags |= DWDESC_OPTIONS; -// description.options = DWOP_GHOST|DWOP_ALPHACHANNEL; -// description.caps = (DFBWindowDescription) (DWCAPS_NODECORATION|DWCAPS_DOUBLEBUFFER); -// description.surface_caps = DSCAPS_PREMULTIPLIED; + description.options = DFBWindowOptions(DWOP_GHOST|DWOP_ALPHACHANNEL); + description.caps = DFBWindowCapabilities(DWCAPS_NODECORATION|DWCAPS_DOUBLEBUFFER); + description.surface_caps = DSCAPS_PREMULTIPLIED; DFBResult result = m_layer->CreateWindow(m_layer,&description,&window); if (result != DFB_OK) { -- cgit v0.12 From 2ed5e8dc4b72f7aea5bc42643d5efd6b0dc9ff4a Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 9 Dec 2009 14:14:59 +0100 Subject: application supplied bitmap cursors for the testlite backend --- src/plugins/graphicssystems/testlite/x11util.cpp | 33 +++++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index 1a421e8..cb08230 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -943,7 +943,6 @@ void MyWindow::setCursor(QCursor * cursor) Cursor MyWindow::createCursorBitmap(QCursor * cursor) { -/* XColor bg, fg; bg.red = 255 << 8; bg.green = 255 << 8; @@ -954,21 +953,35 @@ Cursor MyWindow::createCursorBitmap(QCursor * cursor) QPoint spot = cursor->hotSpot(); Window rootwin = window; - const QBitmap * map = cursor->bitmap(); - char * mapBits = reinterpret_cast(map->toImage().bits()); - const QBitmap * mask = cursor->mask(); - char * maskBits = reinterpret_cast(mask->toImage().bits()); + QImage mapImage = cursor->bitmap()->toImage().convertToFormat(QImage::Format_MonoLSB); + QImage maskImage = cursor->mask()->toImage().convertToFormat(QImage::Format_MonoLSB); - Pixmap cp = XCreateBitmapFromData(xd->display, rootwin, mapBits, map->width(), map->height()); - Pixmap mp = XCreateBitmapFromData(xd->display, rootwin, maskBits, map->width(), map->height()); + int width = cursor->bitmap()->width(); + int height = cursor->bitmap()->height(); + int bytesPerLine = mapImage.bytesPerLine(); + int destLineSize = width / 8; + if (width % 8) + destLineSize++; + + const uchar * map = mapImage.bits(); + const uchar * mask = maskImage.bits(); + + char * mapBits = new char[height * destLineSize]; + char * maskBits = new char[height * destLineSize]; + for (int i = 0; i < height; i++) { + memcpy(mapBits + (destLineSize * i),map + (bytesPerLine * i), destLineSize); + memcpy(maskBits + (destLineSize * i),mask + (bytesPerLine * i), destLineSize); + } + + Pixmap cp = XCreateBitmapFromData(xd->display, rootwin, mapBits, width, height); + Pixmap mp = XCreateBitmapFromData(xd->display, rootwin, maskBits, width, height); Cursor c = XCreatePixmapCursor(xd->display, cp, mp, &fg, &bg, spot.x(), spot.y()); XFreePixmap(xd->display, cp); XFreePixmap(xd->display, mp); + delete[] mapBits; + delete[] maskBits; return c; -*/ - // correct pixmap cursor parsing not implemented yet - return createCursorShape(Qt::ArrowCursor); } Cursor MyWindow::createCursorShape(int cshape) -- cgit v0.12 From 594427bcd0351350c2d2298d6b193bb1014b6bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 9 Dec 2009 15:27:35 +0100 Subject: copy and paste error :( --- src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp | 2 +- src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index cb9b411..695c985 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -46,7 +46,7 @@ void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) IDirectFBWindow *window; dfbDisplayLayer->GetWindow(dfbDisplayLayer,id,&window); -// window->DisableEvents(window,DWET_ALL); + window->DisableEvents(window,DWET_ALL); window->EnableEvents(window,DFBWindowEventType(DWET_ALL)); window->SetKeySelection(window,DWKS_ALL,NULL,0); window->AttachEventBuffer(window,eventBuffer); diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index b7aab7a..0583364 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -102,8 +102,8 @@ IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect, description.height = rect.height(); description.posx = rect.x(); description.posy = rect.y(); - description.options = DFBWindowOptions(DWOP_GHOST|DWOP_ALPHACHANNEL); - description.caps = DFBWindowCapabilities(DWCAPS_NODECORATION|DWCAPS_DOUBLEBUFFER); + description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); + description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER); description.surface_caps = DSCAPS_PREMULTIPLIED; DFBResult result = m_layer->CreateWindow(m_layer,&description,&window); -- cgit v0.12 From a4c7e91befad73601c0ee6e194a5dfeb6cac61a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 10 Dec 2009 13:37:36 +0100 Subject: Added keypresses to minimaldfbinput --- .../graphicssystems/minimaldfb/qdirectfbconvenience.cpp | 4 ++++ src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp | 14 +++++++++++++- src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h | 3 ++- .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 4 ++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp index f0293bd..cd1f568 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp @@ -83,6 +83,10 @@ QEvent::Type QDirectFbConvenience::eventType(DFBWindowEventType type) return QEvent::MouseMove; case DWET_WHEEL: return QEvent::Wheel; + case DWET_KEYDOWN: + return QEvent::KeyPress; + case DWET_KEYUP: + return QEvent::KeyRelease; default: return QEvent::None; } diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 695c985..7c8d3c2 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -68,6 +68,9 @@ void QDirectFbInput::handleEvents() case DWET_WHEEL: handleMouseEvents(event); break; + case DWET_KEYDOWN: + case DWET_KEYUP: + handleKeyEvents(event); } } else @@ -85,12 +88,21 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) Qt::MouseButton button = QDirectFbConvenience::mouseButton(event.window.button); Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); - qDebug() << QDirectFbConvenience::keyMap()->value(event.window.key_symbol); QMouseEvent mouseEvent(type,p,globalPos,button, buttons,(Qt::KeyboardModifiers)0); QWidget *tlw = tlwMap.value(event.window.window_id); QApplicationPrivate::handleMouseEvent(tlw,mouseEvent); } +void QDirectFbInput::handleKeyEvents(const DFBEvent &event) +{ + QEvent::Type type = QDirectFbConvenience::eventType(event.window.type); + Qt::Key key = QDirectFbConvenience::keyMap()->value(event.window.key_symbol); + + QKeyEvent keyEvent(type,key,0,QChar(event.window.key_symbol));//,"",true,0); + QWidget *tlw = tlwMap.value(event.window.window_id); + QApplicationPrivate::handleKeyEvent(tlw,&keyEvent); +} + inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const { IDirectFBWindow *window; diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h index 529d51a..ddc2dbf 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h @@ -35,7 +35,8 @@ public slots: private: - void handleMouseEvents(const DFBEvent & event); + void handleMouseEvents(const DFBEvent &event); + void handleKeyEvents(const DFBEvent &event); IDirectFB *dfbInterface; IDirectFBDisplayLayer *dfbDisplayLayer; IDirectFBEventBuffer *eventBuffer; diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index 0583364..fe3b1d8 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -62,6 +62,10 @@ QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int DirectFBError("QDirectFbGraphicsSystemScreen " "Unable to get primary display layer!", result); } + DFBDisplayLayerConfig *displayLayerConfig; +// m_layer->GetConfiguration(m_layer,displayLayerConfig); +// displayLayerConfig->surface_caps = DFBSurfaceCapabilities(displayLayerConfig->surface_caps | DSCAPS_PREMULTIPLIED); +// m_layer->SetConfiguration(m_layer, displayLayerConfig); m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); IDirectFBSurface *topLevelSurface; -- cgit v0.12 From 2a0229375424499b9d83dd3214595efdc624a8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 11 Dec 2009 09:19:59 +0100 Subject: Minimaldfb: Added keyboard modifiers to keyevents and added double click to mouseevents --- .../minimaldfb/qdirectfbconvenience.cpp | 22 ++++++++++++++++ .../minimaldfb/qdirectfbconvenience.h | 1 + .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 29 ++++++++++++++++++++-- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp index cd1f568..63ae289 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp @@ -72,6 +72,28 @@ Qt::MouseButtons QDirectFbConvenience::mouseButtons(DFBInputDeviceButtonMask mas return buttons; } +Qt::KeyboardModifiers QDirectFbConvenience::keyboardModifiers(DFBInputDeviceModifierMask mask) +{ + Qt::KeyboardModifiers modifiers = Qt::NoModifier; + + if (mask & DIMM_SHIFT) { + modifiers |= Qt::ShiftModifier; + } + if (mask & DIMM_ALT) { + modifiers |= Qt::AltModifier; + } + if (mask & DIMM_ALTGR) { + modifiers |= Qt::MetaModifier; + } + if (mask & DIMM_CONTROL) { + modifiers |= Qt::ControlModifier; + } + if (mask & DIMM_META) { + modifiers | Qt::MetaModifier; + } + return modifiers; +} + QEvent::Type QDirectFbConvenience::eventType(DFBWindowEventType type) { switch(type) { diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h index 0ae1410..2f5e10b 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h @@ -23,6 +23,7 @@ public: static IDirectFB *dfbInterface() { return dfb; } static Qt::MouseButton mouseButton(DFBInputDeviceButtonIdentifier identifier); static Qt::MouseButtons mouseButtons(DFBInputDeviceButtonMask mask); + static Qt::KeyboardModifiers keyboardModifiers(DFBInputDeviceModifierMask mask); static QEvent::Type eventType(DFBWindowEventType type); static QDirectFbKeyMap *keyMap(); diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 7c8d3c2..b6f0b65 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -71,6 +71,9 @@ void QDirectFbInput::handleEvents() case DWET_KEYDOWN: case DWET_KEYUP: handleKeyEvents(event); + break; + default: + break; } } else @@ -87,9 +90,30 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) QPoint globalPos = globalPoint(event); Qt::MouseButton button = QDirectFbConvenience::mouseButton(event.window.button); Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); + QWidget *tlw = tlwMap.value(event.window.window_id); + if (event.window.type == DWET_BUTTONDOWN) { + static long prevTime = 0; + static QWidget *prevWindow; + static int prevX = -999; + static int prevY = -999; + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + timestamp /= 1000; + + if (tlw == prevWindow && timestamp - prevTime < QApplication::doubleClickInterval() + && qAbs(event.window.cx - prevX) < 5 && qAbs(event.window.cy - prevY) < 5) { + type = QEvent::MouseButtonDblClick; + prevTime = timestamp - QApplication::doubleClickInterval(); //no double click next time + } else { + prevTime = timestamp; + } + prevWindow = tlw; + prevX = event.window.cx; + prevY = event.window.cy; + } + + //DFB doesn't give keyboardmodifiers on mouseevents QMouseEvent mouseEvent(type,p,globalPos,button, buttons,(Qt::KeyboardModifiers)0); - QWidget *tlw = tlwMap.value(event.window.window_id); QApplicationPrivate::handleMouseEvent(tlw,mouseEvent); } @@ -97,8 +121,9 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event) { QEvent::Type type = QDirectFbConvenience::eventType(event.window.type); Qt::Key key = QDirectFbConvenience::keyMap()->value(event.window.key_symbol); + Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers); - QKeyEvent keyEvent(type,key,0,QChar(event.window.key_symbol));//,"",true,0); + QKeyEvent keyEvent(type,key,modifiers,QChar(event.window.key_symbol)); QWidget *tlw = tlwMap.value(event.window.window_id); QApplicationPrivate::handleKeyEvent(tlw,&keyEvent); } -- cgit v0.12 From 0447b44246ff46eb273f95b6daf3e7f7de73ca6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 11 Dec 2009 09:57:48 +0100 Subject: Minimaldfb: wheelevent --- .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 17 ++++++++++++++++- src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index b6f0b65..744b5c0 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -65,9 +65,11 @@ void QDirectFbInput::handleEvents() case DWET_BUTTONDOWN: case DWET_BUTTONUP: case DWET_MOTION: - case DWET_WHEEL: handleMouseEvents(event); break; + case DWET_WHEEL: + handleWheelEvent(event); + break; case DWET_KEYDOWN: case DWET_KEYUP: handleKeyEvents(event); @@ -117,6 +119,19 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) QApplicationPrivate::handleMouseEvent(tlw,mouseEvent); } +void QDirectFbInput::handleWheelEvent(const DFBEvent &event) +{ + QPoint p(event.window.cx, event.window.cy); + QPoint globalPos = globalPoint(event); + Qt::MouseButton button = QDirectFbConvenience::mouseButton(event.window.button); + Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); + QWidget *tlw = tlwMap.value(event.window.window_id); + + QWheelEvent wheelEvent(p,globalPos,event.window.step*120,buttons,Qt::NoModifier,Qt::Vertical); + QApplicationPrivate::handleWheelEvent(tlw,wheelEvent); + +} + void QDirectFbInput::handleKeyEvents(const DFBEvent &event) { QEvent::Type type = QDirectFbConvenience::eventType(event.window.type); diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h index ddc2dbf..3a70329 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h @@ -36,6 +36,7 @@ public slots: private: void handleMouseEvents(const DFBEvent &event); + void handleWheelEvent(const DFBEvent &event); void handleKeyEvents(const DFBEvent &event); IDirectFB *dfbInterface; IDirectFBDisplayLayer *dfbDisplayLayer; -- cgit v0.12 From b2aefe0ff51a2cdb4990eb9bc19cfb044193ed21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 16 Dec 2009 14:19:45 +0100 Subject: Some cleanup and fix popup and tooltip event propagation --- .../minimaldfb/qblitter_directfb.cpp | 6 +++- .../minimaldfb/qdirectfbconvenience.cpp | 9 +----- .../minimaldfb/qdirectfbconvenience.h | 2 +- .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 3 -- .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 21 ++++---------- .../minimaldfb/qgraphicssystem_minimaldfb.h | 1 - .../minimaldfb/qwindowsurface_minimaldfb.cpp | 32 ++++++++++++++++++++-- .../minimaldfb/qwindowsurface_minimaldfb.h | 4 ++- 8 files changed, 45 insertions(+), 33 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp index 3c58970..a995b0f 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp @@ -76,7 +76,11 @@ QImage *QDirectFbBlitter::doLock() int bpl; const DFBResult result = m_surface->Lock(m_surface, DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast(&mem), &bpl); if (result == DFB_OK) { - QImage::Format format = QDirectFbConvenience::imageFormatFromSurface(m_surface); + DFBSurfacePixelFormat dfbFormat; + DFBSurfaceCapabilities dfbCaps; + m_surface->GetPixelFormat(m_surface,&dfbFormat); + m_surface->GetCapabilities(m_surface,&dfbCaps); + QImage::Format format = QDirectFbConvenience::imageFormatFromSurfaceFormat(dfbFormat, dfbCaps); int w, h; m_surface->GetSize(m_surface,&w,&h); m_image = QImage(static_cast(mem),w,h,bpl,format); diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp index 63ae289..2bd2f3b 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp @@ -2,11 +2,8 @@ IDirectFB *QDirectFbConvenience::dfb = 0; -QImage::Format QDirectFbConvenience::imageFormatFromSurface(IDirectFBSurface *surface) +QImage::Format QDirectFbConvenience::imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps) { - DFBSurfacePixelFormat format; - surface->GetPixelFormat(surface, &format); - switch (format) { case DSPF_LUT8: return QImage::Format_Indexed8; @@ -28,10 +25,6 @@ QImage::Format QDirectFbConvenience::imageFormatFromSurface(IDirectFBSurface *su case DSPF_RGB32: return QImage::Format_RGB32; case DSPF_ARGB: { - DFBSurfaceCapabilities caps; - const DFBResult result = surface->GetCapabilities(surface, &caps); - Q_ASSERT(result == DFB_OK); - Q_UNUSED(result); return (caps & DSCAPS_PREMULTIPLIED ? QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32); } diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h index 2f5e10b..9c65b1f 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h @@ -17,7 +17,7 @@ public: class QDirectFbConvenience { public: - static QImage::Format imageFormatFromSurface(IDirectFBSurface *surface); + static QImage::Format imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps); //This is set by the graphicssystem constructor static IDirectFB *dfbInterface() { return dfb; } diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 744b5c0..38bc41c 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -46,9 +46,6 @@ void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) IDirectFBWindow *window; dfbDisplayLayer->GetWindow(dfbDisplayLayer,id,&window); - window->DisableEvents(window,DWET_ALL); - window->EnableEvents(window,DFBWindowEventType(DWET_ALL)); - window->SetKeySelection(window,DWKS_ALL,NULL,0); window->AttachEventBuffer(window,eventBuffer); } diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index fe3b1d8..d9da01b 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -68,27 +68,16 @@ QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int // m_layer->SetConfiguration(m_layer, displayLayerConfig); m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); - IDirectFBSurface *topLevelSurface; - //This line gives a warning - m_layer->GetSurface(m_layer, &topLevelSurface); - m_format = QDirectFbConvenience::imageFormatFromSurface(topLevelSurface); - result = m_layer->GetScreen(m_layer,&m_screen); - if (result != DFB_OK) { - DirectFBError("QDirectFbGraphicsSystemScreen: Failed to get screen", result); - } - - int w(0),h(0); - - //Asking the screen for its size gives the desktop geometry on X11 - //Thats not something we want, so ask the topLevelSorface instead - topLevelSurface->GetSize(topLevelSurface,&w,&h); + DFBDisplayLayerConfig config; + m_layer->GetConfiguration(m_layer, &config); - m_geometry = QRect(0,0,w,h); + m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps); + m_geometry = QRect(0,0,config.width,config.height); const int dpi = 72; const qreal inch = 25.4; m_depth = 32; - m_physicalSize = QSize(qRound(w * inch / dpi), qRound(h *inch / dpi)); + m_physicalSize = QSize(qRound(config.width * inch / dpi), qRound(config.height *inch / dpi)); } QDirectFbGraphicsSystemScreen::~QDirectFbGraphicsSystemScreen() diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h index 6068495..ff6a426 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h @@ -70,7 +70,6 @@ public: QDirectFbInput m_input; - IDirectFBScreen *m_screen; IDirectFBDisplayLayer *m_layer; }; diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 6c8b2b4..e0bd33e 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -42,6 +42,7 @@ #include "qwindowsurface_minimaldfb.h" #include "qgraphicssystem_minimaldfb.h" #include "qblitter_directfb.h" +#include "qdirectfbconvenience.h" #include #include @@ -50,7 +51,7 @@ QT_BEGIN_NAMESPACE QDirectFbWindowSurface::QDirectFbWindowSurface (QDirectFbGraphicsSystemScreen *screen, QWidget *window) - : QWindowSurface(window), m_screen(screen), m_lock(false) + : QWindowSurface(window), m_screen(screen) { window->setWindowSurface(this); m_dfbWindow = m_screen->createWindow(window->rect(),window); @@ -96,7 +97,6 @@ void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const void QDirectFbWindowSurface::setGeometry(const QRect &rect) { - m_dfbSurface->Release(m_dfbSurface); QWindowSurface::setGeometry(rect); m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), rect.width(), rect.height()); @@ -124,4 +124,32 @@ void QDirectFbWindowSurface::endPaint(const QRegion ®ion) Q_UNUSED(region); } +void QDirectFbWindowSurface::setVisible(bool visible) +{ + if (visible) { + int x = this->geometry().x(); + int y = this->geometry().y(); + m_dfbWindow->MoveTo(m_dfbWindow,x,y); + } else { + IDirectFBDisplayLayer *displayLayer; + QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY,&displayLayer); + + DFBDisplayLayerConfig config; + displayLayer->GetConfiguration(displayLayer,&config); + m_dfbWindow->MoveTo(m_dfbWindow,config.width+1,config.height + 1); + } +} + +Qt::WindowFlags QDirectFbWindowSurface::setWindowFlags(Qt::WindowFlags type) +{ + if (type == Qt::Popup || type == Qt::ToolTip) + { + DFBWindowOptions options; + m_dfbWindow->GetOptions(m_dfbWindow,&options); + options = DFBWindowOptions(options | DWOP_GHOST); + m_dfbWindow->SetOptions(m_dfbWindow,options); + } + return type; +} + QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h index 98575ff..aeee049 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h @@ -66,13 +66,15 @@ public: void beginPaint(const QRegion ®ion); void endPaint(const QRegion ®ion); + void setVisible(bool visible); + Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); + private: void lockSurfaceToImage(); QDirectFbGraphicsSystemScreen *m_screen; QPixmap *m_pixmap; QBlittablePixmapData *pmdata; - bool m_lock; IDirectFBWindow *m_dfbWindow; IDirectFBSurface *m_dfbSurface; -- cgit v0.12 From 0e5b1ab9bce08a1c0927e13efdc6d24873d920ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 16 Dec 2009 17:22:15 +0100 Subject: typo in pro file --- src/gui/image/image.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index b232848..10a073b 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -23,7 +23,7 @@ HEADERS += \ image/qpictureformatplugin.h \ image/qpixmap.h \ image/qpixmap_raster_p.h \ - miage/qpixmap_blitter_p.h \ + image/qpixmap_blitter_p.h \ image/qpixmapcache.h \ image/qpixmapcache_p.h \ image/qpixmapdata_p.h \ -- cgit v0.12 From 2c64beebfe265a140263ec156a0c41f93005ba73 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 18 Dec 2009 13:21:51 +0100 Subject: queued dispatch of keyboard and mouse events Mouse and Key events can't be handed off directly to QApplicationPrivate:: andleMouseEvent() and QApplicationPrivate::handleKeyEvent() from methods that are called as the slot for a QAbstractSocket::readyRead() signal. Doing so can result in event starvation in the case of things like QMenu::exec() that have their own event loop. --- src/plugins/graphicssystems/vnc/qvncserver.cpp | 46 +++++++++++++++++++++++--- src/plugins/graphicssystems/vnc/qvncserver.h | 6 ++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp index fcff255..c2fb676 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -389,6 +389,10 @@ void QVNCServer::init(uint port) qvnc_cursor = 0; #endif encoder = 0; + + eventTimer.setInterval(0); + eventTimer.setSingleShot(true); + connect(&eventTimer, SIGNAL(timeout()), this, SLOT(sendInputEvents())); } QVNCServer::~QVNCServer() @@ -819,6 +823,30 @@ static bool buttonChange(Qt::MouseButtons before, Qt::MouseButtons after, Qt::Mo return false; } +void QVNCServer::sendInputEvents() +{ + EventPair pair; + for (int i = 0 ; i < eventList.count(); i++) { + pair = eventList[i]; + switch(pair.first) { + case MouseEvent: { + QMouseEvent *me = static_cast(pair.second); + QApplicationPrivate::handleMouseEvent(0, *me); + delete me; + break; + } + case KeyboardEvent: { + QKeyEvent *ke = static_cast(pair.second); + QApplicationPrivate::handleKeyEvent(0, ke); + delete ke; + break; + } + } + } + eventList.clear(); + Q_ASSERT(eventList.count() == 0); +} + void QVNCServer::pointerEvent() { QRfbPointerEvent ev; @@ -834,8 +862,13 @@ void QVNCServer::pointerEvent() bool isPress; if (buttonChange(buttons, ev.buttons, &button, &isPress)) type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - QMouseEvent me(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); - QApplicationPrivate::handleMouseEvent(0, me); + QMouseEvent * me = new QMouseEvent(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); + EventPair pair; + pair.first = MouseEvent; + pair.second = me; + eventList.append(pair); + if (!eventTimer.isActive()) + eventTimer.start(); buttons = ev.buttons; handleMsg = false; } @@ -861,8 +894,13 @@ void QVNCServer::keyEvent() QString str; if (ev.unicode && ev.unicode != 0xffff) str = QString(ev.unicode); - QKeyEvent keyEvent(type, ev.keycode, keymod, str); - QApplicationPrivate::handleKeyEvent(0, &keyEvent); + QKeyEvent *keyEvent = new QKeyEvent(type, ev.keycode, keymod, str); + EventPair pair; + pair.first = KeyboardEvent; + pair.second = keyEvent; + eventList.append(pair); + if (!eventTimer.isActive()) + eventTimer.start(); } handleMsg = false; } diff --git a/src/plugins/graphicssystems/vnc/qvncserver.h b/src/plugins/graphicssystems/vnc/qvncserver.h index 79b2098..be84c3c 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.h +++ b/src/plugins/graphicssystems/vnc/qvncserver.h @@ -482,6 +482,7 @@ private slots: void readClient(); void checkUpdate(); void discardClient(); + void sendInputEvents(); private: void init(uint port); @@ -519,6 +520,11 @@ private: QRfbEncoder *encoder; QVNCCursor *cursor; + + enum EventType { MouseEvent, KeyboardEvent }; + QTimer eventTimer; + typedef QPair EventPair; + QList eventList; }; -- cgit v0.12 From a2e77bb355382d484a39fcd5ab62a9f0bbd556da Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 18 Dec 2009 14:31:48 +0100 Subject: revert queueing of VNC mouse and keyboard events --- src/plugins/graphicssystems/vnc/qvncserver.cpp | 46 +++----------------------- src/plugins/graphicssystems/vnc/qvncserver.h | 6 ---- 2 files changed, 4 insertions(+), 48 deletions(-) diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp index c2fb676..fcff255 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -389,10 +389,6 @@ void QVNCServer::init(uint port) qvnc_cursor = 0; #endif encoder = 0; - - eventTimer.setInterval(0); - eventTimer.setSingleShot(true); - connect(&eventTimer, SIGNAL(timeout()), this, SLOT(sendInputEvents())); } QVNCServer::~QVNCServer() @@ -823,30 +819,6 @@ static bool buttonChange(Qt::MouseButtons before, Qt::MouseButtons after, Qt::Mo return false; } -void QVNCServer::sendInputEvents() -{ - EventPair pair; - for (int i = 0 ; i < eventList.count(); i++) { - pair = eventList[i]; - switch(pair.first) { - case MouseEvent: { - QMouseEvent *me = static_cast(pair.second); - QApplicationPrivate::handleMouseEvent(0, *me); - delete me; - break; - } - case KeyboardEvent: { - QKeyEvent *ke = static_cast(pair.second); - QApplicationPrivate::handleKeyEvent(0, ke); - delete ke; - break; - } - } - } - eventList.clear(); - Q_ASSERT(eventList.count() == 0); -} - void QVNCServer::pointerEvent() { QRfbPointerEvent ev; @@ -862,13 +834,8 @@ void QVNCServer::pointerEvent() bool isPress; if (buttonChange(buttons, ev.buttons, &button, &isPress)) type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - QMouseEvent * me = new QMouseEvent(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); - EventPair pair; - pair.first = MouseEvent; - pair.second = me; - eventList.append(pair); - if (!eventTimer.isActive()) - eventTimer.start(); + QMouseEvent me(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); + QApplicationPrivate::handleMouseEvent(0, me); buttons = ev.buttons; handleMsg = false; } @@ -894,13 +861,8 @@ void QVNCServer::keyEvent() QString str; if (ev.unicode && ev.unicode != 0xffff) str = QString(ev.unicode); - QKeyEvent *keyEvent = new QKeyEvent(type, ev.keycode, keymod, str); - EventPair pair; - pair.first = KeyboardEvent; - pair.second = keyEvent; - eventList.append(pair); - if (!eventTimer.isActive()) - eventTimer.start(); + QKeyEvent keyEvent(type, ev.keycode, keymod, str); + QApplicationPrivate::handleKeyEvent(0, &keyEvent); } handleMsg = false; } diff --git a/src/plugins/graphicssystems/vnc/qvncserver.h b/src/plugins/graphicssystems/vnc/qvncserver.h index be84c3c..79b2098 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.h +++ b/src/plugins/graphicssystems/vnc/qvncserver.h @@ -482,7 +482,6 @@ private slots: void readClient(); void checkUpdate(); void discardClient(); - void sendInputEvents(); private: void init(uint port); @@ -520,11 +519,6 @@ private: QRfbEncoder *encoder; QVNCCursor *cursor; - - enum EventType { MouseEvent, KeyboardEvent }; - QTimer eventTimer; - typedef QPair EventPair; - QList eventList; }; -- cgit v0.12 From d7667e96f2faa83ddb2d9465320fa30ba1891292 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 18 Dec 2009 15:25:22 +0100 Subject: queue VNC keyboard and mouse events for processing outside socket readyRead() Because QAbstractSocket::readyRead() isn't delivered recursively, code that has its own event loop (such as QMenu::exec()) doesn't receive mouse or keyboard events. This fixes that by queueing the event, with processing started by a 0 timer. --- src/plugins/graphicssystems/vnc/qvncserver.cpp | 45 +++++++++++++++++++++++--- src/plugins/graphicssystems/vnc/qvncserver.h | 6 ++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp index fcff255..cbf6054 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -389,6 +389,10 @@ void QVNCServer::init(uint port) qvnc_cursor = 0; #endif encoder = 0; + + eventTimer.setInterval(0); + eventTimer.setSingleShot(true); + connect(&eventTimer, SIGNAL(timeout()), this, SLOT(sendInputEvents())); } QVNCServer::~QVNCServer() @@ -819,6 +823,29 @@ static bool buttonChange(Qt::MouseButtons before, Qt::MouseButtons after, Qt::Mo return false; } +void QVNCServer::sendInputEvents() +{ + EventPair pair; + QMouseEvent *me; + QKeyEvent *ke; + + while(!eventList.isEmpty()) { + pair = eventList.takeFirst(); + switch(pair.first) { + case MouseEvent: + me = static_cast(pair.second); + QApplicationPrivate::handleMouseEvent(0, *me); + delete me; + break; + case KeyboardEvent: + ke = static_cast(pair.second); + QApplicationPrivate::handleKeyEvent(0, ke); + delete ke; + break; + } + } +} + void QVNCServer::pointerEvent() { QRfbPointerEvent ev; @@ -834,8 +861,13 @@ void QVNCServer::pointerEvent() bool isPress; if (buttonChange(buttons, ev.buttons, &button, &isPress)) type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - QMouseEvent me(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); - QApplicationPrivate::handleMouseEvent(0, me); + QMouseEvent * me = new QMouseEvent(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); + EventPair pair; + pair.first = MouseEvent; + pair.second = me; + eventList.append(pair); + if (!eventTimer.isActive()) + eventTimer.start(); buttons = ev.buttons; handleMsg = false; } @@ -861,8 +893,13 @@ void QVNCServer::keyEvent() QString str; if (ev.unicode && ev.unicode != 0xffff) str = QString(ev.unicode); - QKeyEvent keyEvent(type, ev.keycode, keymod, str); - QApplicationPrivate::handleKeyEvent(0, &keyEvent); + QKeyEvent *keyEvent = new QKeyEvent(type, ev.keycode, keymod, str); + EventPair pair; + pair.first = KeyboardEvent; + pair.second = keyEvent; + eventList.append(pair); + if (!eventTimer.isActive()) + eventTimer.start(); } handleMsg = false; } diff --git a/src/plugins/graphicssystems/vnc/qvncserver.h b/src/plugins/graphicssystems/vnc/qvncserver.h index 79b2098..be84c3c 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.h +++ b/src/plugins/graphicssystems/vnc/qvncserver.h @@ -482,6 +482,7 @@ private slots: void readClient(); void checkUpdate(); void discardClient(); + void sendInputEvents(); private: void init(uint port); @@ -519,6 +520,11 @@ private: QRfbEncoder *encoder; QVNCCursor *cursor; + + enum EventType { MouseEvent, KeyboardEvent }; + QTimer eventTimer; + typedef QPair EventPair; + QList eventList; }; -- cgit v0.12 From 4194cfdc5bcc7513ce3d6b8515fb4ab7c5bfdb16 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 30 Dec 2009 13:35:13 +0100 Subject: implement window flag get and set methods for VNC and linuxfb --- src/plugins/graphicssystems/fb_base/fb_base.cpp | 11 +++++++++++ src/plugins/graphicssystems/fb_base/fb_base.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index f9ea97f..bd8d407 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -283,3 +283,14 @@ void QGraphicsSystemFbWindowSurface::setVisible(bool visible) visibleFlag = visible; mScreen->setDirty(geometry()); } + +Qt::WindowFlags QGraphicsSystemFbWindowSurface::setWindowFlags(Qt::WindowFlags type) +{ + flags = type; + return flags; +} + +Qt::WindowFlags QGraphicsSystemFbWindowSurface::windowFlags() const +{ + return flags; +} diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h index 58f340d..f21cd41 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -61,11 +61,15 @@ public: virtual void raise(); virtual void lower(); + virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); + virtual Qt::WindowFlags windowFlags() const; + protected: QGraphicsSystemFbScreen *mScreen; QRect oldGeometry; QImage mImage; bool visibleFlag; + Qt::WindowFlags flags; }; class QGraphicsSystemFbScreen : public QGraphicsSystemScreen -- cgit v0.12 From 0647b24b35e17d3948220640192415337eb87215 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 16 Dec 2009 09:43:13 -0800 Subject: Use pkg-config/directfb-config to find cflags/libs --- .../graphicssystems/minimaldfb/minimaldfb.pro | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro index 8b20c45..6f50b4a 100644 --- a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro +++ b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro @@ -1,12 +1,21 @@ TARGET = qminimaldfb include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems -QMAKE_CXXFLAGS += -I/usr/local/include/directfb -LIBS += -L/usr/local/lib \ - -ldirectfb \ - -lfusion \ - -ldirect \ - -lpthread + +system(pkg-config --exists directfb) { + DIRECTFB_CFLAGS = $$system(pkg-config --cflags directfb) + DIRECTFB_LIBS = $$system(pkg-config --libs directfb) +} else { + directfb_config = $$SYSTEM(which directfb-config) + !isEmpty(directfb_config) { + DIRECTFB_CFLAGS = $$system(directfb-config --cflags) + DIRECTFB_LIBS = $$system(directfb-config --libs) + } +} + +QMAKE_CXXFLAGS += $$DIRECTFB_CFLAGS +LIBS += $$DIRECTFB_LIBS + SOURCES = main.cpp \ qgraphicssystem_minimaldfb.cpp \ qwindowsurface_minimaldfb.cpp \ -- cgit v0.12 From 1ce74505a12ebfe187cfdc26bf50195e5ce27b86 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 16 Dec 2009 09:44:23 -0800 Subject: Fix includes Include , not directfb-config/pkg-config gives us the -I to installpath/include/directfb so this include breaks a properly configured DirectFB --- src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h | 2 +- src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h | 2 +- src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h index c1fbc14..73eb7fb 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h @@ -3,7 +3,7 @@ #include -#include +#include class QDirectFbBlitter : public QBlittable { diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h index 9c65b1f..525aa22 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h @@ -5,7 +5,7 @@ #include #include -#include +#include class QDirectFbKeyMap: public QHash { diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h index 3a70329..e5bfba0 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h @@ -7,7 +7,7 @@ #include #include -#include +#include class InputSocketWaiter : public QThread { -- cgit v0.12 From 9983638b6fbb2dceeef3eac6c31d9b52384beff6 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 16 Dec 2009 09:45:45 -0800 Subject: Compile with DirectFB < 1.1 --- .../graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp | 9 +++++++-- .../graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index d9da01b..e0479a0 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -50,7 +50,6 @@ #include #include #include -#include QT_BEGIN_NAMESPACE @@ -90,12 +89,18 @@ IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect, DFBWindowDescription description; memset(&description,0,sizeof(DFBWindowDescription)); - description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS|DWDESC_OPTIONS|DWDESC_CAPS); + description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS +#if DIRECTFB_MINOR_VERSION >= 1 + |DWDESC_OPTIONS +#endif + |DWDESC_CAPS); description.width = rect.width(); description.height = rect.height(); description.posx = rect.x(); description.posy = rect.y(); +#if DIRECTFB_MINOR_VERSION >= 1 description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); +#endif description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER); description.surface_caps = DSCAPS_PREMULTIPLIED; diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h index ff6a426..2f29ab4 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h @@ -46,6 +46,7 @@ #include #include +#include QT_BEGIN_NAMESPACE -- cgit v0.12 From be4e111877aafec15cecbd7a356fb7e6dd076c61 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 16 Dec 2009 09:59:51 -0800 Subject: Initialize variables to 0 --- .../graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index e0bd33e..53937b8 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -49,9 +49,9 @@ QT_BEGIN_NAMESPACE -QDirectFbWindowSurface::QDirectFbWindowSurface - (QDirectFbGraphicsSystemScreen *screen, QWidget *window) - : QWindowSurface(window), m_screen(screen) +QDirectFbWindowSurface::QDirectFbWindowSurface(QDirectFbGraphicsSystemScreen *screen, QWidget *window) + : QWindowSurface(window), m_screen(screen), m_pixmap(0), pmdata(0), + m_dfbWindow(0), m_dfbSurface(0) { window->setWindowSurface(this); m_dfbWindow = m_screen->createWindow(window->rect(),window); -- cgit v0.12 From 6911786e2275b41284b19c88dc9692e78a01a647 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 16 Dec 2009 10:00:33 -0800 Subject: Flip OnSync to avoid tearing --- src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 53937b8..4d35376 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -91,7 +91,7 @@ void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const for (int i = 0 ; i < rects.size(); i++) { const QRect rect = rects.at(i); DFBRegion dfbReg = { rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()}; - m_dfbSurface->Flip(m_dfbSurface,&dfbReg,DSFLIP_BLIT); + m_dfbSurface->Flip(m_dfbSurface, &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC)); } } -- cgit v0.12 From c8ed3a4499adae2c26e66a1e00bffa28cc649b5a Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 16 Dec 2009 10:01:22 -0800 Subject: Release surface before getting a new one --- src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 4d35376..4a055ac 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -100,6 +100,10 @@ void QDirectFbWindowSurface::setGeometry(const QRect &rect) QWindowSurface::setGeometry(rect); m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), rect.width(), rect.height()); + if (m_dfbSurface) { + m_dfbSurface->Release(m_dfbSurface); + m_dfbSurface = 0; + } DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); if (result != DFB_OK) DirectFBError("QDirectFbWindowSurface::setGeometry() failed to retrieve new surface",result); -- cgit v0.12 From c4891eb3f74db6aebf10565d629b683204aa0166 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 16 Dec 2009 10:03:18 -0800 Subject: Clear and Flip surface when resizing/creating --- .../graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 4a055ac..fc2a1fe 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -59,6 +59,10 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QDirectFbGraphicsSystemScreen *sc if (result != DFB_OK) { DirectFBError("QDirectFbWindowSurface::QDirectFbWindowSurface: unable to get windows surface",result); } + if (m_dfbSurface) { + m_dfbSurface->Clear(m_dfbSurface, 0, 0, 0, 0); + m_dfbSurface->Flip(m_dfbSurface, 0, DSFLIP_ONSYNC); + } QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); int width,height; @@ -105,9 +109,15 @@ void QDirectFbWindowSurface::setGeometry(const QRect &rect) m_dfbSurface = 0; } DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); + if (result != DFB_OK) DirectFBError("QDirectFbWindowSurface::setGeometry() failed to retrieve new surface",result); + if (m_dfbSurface) { + m_dfbSurface->Clear(m_dfbSurface, 0, 0, 0, 0); + m_dfbSurface->Flip(m_dfbSurface, 0, DSFLIP_ONSYNC); + } + QDirectFbBlitter *blitter = new QDirectFbBlitter(rect, m_dfbSurface); pmdata->resize(rect.width(),rect.height()); pmdata->setBlittable(blitter); -- cgit v0.12 From 0191180e2fe92a2b4f709ac4eb8a1065726906c4 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 16 Dec 2009 10:03:47 -0800 Subject: Fix setWindowFlags and implement raise()/lower() --- .../minimaldfb/qwindowsurface_minimaldfb.cpp | 24 ++++++++++++++++++---- .../minimaldfb/qwindowsurface_minimaldfb.h | 2 ++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index fc2a1fe..913e01d 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -154,16 +154,32 @@ void QDirectFbWindowSurface::setVisible(bool visible) } } -Qt::WindowFlags QDirectFbWindowSurface::setWindowFlags(Qt::WindowFlags type) +Qt::WindowFlags QDirectFbWindowSurface::setWindowFlags(Qt::WindowFlags flags) { - if (type == Qt::Popup || type == Qt::ToolTip) - { + switch (flags & Qt::WindowType_Mask) { + case Qt::Popup: + case Qt::ToolTip: { DFBWindowOptions options; m_dfbWindow->GetOptions(m_dfbWindow,&options); options = DFBWindowOptions(options | DWOP_GHOST); m_dfbWindow->SetOptions(m_dfbWindow,options); + break; } + default: + break; } - return type; + + m_dfbWindow->SetStackingClass(m_dfbWindow, flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE); + return flags; +} + +void QDirectFbWindowSurface::raise() +{ + m_dfbWindow->RaiseToTop(m_dfbWindow); +} + +void QDirectFbWindowSurface::lower() +{ + m_dfbWindow->LowerToBottom(m_dfbWindow); } QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h index aeee049..3c81287 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h @@ -69,6 +69,8 @@ public: void setVisible(bool visible); Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); + void raise(); + void lower(); private: void lockSurfaceToImage(); -- cgit v0.12 From 021c5f11c3a72a04f05b3a7b52ffd14e0fc6488c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 16 Dec 2009 10:29:19 -0800 Subject: Fix mouse events. The window coordinate is passed in x and y, not cx, cy. --- src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 38bc41c..e470b9a 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -85,7 +85,7 @@ void QDirectFbInput::handleEvents() void QDirectFbInput::handleMouseEvents(const DFBEvent &event) { QEvent::Type type = QDirectFbConvenience::eventType(event.window.type); - QPoint p(event.window.cx, event.window.cy); + QPoint p(event.window.x, event.window.y); QPoint globalPos = globalPoint(event); Qt::MouseButton button = QDirectFbConvenience::mouseButton(event.window.button); Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); -- cgit v0.12 From 781e8b00979f22de15a17510121be1ad20630c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 17 Dec 2009 11:50:43 +0100 Subject: Adding serialnumber to qpixmap_blitter --- src/gui/image/qpixmap_blitter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 18761a9..3b18ca9 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -21,6 +21,7 @@ QBlittable *QBlittablePixmapData::blittable() const if (!m_blittable) { QBlittablePixmapData *that = const_cast(this); that->m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QRect(0,0,w,h)); + that->setSerialNumber(m_blittable->lock()->serialNumber()); } return m_blittable; -- cgit v0.12 From 5e4b2e2591bb1b5897b29c43fa35b0a60fd43d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 5 Jan 2010 12:09:20 +0100 Subject: Make sure that premultiplied surfaces are used and clean up a bit. Also removed alot of unnecessary windowsurface code --- src/gui/image/qpixmap_blitter.cpp | 8 ++-- src/gui/painting/qpaintengine_blitter_p.h | 1 - .../minimaldfb/qblitter_directfb.cpp | 3 +- .../minimaldfb/qdirectfbconvenience.cpp | 6 +-- .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 7 +--- .../minimaldfb/qwindowsurface_minimaldfb.cpp | 44 +++++++--------------- .../minimaldfb/qwindowsurface_minimaldfb.h | 2 +- 7 files changed, 24 insertions(+), 47 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 3b18ca9..3613211 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -29,15 +29,13 @@ QBlittable *QBlittablePixmapData::blittable() const void QBlittablePixmapData::setBlittable(QBlittable *blittable) { - if (m_blittable) - delete m_blittable; + delete m_blittable; + resize(blittable->rect().width(),blittable->rect().height()); m_blittable = blittable; } void QBlittablePixmapData::resize(int width, int height) { - delete m_blittable; - m_blittable = 0; delete m_engine; m_engine = 0; d = QApplicationPrivate::graphicsSystem()->screens().at(0)->depth(); @@ -78,7 +76,7 @@ int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const void QBlittablePixmapData::fill(const QColor &color) { if (blittable()->capabilities() & QBlittable::SolidRectCapability) - blittable()->fillRect(m_blittable->rect(),color); + blittable()->fillRect(QRectF(0,0,w,h),color); else blittable()->lock()->fill(color.rgb()); } diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index 6a5462e..7f67997 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -8,7 +8,6 @@ class QBlittablePrivate; class QBlitterPaintEnginePrivate; class QBlittablePixmapData; -// ### find name class Q_GUI_EXPORT QBlittable { Q_DECLARE_PRIVATE(QBlittable); diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp index a995b0f..06622a1 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp @@ -20,7 +20,8 @@ QDirectFbBlitter::QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface) DFBSurfaceDescription surfaceDesc; surfaceDesc.width = rect.width(); surfaceDesc.height = rect.height(); - surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT); + surfaceDesc.caps = DSCAPS_PREMULTIPLIED; + surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS); IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp index 2bd2f3b..4e2085d 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp @@ -25,9 +25,9 @@ QImage::Format QDirectFbConvenience::imageFormatFromSurfaceFormat(const DFBSurfa case DSPF_RGB32: return QImage::Format_RGB32; case DSPF_ARGB: { - return (caps & DSCAPS_PREMULTIPLIED - ? QImage::Format_ARGB32_Premultiplied - : QImage::Format_ARGB32); } + if (caps & DSCAPS_PREMULTIPLIED) + return QImage::Format_ARGB32_Premultiplied; + else return QImage::Format_ARGB32; } default: break; } diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index e0479a0..9e5e8bb 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -61,13 +61,8 @@ QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int DirectFBError("QDirectFbGraphicsSystemScreen " "Unable to get primary display layer!", result); } - DFBDisplayLayerConfig *displayLayerConfig; -// m_layer->GetConfiguration(m_layer,displayLayerConfig); -// displayLayerConfig->surface_caps = DFBSurfaceCapabilities(displayLayerConfig->surface_caps | DSCAPS_PREMULTIPLIED); -// m_layer->SetConfiguration(m_layer, displayLayerConfig); m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); - DFBDisplayLayerConfig config; m_layer->GetConfiguration(m_layer, &config); @@ -101,7 +96,7 @@ IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect, #if DIRECTFB_MINOR_VERSION >= 1 description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); #endif - description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER); + description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL); description.surface_caps = DSCAPS_PREMULTIPLIED; DFBResult result = m_layer->CreateWindow(m_layer,&description,&window); diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 913e01d..f7229e9 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -47,30 +47,25 @@ #include +#include + QT_BEGIN_NAMESPACE QDirectFbWindowSurface::QDirectFbWindowSurface(QDirectFbGraphicsSystemScreen *screen, QWidget *window) - : QWindowSurface(window), m_screen(screen), m_pixmap(0), pmdata(0), + : QWindowSurface(window), m_screen(screen), m_pixmap(0), m_pmdata(0), m_dfbWindow(0), m_dfbSurface(0) { window->setWindowSurface(this); m_dfbWindow = m_screen->createWindow(window->rect(),window); - DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); - if (result != DFB_OK) { - DirectFBError("QDirectFbWindowSurface::QDirectFbWindowSurface: unable to get windows surface",result); - } - if (m_dfbSurface) { - m_dfbSurface->Clear(m_dfbSurface, 0, 0, 0, 0); - m_dfbSurface->Flip(m_dfbSurface, 0, DSFLIP_ONSYNC); - } + m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); + qDebug () << "initial surface: " << m_dfbSurface; + QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); - pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); - int width,height; - m_dfbSurface->GetSize(m_dfbSurface, &width, &height); - pmdata->resize(width,height); - pmdata->setBlittable(blitter); + m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); + m_pmdata->setBlittable(blitter); + m_pixmap = new QPixmap(m_pmdata); + - m_pixmap = new QPixmap(pmdata); } QDirectFbWindowSurface::~QDirectFbWindowSurface() @@ -104,23 +99,12 @@ void QDirectFbWindowSurface::setGeometry(const QRect &rect) QWindowSurface::setGeometry(rect); m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), rect.width(), rect.height()); - if (m_dfbSurface) { - m_dfbSurface->Release(m_dfbSurface); - m_dfbSurface = 0; - } - DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); - if (result != DFB_OK) - DirectFBError("QDirectFbWindowSurface::setGeometry() failed to retrieve new surface",result); - - if (m_dfbSurface) { - m_dfbSurface->Clear(m_dfbSurface, 0, 0, 0, 0); - m_dfbSurface->Flip(m_dfbSurface, 0, DSFLIP_ONSYNC); - } + //Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable + m_dfbSurface->AddRef(m_dfbSurface); + QBlittable *blittabler = new QDirectFbBlitter(rect,m_dfbSurface); + m_pmdata->setBlittable(blittabler); - QDirectFbBlitter *blitter = new QDirectFbBlitter(rect, m_dfbSurface); - pmdata->resize(rect.width(),rect.height()); - pmdata->setBlittable(blitter); } bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h index 3c81287..f74fb29 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h @@ -76,7 +76,7 @@ private: QDirectFbGraphicsSystemScreen *m_screen; QPixmap *m_pixmap; - QBlittablePixmapData *pmdata; + QBlittablePixmapData *m_pmdata; IDirectFBWindow *m_dfbWindow; IDirectFBSurface *m_dfbSurface; -- cgit v0.12 From e6c02f892651e69fc7f3a1991e115a7c315cc1de Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 30 Dec 2009 15:21:30 +0100 Subject: working on cursor changes - not at all functional currently --- .../graphicssystems/minimaldfb/minimaldfb.pro | 6 +- .../graphicssystems/minimaldfb/qdirectfbcursor.cpp | 73 ++++++++++++++++++++++ .../graphicssystems/minimaldfb/qdirectfbcursor.h | 22 +++++++ .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 4 ++ .../minimaldfb/qgraphicssystem_minimaldfb.h | 5 ++ 5 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp create mode 100644 src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.h diff --git a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro index 6f50b4a..f5d2406 100644 --- a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro +++ b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro @@ -21,11 +21,13 @@ SOURCES = main.cpp \ qwindowsurface_minimaldfb.cpp \ qblitter_directfb.cpp \ qdirectfbconvenience.cpp \ - qdirectfbinput.cpp + qdirectfbinput.cpp \ + qdirectfbcursor.cpp HEADERS = qgraphicssystem_minimaldfb.h \ qwindowsurface_minimaldfb.h \ qblitter_directfb.h \ qdirectfbconvenience.h \ - qdirectfbinput.h + qdirectfbinput.h \ + qdirectfbcursor.h target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems INSTALLS += target diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp new file mode 100644 index 0000000..9c6cc59 --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp @@ -0,0 +1,73 @@ +#include "qdirectfbcursor.h" +#include "qblitter_directfb.h" +#include "qgraphicssystem_minimaldfb.h" +#include "qdirectfbconvenience.h" + +QDirectFBCursor::QDirectFBCursor(QGraphicsSystemScreen * screen) : + QGraphicsSystemCursor(screen), surface(0) +{ + QDirectFbGraphicsSystemScreen * s; + s = static_cast(screen); + m_layer = s->m_layer; + image = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); +} + +void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) +{ + qDebug() << "cursor change request:" << cursor << widget; + + if (cursor->shape() != Qt::BitmapCursor) { + image->set(cursor->shape()); + } else { + qDebug() << "non-shape cursor: not implemented yet"; + return; // not attempting to deal with application supplied cursors yet + } + + // create a window to show the cursor for debugging purposes + static IDirectFBWindow * window = 0; + static IDirectFBSurface * windowSurface; + qDebug() << "window is" << window; + if (!window) { + qDebug() << "creating cursor preview window"; + DFBWindowDescription description; + description.width = 32; + description.height = 32; + description.flags = DFBWindowDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT); + qDebug() << m_layer->CreateWindow(m_layer, &description,&window); + qDebug() << window->RaiseToTop(window); + qDebug() << window->MoveTo(window, 500, 500); + qDebug() << window->GetSurface(window, &windowSurface); + } + + QImage *i = image->image(); + QRect imageRect = i->rect(); + QPixmap map = QPixmap::fromImage(*i); + + if (surface) + surface->Release(surface); + DFBSurfaceDescription surfaceDesc; + surfaceDesc.width = map.width(); + surfaceDesc.height = map.height(); + surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT); + + IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); + QDirectFbConvenience::dfbInterface()->CreateSurface(QDirectFbConvenience::dfbInterface(), &surfaceDesc, &surface); + + blitter = new QDirectFbBlitter(imageRect, windowSurface); // jeremy - should be surface + blitter->drawPixmap(imageRect, map, imageRect); + + + // + // blit to the window + // + //windowSurface->Blit(windowSurface, surface, NULL, 0, 0); + + DFBResult res = m_layer->SetCursorShape( m_layer, surface, cursor->hotSpot().x(), cursor->hotSpot().y()); + qDebug() << "setCursorShape result:"; + switch(res) { + case DFB_OK: qDebug() << "OK"; break; + case DFB_INVARG: qDebug() << "DFB_INVARG"; break; + case DFB_ACCESSDENIED: qDebug() << "DFB_ACCESSDENIED"; break; + default: qDebug() << "unknown error" << res; + } +} diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.h new file mode 100644 index 0000000..064a336 --- /dev/null +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.h @@ -0,0 +1,22 @@ +#ifndef QDIRECTFBCURSOR_H +#define QDIRECTFBCURSOR_H + +#include +#include +class QDirectFbGraphicsSystemScreen; +class QDirectFbBlitter; + +class QDirectFBCursor : public QGraphicsSystemCursor +{ +public: + QDirectFBCursor(QGraphicsSystemScreen *screem); + void changeCursor(QCursor * cursor, QWidget * widget); + +private: + IDirectFBDisplayLayer * m_layer; + IDirectFBSurface * surface; + QGraphicsSystemCursorImage * image; + QDirectFbBlitter *blitter; +}; + +#endif // QDIRECTFBCURSOR_H diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index 9e5e8bb..c767c7c 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -43,6 +43,7 @@ #include "qwindowsurface_minimaldfb.h" #include "qblitter_directfb.h" #include "qdirectfbconvenience.h" +#include "qdirectfbcursor.h" #include #include @@ -107,6 +108,9 @@ IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect, DFBWindowID id; window->GetID(window, &id); m_input.addWindow(id,tlw); + + cursor = new QDirectFBCursor(this); + return window; } diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h index 2f29ab4..f6ce011 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE +class QDirectFBCursor; + class QDirectFbGraphicsSystemScreen : public QGraphicsSystemScreen { public: @@ -73,6 +75,9 @@ public: IDirectFBDisplayLayer *m_layer; +private: + QDirectFBCursor * cursor; + }; class QDirectFbGraphicsSystem : public QGraphicsSystem -- cgit v0.12 From a8898716b1bf8f2b01596677bf7f913709cea3cf Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 4 Jan 2010 18:18:16 +0100 Subject: cursors starting to work. something on screen, but the images are wrong additionally, there may be access control issues. blind setting/resetting appears to be the only option --- src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp index 9c6cc59..38c6c20 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp @@ -62,7 +62,13 @@ void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) // //windowSurface->Blit(windowSurface, surface, NULL, 0, 0); - DFBResult res = m_layer->SetCursorShape( m_layer, surface, cursor->hotSpot().x(), cursor->hotSpot().y()); + int xSpot = cursor->hotSpot().x(); + int ySpot = cursor->hotSpot().y(); + // The SetCursorShape() call fails if the cooperative level is DLSCL_SHARED + // Question is, how can we determine the level, to reset is properly after? + m_layer->SetCooperativeLevel(m_layer, DLSCL_ADMINISTRATIVE); + DFBResult res = m_layer->SetCursorShape( m_layer, surface, xSpot, ySpot); + m_layer->SetCooperativeLevel(m_layer, DLSCL_SHARED); // This may be wrong. could be DFSCL_FULLSCREEN or DLSCL_ADMINISTRATIVE qDebug() << "setCursorShape result:"; switch(res) { case DFB_OK: qDebug() << "OK"; break; -- cgit v0.12 From 7d005e75c5000a568454c9f13112506ad2b1b1dc Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 5 Jan 2010 11:55:35 +0100 Subject: cleanup --- .../graphicssystems/minimaldfb/qdirectfbcursor.cpp | 45 ++++------------------ 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp index 38c6c20..24f64e6 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp @@ -14,29 +14,12 @@ QDirectFBCursor::QDirectFBCursor(QGraphicsSystemScreen * screen) : void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) { - qDebug() << "cursor change request:" << cursor << widget; - + Q_UNUSED(widget); if (cursor->shape() != Qt::BitmapCursor) { image->set(cursor->shape()); } else { qDebug() << "non-shape cursor: not implemented yet"; - return; // not attempting to deal with application supplied cursors yet - } - - // create a window to show the cursor for debugging purposes - static IDirectFBWindow * window = 0; - static IDirectFBSurface * windowSurface; - qDebug() << "window is" << window; - if (!window) { - qDebug() << "creating cursor preview window"; - DFBWindowDescription description; - description.width = 32; - description.height = 32; - description.flags = DFBWindowDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT); - qDebug() << m_layer->CreateWindow(m_layer, &description,&window); - qDebug() << window->RaiseToTop(window); - qDebug() << window->MoveTo(window, 500, 500); - qDebug() << window->GetSurface(window, &windowSurface); + return; } QImage *i = image->image(); @@ -53,27 +36,15 @@ void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); QDirectFbConvenience::dfbInterface()->CreateSurface(QDirectFbConvenience::dfbInterface(), &surfaceDesc, &surface); - blitter = new QDirectFbBlitter(imageRect, windowSurface); // jeremy - should be surface + blitter = new QDirectFbBlitter(imageRect, surface); blitter->drawPixmap(imageRect, map, imageRect); - - // - // blit to the window - // - //windowSurface->Blit(windowSurface, surface, NULL, 0, 0); - int xSpot = cursor->hotSpot().x(); int ySpot = cursor->hotSpot().y(); - // The SetCursorShape() call fails if the cooperative level is DLSCL_SHARED - // Question is, how can we determine the level, to reset is properly after? - m_layer->SetCooperativeLevel(m_layer, DLSCL_ADMINISTRATIVE); - DFBResult res = m_layer->SetCursorShape( m_layer, surface, xSpot, ySpot); - m_layer->SetCooperativeLevel(m_layer, DLSCL_SHARED); // This may be wrong. could be DFSCL_FULLSCREEN or DLSCL_ADMINISTRATIVE - qDebug() << "setCursorShape result:"; - switch(res) { - case DFB_OK: qDebug() << "OK"; break; - case DFB_INVARG: qDebug() << "DFB_INVARG"; break; - case DFB_ACCESSDENIED: qDebug() << "DFB_ACCESSDENIED"; break; - default: qDebug() << "unknown error" << res; + + if (m_layer->SetCooperativeLevel(m_layer, DLSCL_ADMINISTRATIVE) != DFB_OK) { + return; } + m_layer->SetCursorShape( m_layer, surface, xSpot, ySpot); + m_layer->SetCooperativeLevel(m_layer, DLSCL_SHARED); } -- cgit v0.12 From a50574975b408b1de58c9822a5b6c48a094e8013 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 5 Jan 2010 14:51:53 +0100 Subject: get cursor hotspot from the graphic --- src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp index 24f64e6..50c0622 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp @@ -39,8 +39,8 @@ void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) blitter = new QDirectFbBlitter(imageRect, surface); blitter->drawPixmap(imageRect, map, imageRect); - int xSpot = cursor->hotSpot().x(); - int ySpot = cursor->hotSpot().y(); + int xSpot = image->hotspot().x(); + int ySpot = image->hotspot().y(); if (m_layer->SetCooperativeLevel(m_layer, DLSCL_ADMINISTRATIVE) != DFB_OK) { return; -- cgit v0.12 From b5a1c9ba094c07c22be2d0e9896dbbafdfca5930 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 6 Jan 2010 12:31:57 +0100 Subject: removed an unnecessary call to QDirectFbConvenience::dfbInterface() --- src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp index 50c0622..074fc5a 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp @@ -33,7 +33,6 @@ void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) surfaceDesc.height = map.height(); surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT); - IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); QDirectFbConvenience::dfbInterface()->CreateSurface(QDirectFbConvenience::dfbInterface(), &surfaceDesc, &surface); blitter = new QDirectFbBlitter(imageRect, surface); -- cgit v0.12 From 6d7f46dd995c45c3ac9b65e35a8cf2e4d8f9225b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 5 Jan 2010 16:20:51 +0100 Subject: Cleaned up a bit in the cursor code --- .../graphicssystems/minimaldfb/qblitter_directfb.h | 4 ++++ .../minimaldfb/qdirectfbconvenience.cpp | 14 ++++++++++++++ .../graphicssystems/minimaldfb/qdirectfbconvenience.h | 4 ++++ .../graphicssystems/minimaldfb/qdirectfbcursor.cpp | 18 ++++-------------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h index 73eb7fb..8d24678 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h @@ -1,6 +1,8 @@ #ifndef QDIRECTFBBLITTER_H #define QDIRECTFBBLITTER_H +#include "qdirectfbconvenience.h" + #include #include @@ -20,6 +22,8 @@ protected: IDirectFBSurface *m_surface; QImage m_image; + + friend class QDirectFbConvenience; }; #endif // QDIRECTFBBLITTER_H diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp index 4e2085d..03fa18f 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp @@ -1,4 +1,7 @@ #include "qdirectfbconvenience.h" +#include "qblitter_directfb.h" + +#include IDirectFB *QDirectFbConvenience::dfb = 0; @@ -35,6 +38,17 @@ QImage::Format QDirectFbConvenience::imageFormatFromSurfaceFormat(const DFBSurfa } +IDirectFBSurface *QDirectFbConvenience::dfbSurfaceForPixmapData(QPixmapData *pixmapData) +{ + QBlittablePixmapData *blittablePmData = static_cast(pixmapData); + if (blittablePmData) { + QBlittable *blittable = blittablePmData->blittable(); + QDirectFbBlitter *dfbBlitter = static_cast(blittable); + return dfbBlitter->m_surface; + } + return 0; +} + Qt::MouseButton QDirectFbConvenience::mouseButton(DFBInputDeviceButtonIdentifier identifier) { switch (identifier){ diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h index 525aa22..81524dd 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -21,6 +22,9 @@ public: //This is set by the graphicssystem constructor static IDirectFB *dfbInterface() { return dfb; } + + static IDirectFBSurface *dfbSurfaceForPixmapData(QPixmapData *); + static Qt::MouseButton mouseButton(DFBInputDeviceButtonIdentifier identifier); static Qt::MouseButtons mouseButtons(DFBInputDeviceButtonMask mask); static Qt::KeyboardModifiers keyboardModifiers(DFBInputDeviceModifierMask mask); diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp index 074fc5a..e737575 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp @@ -3,12 +3,12 @@ #include "qgraphicssystem_minimaldfb.h" #include "qdirectfbconvenience.h" +#include + QDirectFBCursor::QDirectFBCursor(QGraphicsSystemScreen * screen) : QGraphicsSystemCursor(screen), surface(0) { - QDirectFbGraphicsSystemScreen * s; - s = static_cast(screen); - m_layer = s->m_layer; + QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY, &m_layer); image = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); } @@ -26,17 +26,7 @@ void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) QRect imageRect = i->rect(); QPixmap map = QPixmap::fromImage(*i); - if (surface) - surface->Release(surface); - DFBSurfaceDescription surfaceDesc; - surfaceDesc.width = map.width(); - surfaceDesc.height = map.height(); - surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT); - - QDirectFbConvenience::dfbInterface()->CreateSurface(QDirectFbConvenience::dfbInterface(), &surfaceDesc, &surface); - - blitter = new QDirectFbBlitter(imageRect, surface); - blitter->drawPixmap(imageRect, map, imageRect); + IDirectFBSurface *surface = QDirectFbConvenience::dfbSurfaceForPixmapData(map.pixmapData()); int xSpot = image->hotspot().x(); int ySpot = image->hotspot().y(); -- cgit v0.12 From 743c1e4800ff6f6a7d0b8c5bd5ac6be9d5027255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 6 Jan 2010 10:55:52 +0100 Subject: Cleanup properly in minimaldfb input --- .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 43 +++++++++++++++------- .../graphicssystems/minimaldfb/qdirectfbinput.h | 9 ++++- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index e470b9a..de50229 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -10,34 +10,46 @@ #include InputSocketWaiter::InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent) - : QThread(parent), eventBuffer(eventBuffer) - { - this->start(); - } + : QThread(parent), m_eventBuffer(eventBuffer),m_shouldStop(false) +{ + connect(qApp,SIGNAL(aboutToQuit()),SLOT(stop())); + this->start(); +} + +InputSocketWaiter::~InputSocketWaiter() +{ + m_shouldStop = true; + m_eventBuffer->WakeUp(m_eventBuffer); + m_mutex.lock(); +} void InputSocketWaiter::run() { + m_mutex.lock(); while (1) { - eventBuffer->WaitForEvent(eventBuffer); + m_eventBuffer->WaitForEvent(m_eventBuffer); + if (m_shouldStop) + break; emit newEvent(); } + m_mutex.unlock(); } QDirectFbInput::QDirectFbInput(QObject *parent) : QObject(parent) { - DFBResult ok = DirectFBCreate(&dfbInterface); - if (ok != DFB_OK) - DirectFBError("Failed to initialise QDirectFBInput", ok); + dfbInterface = QDirectFbConvenience::dfbInterface(); - ok = dfbInterface->CreateEventBuffer(dfbInterface,&eventBuffer); + DFBResult ok = dfbInterface->CreateEventBuffer(dfbInterface,&eventBuffer); if (ok != DFB_OK) DirectFBError("Failed to initialise eventbuffer", ok); dfbInterface->GetDisplayLayer(dfbInterface,DLID_PRIMARY, &dfbDisplayLayer); - InputSocketWaiter *inputHandler = new InputSocketWaiter(eventBuffer,this); - connect(inputHandler,SIGNAL(newEvent()),this,SLOT(handleEvents())); + m_inputHandler = new InputSocketWaiter(eventBuffer,this); + connect(m_inputHandler,SIGNAL(newEvent()),this,SLOT(handleEvents())); + + connect(qApp,SIGNAL(aboutToQuit()),SLOT(applicationEnd())); } void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) @@ -75,8 +87,7 @@ void QDirectFbInput::handleEvents() break; } - } else - qDebug() << "WHAT!"; + } hasEvent = eventBuffer->HasEvent(eventBuffer); } @@ -116,6 +127,12 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) QApplicationPrivate::handleMouseEvent(tlw,mouseEvent); } +void QDirectFbInput::applicationEnd() +{ + delete m_inputHandler; + m_inputHandler = 0; +} + void QDirectFbInput::handleWheelEvent(const DFBEvent &event) { QPoint p(event.window.cx, event.window.cy); diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h index e5bfba0..84439d9 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h @@ -2,6 +2,7 @@ #define QDIRECTFBINPUT_H #include +#include #include #include #include @@ -14,12 +15,15 @@ class InputSocketWaiter : public QThread Q_OBJECT public: InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent); + virtual ~InputSocketWaiter(); protected: void run(); signals: void newEvent(); private: - IDirectFBEventBuffer *eventBuffer; + IDirectFBEventBuffer *m_eventBuffer; + bool m_shouldStop; + QMutex m_mutex; }; class QDirectFbInput : public QObject @@ -32,6 +36,7 @@ public: public slots: void handleEvents(); + void applicationEnd(); private: @@ -46,6 +51,8 @@ private: inline QPoint globalPoint(const DFBEvent &event) const; + InputSocketWaiter *m_inputHandler; + }; #endif // QDIRECTFBINPUT_H -- cgit v0.12 From c489e061817d0880ac3f1492d8decf749a502e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 6 Jan 2010 14:41:53 +0100 Subject: fixed minimaldfb input when mouse events that did not get delivered and refactorede a bit stuff out. DirectFB handles the singelton pattern for the dfbInterface itself --- .../minimaldfb/qdirectfbconvenience.cpp | 22 +++++++++++++++++++++- .../minimaldfb/qdirectfbconvenience.h | 5 ++--- .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 7 +++++++ .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 16 +++------------- .../minimaldfb/qgraphicssystem_minimaldfb.h | 2 +- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp index 03fa18f..25d6258 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp @@ -3,7 +3,27 @@ #include -IDirectFB *QDirectFbConvenience::dfb = 0; +IDirectFB *QDirectFbConvenience::dfbInterface() +{ + IDirectFB *dfb; + DFBResult result = DirectFBCreate(&dfb); + if (result != DFB_OK) { + DirectFBError("QDirectFBConvenience: error creating DirectFB interface",result); + return 0; + } + return dfb; +} + +IDirectFBDisplayLayer *QDirectFbConvenience::dfbDisplayLayer(int display) +{ + IDirectFBDisplayLayer *layer; + DFBResult result = QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),display,&layer); + if (result != DFB_OK) { + DirectFBError("QDirectFbConvenience: " + "Unable to get primary display layer!", result); + } + return layer; +} QImage::Format QDirectFbConvenience::imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps) { diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h index 81524dd..c086828 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h @@ -21,7 +21,8 @@ public: static QImage::Format imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps); //This is set by the graphicssystem constructor - static IDirectFB *dfbInterface() { return dfb; } + static IDirectFB *dfbInterface(); + static IDirectFBDisplayLayer *dfbDisplayLayer(int display = DLID_PRIMARY); static IDirectFBSurface *dfbSurfaceForPixmapData(QPixmapData *); @@ -33,8 +34,6 @@ public: static QDirectFbKeyMap *keyMap(); private: - static void setDfbInterface(IDirectFB *dfbInterface) {dfb = dfbInterface;} - static IDirectFB *dfb; static QDirectFbKeyMap *dfbKeymap; friend class QDirectFbGraphicsSystem; }; diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index de50229..00c2310 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -102,6 +102,9 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); QWidget *tlw = tlwMap.value(event.window.window_id); + IDirectFBWindow *window; + QDirectFbConvenience::dfbDisplayLayer()->GetWindow(layer,event.window.window_id,&window); + if (event.window.type == DWET_BUTTONDOWN) { static long prevTime = 0; static QWidget *prevWindow; @@ -120,6 +123,10 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) prevWindow = tlw; prevX = event.window.cx; prevY = event.window.cy; + + window->GrabPointer(window); + } else if (event.window.type == DWET_BUTTONUP) { + window->UngrabPointer(window); } //DFB doesn't give keyboardmodifiers on mouseevents diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index c767c7c..2d471e4 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -54,14 +54,10 @@ QT_BEGIN_NAMESPACE -QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int display) +QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(int display) :QGraphicsSystemScreen() , m_input(this) { - DFBResult result = dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &m_layer); - if (result != DFB_OK) { - DirectFBError("QDirectFbGraphicsSystemScreen " - "Unable to get primary display layer!", result); - } + IDirectFBDisplayLayer *m_layer = QDirectFbConvenience::dfbDisplayLayer(display); m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); DFBDisplayLayerConfig config; @@ -134,14 +130,8 @@ QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() } delete[] argv; - result = DirectFBCreate(&dfb); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreen: error creating DirectFB interface", - result); - } - QDirectFbConvenience::setDfbInterface(dfb); - mPrimaryScreen = new QDirectFbGraphicsSystemScreen(dfb,0); + mPrimaryScreen = new QDirectFbGraphicsSystemScreen(0); mScreens.append(mPrimaryScreen); } diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h index f6ce011..892bc58 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h @@ -55,7 +55,7 @@ class QDirectFBCursor; class QDirectFbGraphicsSystemScreen : public QGraphicsSystemScreen { public: - QDirectFbGraphicsSystemScreen(IDirectFB *dfb, int display); + QDirectFbGraphicsSystemScreen(int display); ~QDirectFbGraphicsSystemScreen(); QRect geometry() const { return m_geometry; } -- cgit v0.12 From 86bc22465a43496950bc0bf8901673ccd6c65fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 6 Jan 2010 15:16:13 +0100 Subject: Added DirectFb scrolling to minimaldfb --- .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 3 ++- .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 2 +- .../minimaldfb/qwindowsurface_minimaldfb.cpp | 22 +++++++++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 00c2310..b8f6dd9 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -102,8 +102,9 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); QWidget *tlw = tlwMap.value(event.window.window_id); + IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); IDirectFBWindow *window; - QDirectFbConvenience::dfbDisplayLayer()->GetWindow(layer,event.window.window_id,&window); + layer->GetWindow(layer,event.window.window_id,&window); if (event.window.type == DWET_BUTTONDOWN) { static long prevTime = 0; diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index 2d471e4..8bba616 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(int display) :QGraphicsSystemScreen() , m_input(this) { - IDirectFBDisplayLayer *m_layer = QDirectFbConvenience::dfbDisplayLayer(display); + m_layer = QDirectFbConvenience::dfbDisplayLayer(display); m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); DFBDisplayLayerConfig config; diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index f7229e9..93ea44f 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -107,9 +107,29 @@ void QDirectFbWindowSurface::setGeometry(const QRect &rect) } +static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) +{ + const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; + surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy); + const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy }; + surface->Flip(surface, ®ion, DFBSurfaceFlipFlags(DSFLIP_BLIT)); +} + bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) { - return QWindowSurface::scroll(area, dx, dy); + if (!m_dfbSurface || area.isEmpty()) + return false; + m_dfbSurface->SetBlittingFlags(m_dfbSurface, DSBLIT_NOFX); + if (area.rectCount() == 1) { + scrollSurface(m_dfbSurface, area.boundingRect(), dx, dy); + } else { + const QVector rects = area.rects(); + const int n = rects.size(); + for (int i=0; i Date: Wed, 6 Jan 2010 16:05:42 +0100 Subject: Fix wheel event reporting with a null top level widget reported --- src/gui/kernel/qapplication_lite.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index a42bfd7..57f6d72 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -621,7 +621,7 @@ void QApplicationPrivate::handleWheelEvent(QWidget *tlw, QWheelEvent &ev) // QPoint localPoint = ev.pos(); QPoint globalPoint = ev.globalPos(); // bool trustLocalPoint = !!tlw; //is there something the local point can be local to? - QWidget *mouseWidget = tlw; + QWidget *mouseWidget; qt_last_x = globalPoint.x(); qt_last_y = globalPoint.y(); @@ -636,6 +636,8 @@ void QApplicationPrivate::handleWheelEvent(QWidget *tlw, QWheelEvent &ev) if (!mouseWindow) return; + mouseWidget = mouseWindow; + if (app_do_modal && !qt_try_modal(mouseWindow, &ev) ) { qDebug() << "modal blocked wheel event" << mouseWindow; return; -- cgit v0.12 From 769ec23cc32c43ce9d519b39ac8dad2a04b78403 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 6 Jan 2010 16:10:44 +0100 Subject: VNC mouse wheen support --- src/plugins/graphicssystems/vnc/qvncserver.cpp | 50 ++++++++++++++++++++------ src/plugins/graphicssystems/vnc/qvncserver.h | 8 ++++- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp index cbf6054..9576d10 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -316,13 +316,23 @@ bool QRfbPointerEvent::read(QTcpSocket *s) char buttonMask; s->read(&buttonMask, 1); + buttons = Qt::NoButton; + wheelDirection = WheelNone; if (buttonMask & 1) buttons |= Qt::LeftButton; if (buttonMask & 2) buttons |= Qt::MidButton; if (buttonMask & 4) buttons |= Qt::RightButton; + if (buttonMask & 8) + wheelDirection = WheelUp; + if (buttonMask & 16) + wheelDirection = WheelDown; + if (buttonMask & 32) + wheelDirection = WheelLeft; + if (buttonMask & 64) + wheelDirection = WheelRight; quint16 tmp; s->read((char *)&tmp, 2); @@ -828,6 +838,7 @@ void QVNCServer::sendInputEvents() EventPair pair; QMouseEvent *me; QKeyEvent *ke; + QWheelEvent *we; while(!eventList.isEmpty()) { pair = eventList.takeFirst(); @@ -842,6 +853,11 @@ void QVNCServer::sendInputEvents() QApplicationPrivate::handleKeyEvent(0, ke); delete ke; break; + case WheelEvent: + we = static_cast(pair.second); + QApplicationPrivate::handleWheelEvent(0, *we); + delete we; + break; } } } @@ -854,21 +870,33 @@ void QVNCServer::pointerEvent() // QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons); - //qDebug() << "pointerEvent" << ev.x << ev.y << hex << ev.buttons; - - QEvent::Type type = QEvent::MouseMove; - Qt::MouseButton button = Qt::NoButton; - bool isPress; - if (buttonChange(buttons, ev.buttons, &button, &isPress)) - type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - QMouseEvent * me = new QMouseEvent(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); EventPair pair; - pair.first = MouseEvent; - pair.second = me; + //qDebug() << "pointerEvent" << ev.x << ev.y << hex << ev.buttons; + if (ev.wheelDirection == ev.WheelNone) { + QEvent::Type type = QEvent::MouseMove; + Qt::MouseButton button = Qt::NoButton; + bool isPress; + if (buttonChange(buttons, ev.buttons, &button, &isPress)) + type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; + QMouseEvent * me = new QMouseEvent(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); + pair.first = MouseEvent; + pair.second = me; + buttons = ev.buttons; + } else { + // No buttons or motion reported at the same time as wheel events + Qt::Orientation orientation; + if (ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelRight) + orientation = Qt::Horizontal; + else + orientation = Qt::Vertical; + int delta = 120 * ((ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelUp) ? 1 : -1); + QWheelEvent *we = new QWheelEvent(QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), delta, buttons, keymod, orientation); + pair.first = WheelEvent; + pair.second = we; + } eventList.append(pair); if (!eventTimer.isActive()) eventTimer.start(); - buttons = ev.buttons; handleMsg = false; } } diff --git a/src/plugins/graphicssystems/vnc/qvncserver.h b/src/plugins/graphicssystems/vnc/qvncserver.h index be84c3c..7532cb4 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.h +++ b/src/plugins/graphicssystems/vnc/qvncserver.h @@ -228,6 +228,12 @@ public: bool read(QTcpSocket *s); Qt::MouseButtons buttons; + enum { WheelNone, + WheelUp, + WheelDown, + WheelLeft, + WheelRight + } wheelDirection; quint16 x; quint16 y; }; @@ -521,7 +527,7 @@ private: QRfbEncoder *encoder; QVNCCursor *cursor; - enum EventType { MouseEvent, KeyboardEvent }; + enum EventType { MouseEvent, KeyboardEvent, WheelEvent }; QTimer eventTimer; typedef QPair EventPair; QList eventList; -- cgit v0.12 From e0ec5613e73d16ad91d5c267393b08f9193b4f3c Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 6 Jan 2010 18:25:34 +0100 Subject: LinuxInputMouse wheel support --- src/plugins/generic/linuxinput/qlinuxinput.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 48084d0..308af6b 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -134,6 +134,16 @@ void QLinuxInputMouseHandler::readMouseData() m_x += data->value; } else if (data->code == REL_Y) { m_y += data->value; + } else if (data->code == ABS_WHEEL) { // vertical scroll + // data->value: 1 == up, -1 == down + int delta = 120 * data->value; + QWheelEvent we(QPoint(m_x, m_y), QPoint(m_x, m_y), delta, m_buttons, Qt::NoModifier, Qt::Vertical); + QApplicationPrivate::handleWheelEvent(0, we); + } else if (data->code == ABS_THROTTLE) { // horizontal scroll + // data->value: 1 == right, -1 == left + int delta = 120 * -data->value; + QWheelEvent we(QPoint(m_x, m_y), QPoint(m_x, m_y), delta, m_buttons, Qt::NoModifier, Qt::Horizontal); + QApplicationPrivate::handleWheelEvent(0, we); } else { unknown = true; } -- cgit v0.12 From 18c551144eeeff6a2e124fc427b2a6c973516c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 7 Jan 2010 10:07:46 +0100 Subject: Added enter/leave event in minimaldfb --- .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 18 ++++++++++++++++++ .../graphicssystems/minimaldfb/qdirectfbinput.h | 1 + .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 6 ++---- .../minimaldfb/qwindowsurface_minimaldfb.cpp | 8 +++++++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index b8f6dd9..e704aa7 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -83,6 +83,9 @@ void QDirectFbInput::handleEvents() case DWET_KEYUP: handleKeyEvents(event); break; + case DWET_ENTER: + case DWET_LEAVE: + handleEnterLeaveEvents(event); default: break; } @@ -165,6 +168,21 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event) QApplicationPrivate::handleKeyEvent(tlw,&keyEvent); } +void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) +{ + QWidget *tlw = tlwMap.value(event.window.window_id); + switch (event.window.type) { + case DWET_ENTER: + QApplicationPrivate::handleEnterEvent(tlw); + break; + case DWET_LEAVE: + QApplicationPrivate::handleLeaveEvent(tlw); + break; + default: + break; + } +} + inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const { IDirectFBWindow *window; diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h index 84439d9..8f90019 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h @@ -43,6 +43,7 @@ private: void handleMouseEvents(const DFBEvent &event); void handleWheelEvent(const DFBEvent &event); void handleKeyEvents(const DFBEvent &event); + void handleEnterLeaveEvents(const DFBEvent &event); IDirectFB *dfbInterface; IDirectFBDisplayLayer *dfbDisplayLayer; IDirectFBEventBuffer *eventBuffer; diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index 8bba616..aef7a3d 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -64,6 +64,7 @@ QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(int display) m_layer->GetConfiguration(m_layer, &config); m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps); + qDebug() << "GraphcisSystemScreen has format: " << m_format; m_geometry = QRect(0,0,config.width,config.height); const int dpi = 72; const qreal inch = 25.4; @@ -113,9 +114,6 @@ IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect, QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() { - IDirectFB *dfb; - DFBResult result = DFB_OK; - const QStringList args = QCoreApplication::arguments(); int argc = args.size(); char **argv = new char*[argc]; @@ -123,7 +121,7 @@ QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() for (int i = 0; i < argc; ++i) argv[i] = qstrdup(args.at(i).toLocal8Bit().constData()); - result = DirectFBInit(&argc, &argv); + DFBResult result = DirectFBInit(&argc, &argv); if (result != DFB_OK) { DirectFBError("QDirectFBScreen: error initializing DirectFB", result); diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 93ea44f..c8e4f9d 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -58,7 +58,13 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QDirectFbGraphicsSystemScreen *sc window->setWindowSurface(this); m_dfbWindow = m_screen->createWindow(window->rect(),window); m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); - qDebug () << "initial surface: " << m_dfbSurface; + + DFBSurfaceCapabilities caps; + m_dfbSurface->GetCapabilities(m_dfbSurface, &caps); + DFBSurfacePixelFormat format; + m_dfbSurface->GetPixelFormat(m_dfbSurface, &format); + qDebug() << "WindowSurface format " << QDirectFbConvenience::imageFormatFromSurfaceFormat(format,caps); + QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); -- cgit v0.12 From 9096336c767670b4f68d507a5116da433ecb40b0 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 8 Jan 2010 14:46:49 +0100 Subject: Alpha channel fixes for QBlittablePixmapData MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jørgen Lind --- src/gui/image/qpixmap_blitter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 3613211..6ab97c1 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -75,10 +75,10 @@ int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const void QBlittablePixmapData::fill(const QColor &color) { - if (blittable()->capabilities() & QBlittable::SolidRectCapability) - blittable()->fillRect(QRectF(0,0,w,h),color); + if (color.alpha() == 255 && blittable()->capabilities() & QBlittable::SolidRectCapability) + blittable()->fillRect(QRectF(0,0,w,h),color); else - blittable()->lock()->fill(color.rgb()); + blittable()->lock()->fill(color.rgba()); } QImage *QBlittablePixmapData::buffer() @@ -102,6 +102,7 @@ void QBlittablePixmapData::fromImage(const QImage &image, resize(image.width(),image.height()); QImage *thisImg = blittable()->lock(); QPainter p(thisImg); + p.setCompositionMode(QPainter::CompositionMode_Source); p.drawImage(0,0,image,flags); } -- cgit v0.12 From a98fd80bf018e21fb1d0216bccf39de57da4950c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 8 Jan 2010 15:05:49 +0100 Subject: Make minimaldfb input more efficient Reviewed-by: Andy Nichols --- src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp | 15 +++++++++++---- src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h | 5 ++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index e704aa7..1926367 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -12,7 +12,6 @@ InputSocketWaiter::InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent) : QThread(parent), m_eventBuffer(eventBuffer),m_shouldStop(false) { - connect(qApp,SIGNAL(aboutToQuit()),SLOT(stop())); this->start(); } @@ -20,19 +19,26 @@ InputSocketWaiter::~InputSocketWaiter() { m_shouldStop = true; m_eventBuffer->WakeUp(m_eventBuffer); - m_mutex.lock(); + m_cleanupMutex.lock(); +} + +void InputSocketWaiter::continueWaitingForEvents() +{ + m_finishedProcessingEvents.wakeAll(); } void InputSocketWaiter::run() { - m_mutex.lock(); + m_cleanupMutex.lock(); while (1) { m_eventBuffer->WaitForEvent(m_eventBuffer); if (m_shouldStop) break; emit newEvent(); + QMutex waitForProcessingMutex; + m_finishedProcessingEvents.wait(&waitForProcessingMutex); } - m_mutex.unlock(); + m_cleanupMutex.unlock(); } QDirectFbInput::QDirectFbInput(QObject *parent) @@ -94,6 +100,7 @@ void QDirectFbInput::handleEvents() hasEvent = eventBuffer->HasEvent(eventBuffer); } + m_inputHandler->continueWaitingForEvents(); } void QDirectFbInput::handleMouseEvents(const DFBEvent &event) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h index 8f90019..74ccee2 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -16,6 +17,7 @@ class InputSocketWaiter : public QThread public: InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent); virtual ~InputSocketWaiter(); + void continueWaitingForEvents(); protected: void run(); signals: @@ -23,7 +25,8 @@ signals: private: IDirectFBEventBuffer *m_eventBuffer; bool m_shouldStop; - QMutex m_mutex; + QMutex m_cleanupMutex; + QWaitCondition m_finishedProcessingEvents; }; class QDirectFbInput : public QObject -- cgit v0.12 From 5dfcb52fb853ae7f28acc83e2be99f999e1bf31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 8 Jan 2010 15:13:54 +0100 Subject: Make minimaldfb input more efficient copy paste error :( --- src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 1926367..17fdd10 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -36,6 +36,7 @@ void InputSocketWaiter::run() break; emit newEvent(); QMutex waitForProcessingMutex; + waitForProcessingMutex.lock(); m_finishedProcessingEvents.wait(&waitForProcessingMutex); } m_cleanupMutex.unlock(); -- cgit v0.12 From 721653914597ccdec7bbf94b58e6b6879dd53755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 11 Jan 2010 16:14:33 +0100 Subject: Added colordepth convenience function in minimaldfb and added pixelformat for default dfbblitters --- src/gui/image/qpixmap_blitter.cpp | 4 +++- src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp | 10 +++++++++- .../graphicssystems/minimaldfb/qdirectfbconvenience.cpp | 5 +++++ src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h | 2 ++ .../graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp | 2 ++ .../graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp | 2 ++ 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 6ab97c1..b2bb674 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -29,13 +29,15 @@ QBlittable *QBlittablePixmapData::blittable() const void QBlittablePixmapData::setBlittable(QBlittable *blittable) { - delete m_blittable; resize(blittable->rect().width(),blittable->rect().height()); m_blittable = blittable; } void QBlittablePixmapData::resize(int width, int height) { + + delete m_blittable; + m_blittable = 0; delete m_engine; m_engine = 0; d = QApplicationPrivate::graphicsSystem()->screens().at(0)->depth(); diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp index 06622a1..23e3be6 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp @@ -18,13 +18,16 @@ QDirectFbBlitter::QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface) m_surface = surface; } else { DFBSurfaceDescription surfaceDesc; + memset(&surfaceDesc,0,sizeof(DFBSurfaceDescription)); surfaceDesc.width = rect.width(); surfaceDesc.height = rect.height(); surfaceDesc.caps = DSCAPS_PREMULTIPLIED; - surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS); + surfaceDesc.pixelformat = DSPF_ARGB; + surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT); IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); + m_surface->Clear(m_surface,0,0,0,0); } } @@ -36,6 +39,10 @@ QDirectFbBlitter::~QDirectFbBlitter() void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color) { m_surface->SetColor(m_surface, color.red(), color.green(), color.blue(), color.alpha()); +// When the blitter api supports non opaque blits, also remember to change +// qpixmap_blitter.cpp::fill +// DFBSurfaceDrawingFlags drawingFlags = color.alpha() ? DSDRAW_BLEND : DSDRAW_NOFX; +// m_surface->SetDrawingFlags(m_surface, drawingFlags); m_surface->SetDrawingFlags(m_surface, DSDRAW_NOFX); m_surface->FillRectangle(m_surface, rect.x(), rect.y(), rect.width(), rect.height()); @@ -49,6 +56,7 @@ void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, con m_surface->SetColor(m_surface, 0xff, 0xff, 0xff, 255); QPixmapData *data = pixmap.pixmapData(); + Q_ASSERT(data->width() && data->height()); Q_ASSERT(data->classId() == QPixmapData::BlitterClass); QBlittablePixmapData *blitPm = static_cast(data); QDirectFbBlitter *dfbBlitter = static_cast(blitPm->blittable()); diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp index 25d6258..57d03fc 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp @@ -58,6 +58,11 @@ QImage::Format QDirectFbConvenience::imageFormatFromSurfaceFormat(const DFBSurfa } +int QDirectFbConvenience::colorDepthForSurface(const DFBSurfacePixelFormat format) +{ + return ((0x1f << 7) & format) >> 7; +} + IDirectFBSurface *QDirectFbConvenience::dfbSurfaceForPixmapData(QPixmapData *pixmapData) { QBlittablePixmapData *blittablePmData = static_cast(pixmapData); diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h index c086828..0b1a24f 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h @@ -19,6 +19,8 @@ class QDirectFbConvenience { public: static QImage::Format imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps); + static bool pixelFomatHasAlpha(const DFBSurfacePixelFormat format) { return (1 << 16) & format; } + static int colorDepthForSurface(const DFBSurfacePixelFormat format); //This is set by the graphicssystem constructor static IDirectFB *dfbInterface(); diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index aef7a3d..f1f2215 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -64,6 +64,8 @@ QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(int display) m_layer->GetConfiguration(m_layer, &config); m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps); + qDebug() << QDirectFbConvenience::pixelFomatHasAlpha(config.pixelformat); + qDebug() << QDirectFbConvenience::colorDepthForSurface(config.pixelformat); qDebug() << "GraphcisSystemScreen has format: " << m_format; m_geometry = QRect(0,0,config.width,config.height); const int dpi = 72; diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index c8e4f9d..5f03b78 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -63,6 +63,8 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QDirectFbGraphicsSystemScreen *sc m_dfbSurface->GetCapabilities(m_dfbSurface, &caps); DFBSurfacePixelFormat format; m_dfbSurface->GetPixelFormat(m_dfbSurface, &format); + qDebug() << QDirectFbConvenience::pixelFomatHasAlpha(format); + qDebug() << QDirectFbConvenience::colorDepthForSurface(format); qDebug() << "WindowSurface format " << QDirectFbConvenience::imageFormatFromSurfaceFormat(format,caps); -- cgit v0.12 From 4bbbbbcd60d621af0a80926d29a87f061a50ff85 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 11 Jan 2010 16:36:57 +0100 Subject: application supplied pixmap cursors for minimaldfb --- .../graphicssystems/minimaldfb/qdirectfbcursor.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp index e737575..229a875 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp @@ -15,22 +15,25 @@ QDirectFBCursor::QDirectFBCursor(QGraphicsSystemScreen * screen) : void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) { Q_UNUSED(widget); + int xSpot; + int ySpot; + QPixmap map; + if (cursor->shape() != Qt::BitmapCursor) { image->set(cursor->shape()); + xSpot = image->hotspot().x(); + ySpot = image->hotspot().y(); + QImage *i = image->image(); + map = QPixmap::fromImage(*i); } else { - qDebug() << "non-shape cursor: not implemented yet"; - return; + QPoint point = cursor->hotSpot(); + xSpot = point.x(); + ySpot = point.y(); + map = cursor->pixmap(); } - QImage *i = image->image(); - QRect imageRect = i->rect(); - QPixmap map = QPixmap::fromImage(*i); - IDirectFBSurface *surface = QDirectFbConvenience::dfbSurfaceForPixmapData(map.pixmapData()); - int xSpot = image->hotspot().x(); - int ySpot = image->hotspot().y(); - if (m_layer->SetCooperativeLevel(m_layer, DLSCL_ADMINISTRATIVE) != DFB_OK) { return; } -- cgit v0.12 From 645f29c727f33cc9f8b00b8efcb658a050ac6a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 12 Jan 2010 14:38:18 +0100 Subject: Fix QBlittablePixmapData::fromImage --- src/gui/image/qpixmap_blitter.cpp | 25 ++++++++++++++++++---- .../minimaldfb/qblitter_directfb.cpp | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index b2bb674..5ce7fc1 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -102,10 +102,27 @@ void QBlittablePixmapData::fromImage(const QImage &image, Qt::ImageConversionFlags flags) { resize(image.width(),image.height()); - QImage *thisImg = blittable()->lock(); - QPainter p(thisImg); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.drawImage(0,0,image,flags); + QImage *thisImg = buffer(); + + QImage correctFormatPic = image; + if (correctFormatPic.format() != thisImg->format()) + correctFormatPic = correctFormatPic.convertToFormat(thisImg->format(), flags); + + //jl: This does not ALWAYS work as expected :( +// QPainter p(thisImg); +// p.setCompositionMode(QPainter::CompositionMode_Source); +// p.drawImage(0,0,image,flags); + + //So just copy strides by hand + uchar *mem = thisImg->bits(); + const uchar *bits = correctFormatPic.bits(); + int bytesCopied = 0; + while (bytesCopied < correctFormatPic.byteCount()) { + memcpy(mem,bits,correctFormatPic.bytesPerLine()); + mem += thisImg->bytesPerLine(); + bits += correctFormatPic.bytesPerLine(); + bytesCopied+=correctFormatPic.bytesPerLine(); + } } QPaintEngine *QBlittablePixmapData::paintEngine() const diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp index 23e3be6..3772131 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp @@ -23,7 +23,7 @@ QDirectFbBlitter::QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface) surfaceDesc.height = rect.height(); surfaceDesc.caps = DSCAPS_PREMULTIPLIED; surfaceDesc.pixelformat = DSPF_ARGB; - surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT); + surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT); IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); -- cgit v0.12 From d01179752907fa441ca1ae6f6e7e7b351e2a60f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 14 Jan 2010 13:48:00 +0100 Subject: minimaldfb: Set the correct SetDstBlendFunction --- src/gui/painting/qpaintengine_blitter.cpp | 4 ++-- .../graphicssystems/minimaldfb/qblitter_directfb.cpp | 14 ++++++++------ .../minimaldfb/qwindowsurface_minimaldfb.cpp | 2 -- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 7336dcc..a954294 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -302,7 +302,7 @@ void QBlitterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) void QBlitterPaintEngine::fillRect(const QRectF &rect, const QColor &color) { Q_D(QBlitterPaintEngine); - if (d->capabillities->canBlitterFillRect() && color.alpha() == 255) { + if (d->capabillities->canBlitterFillRect() && color.alpha() == 0xff) { d->fillRect(rect, color); } else { d->lock(); @@ -319,7 +319,7 @@ void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) return; Q_D(QBlitterPaintEngine); if (qbrush_style(brush) == Qt::SolidPattern - && qbrush_color(brush).alpha() == 255 + && qbrush_color(brush).alpha() == 0xff && d->capabillities->canBlitterFillRect()) { d->fillRect(rect, qbrush_color(brush)); diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp index 3772131..c2e4b4f 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp @@ -50,11 +50,6 @@ void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color) void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &srcRect) { - quint32 blittingFlags = pixmap.hasAlphaChannel() ? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; - - m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags)); - m_surface->SetColor(m_surface, 0xff, 0xff, 0xff, 255); - QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->width() && data->height()); Q_ASSERT(data->classId() == QPixmapData::BlitterClass); @@ -62,6 +57,14 @@ void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, con QDirectFbBlitter *dfbBlitter = static_cast(blitPm->blittable()); IDirectFBSurface *s = dfbBlitter->m_surface; + + quint32 blittingFlags = pixmap.hasAlpha()? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; + + s->SetBlittingFlags(s, DFBSurfaceBlittingFlags(blittingFlags)); + m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags)); + m_surface->SetPorterDuff(m_surface,DSPD_SRC_OVER); + m_surface->SetDstBlendFunction(m_surface,DSBF_INVSRCALPHA); + const DFBRectangle sRect = { srcRect.x(), srcRect.y(), rect.width(), rect.height() }; DFBResult result; @@ -73,7 +76,6 @@ void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, con } if (result != DFB_OK) DirectFBError("QDirectFBBlitter::drawPixmap()", result); - } QImage *QDirectFbBlitter::doLock() diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 5f03b78..7f3e165 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -47,8 +47,6 @@ #include -#include - QT_BEGIN_NAMESPACE QDirectFbWindowSurface::QDirectFbWindowSurface(QDirectFbGraphicsSystemScreen *screen, QWidget *window) -- cgit v0.12 From 68153ffc1ee0dcd779a4f809b614b05550a2acf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 18 Jan 2010 10:45:56 +0100 Subject: Fixed QBlittablePixmapData::fill and a clipping error in the paintengine. Should prob. refactor engine state and clip calls. --- src/gui/image/qpixmap_blitter.cpp | 7 ++++--- src/gui/painting/qpaintengine_blitter.cpp | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 5ce7fc1..175c234 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -77,9 +77,10 @@ int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const void QBlittablePixmapData::fill(const QColor &color) { - if (color.alpha() == 255 && blittable()->capabilities() & QBlittable::SolidRectCapability) - blittable()->fillRect(QRectF(0,0,w,h),color); - else + if (color.alpha() == 255 && blittable()->capabilities() & QBlittable::SolidRectCapability) { + blittable()->unlock(); + blittable()->fillRect(QRectF(0,0,w,h),color); + }else blittable()->lock()->fill(color.rgba()); } diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index a954294..43206c8 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -174,12 +174,11 @@ public: } void fillRect(const QRectF &rect, const QColor &color) { -// lock(); QRectF targetRect = rect; if (hasXForm) { targetRect = state->matrix.mapRect(rect); } - QClipData *clipData = state->clip; + const QClipData *clipData = raster->d_func()->clip();; if (clipData) { if (clipData->hasRectClip) { unlock(); -- cgit v0.12 From 900e0b47c09ec9d4d12d7de077d01b45baa7497f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 19 Jan 2010 11:32:15 +0100 Subject: Make the blitterpaintengine not create a path but call the raster implementation instead (this is a workaround for the anti-pattern that the blitterpaintengine is) --- src/gui/painting/qpaintengine_blitter.cpp | 6 ++++++ src/gui/painting/qpaintengine_blitter_p.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 43206c8..0f6b5cf 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -587,6 +587,12 @@ void QBlitterPaintEngine::drawTextItem(const QPointF &pos, const QTextItem &ti) #endif } +void QBlitterPaintEngine::drawEllipse(const QRectF &r) +{ + Q_D(QBlitterPaintEngine); + d->lock(); + d->raster->drawEllipse(r); +} void QBlitterPaintEngine::setState(QPainterState *s) { diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index 7f67997..cebaf21 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -85,6 +85,8 @@ public: virtual void drawTextItem(const QPointF &pos, const QTextItem &ti); + virtual void drawEllipse(const QRectF &r); + virtual void setState(QPainterState *s); inline QPainterState *state() { return static_cast(QPaintEngine::state); } -- cgit v0.12 From 49e5181ea9da13439200720f51c8abbe4d8141c1 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 19 Jan 2010 16:28:22 +0100 Subject: Implement support for the MIT SHM extension (turned off by default). This should be significantly faster, since we are not sending the entire backing store over the wire for every paint event. It is turned off by default for now because we don't synchronize paint events. --- .../testlite/qwindowsurface_testlite.cpp | 7 +- src/plugins/graphicssystems/testlite/testlite.pro | 2 +- src/plugins/graphicssystems/testlite/x11util.cpp | 110 +++++++++++++++++++-- src/plugins/graphicssystems/testlite/x11util.h | 11 ++- 4 files changed, 118 insertions(+), 12 deletions(-) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index fde54a1..c0a0cc9 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -75,7 +75,7 @@ QTestLiteWindowSurface::~QTestLiteWindowSurface() QPaintDevice *QTestLiteWindowSurface::paintDevice() { - return &xw->img; + return xw->image(); } void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) @@ -92,13 +92,12 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const void QTestLiteWindowSurface::geometryChanged(const QRect &rect) { + bool resize = rect.size() != geometry().size(); QWindowSurface::setGeometry(rect); - if (xw->img.size() != rect.size()) { - xw->img = QImage(rect.size(), mScreen->format()); + if (resize) { window()->update(); //### this is the wrong place for this... } - } diff --git a/src/plugins/graphicssystems/testlite/testlite.pro b/src/plugins/graphicssystems/testlite/testlite.pro index af8a437..d483f45 100644 --- a/src/plugins/graphicssystems/testlite/testlite.pro +++ b/src/plugins/graphicssystems/testlite/testlite.pro @@ -10,7 +10,7 @@ HEADERS = qgraphicssystem_testlite.h qwindowsurface_testlite.h HEADERS += x11util.h SOURCES += x11util.cpp -LIBS += -lX11 +LIBS += -lX11 -lXext target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index cb08230..f3b6dc2 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -57,6 +57,11 @@ #include +# include +# include +# include + + #include #include #include @@ -68,6 +73,10 @@ //#define MYX11_DEBUG +//MIT SHM disabled by default, since we haven't implemented ShmCompletion synchronization yet + +#define DONT_USE_MIT_SHM + static int (*original_x_errhandler)(Display *dpy, XErrorEvent *); static bool seen_badwindow; @@ -307,12 +316,15 @@ MyDisplay::MyDisplay() exit(1); } +#ifndef DONT_USE_MIT_SHM + Status MIT_SHM_extension_supported = XShmQueryExtension (display); + Q_ASSERT(MIT_SHM_extension_supported == True); +#endif original_x_errhandler = XSetErrorHandler(qt_x_errhandler); if (qgetenv("DO_X_SYNCHRONIZE").toInt()) XSynchronize(display, true); - screen = DefaultScreen(display); width = DisplayWidth(display, screen); height = DisplayHeight(display, screen); @@ -367,6 +379,16 @@ void MyDisplay::eventDispatcher() } } +struct MyShmImageInfo { + MyShmImageInfo(Display *xdisplay) : image(0), display(xdisplay) {} + ~MyShmImageInfo() { destroy(); } + + void destroy(); + + XShmSegmentInfo shminfo; + XImage *image; + Display *display; +}; MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) { @@ -407,6 +429,9 @@ MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) setWindowTitle(QLatin1String("Qt Lighthouse")); currentCursor = -1; + + image_info = 0; + } @@ -432,6 +457,8 @@ MyWindow::~MyWindow() XDestroyWindow(xd->display, window); xd->windowList.removeAll(this); + + delete image_info; } GC MyWindow::createGC() @@ -453,9 +480,14 @@ void MyWindow::closeEvent() void MyWindow::paintEvent() { Visual *visual = DefaultVisual(xd->display, xd->screen); - - if (!img.isNull()) { - QImage image = img.convertToFormat(QImage::Format_RGB32); +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::paintEvent" << shm_img.size(); +#endif +#ifdef DONT_USE_MIT_SHM + // just convert the image every time... + if (!shm_img.isNull()) { + QImage image = shm_img; + //img.convertToFormat( XImage *xi = XCreateImage(xd->display, visual, 24, ZPixmap, 0, (char *) image.scanLine(0), image.width(), image.height(), 32, image.bytesPerLine()); @@ -468,6 +500,65 @@ void MyWindow::paintEvent() xi->data = 0; // QImage owns these bits XDestroyImage(xi); } +#else + // Use MIT_SHM + if (image_info->image) { + //qDebug() << "Here we go" << image_info->image->width << image_info->image->height; + int x = 0; + int y = 0; + // We should really set send_event to true, and then use the XShmCompletionEvent + // to synchronize painting + XShmPutImage (xd->display, window, gc, image_info->image, 0, 0, + x, y, image_info->image->width, image_info->image->height, + /*send_event*/ false); + + //### This makes output visible, probably not ideal from a performance point of view... + XFlush(xd->display); + } +#endif +} + +#ifndef DONT_USE_MIT_SHM +void MyShmImageInfo::destroy() +{ + XShmDetach (display, &shminfo); + XDestroyImage (image); + shmdt (shminfo.shmaddr); + shmctl (shminfo.shmid, IPC_RMID, 0); +} +#endif + +void MyWindow::resizeShmImage(int width, int height) +{ +#ifdef DONT_USE_MIT_SHM + shm_img = QImage(width, height, QImage::Format_RGB32); +#else + if (image_info) + image_info->destroy(); + else + image_info = new MyShmImageInfo(xd->display); + + Visual *visual = DefaultVisual(xd->display, xd->screen); + + + XImage *image = XShmCreateImage (xd->display, visual, 24, ZPixmap, 0, + &image_info->shminfo, width, height); + + + image_info->shminfo.shmid = shmget (IPC_PRIVATE, + image->bytes_per_line * image->height, IPC_CREAT|0777); + + image_info->shminfo.shmaddr = image->data = (char*)shmat (image_info->shminfo.shmid, 0, 0); + image_info->shminfo.readOnly = False; + + image_info->image = image; + + Status shm_attach_status = XShmAttach(xd->display, &image_info->shminfo); + + Q_ASSERT(shm_attach_status == True); + + shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, QImage::Format_RGB32 ); +#endif } void MyWindow::resizeEvent(XConfigureEvent *e) @@ -484,8 +575,11 @@ void MyWindow::resizeEvent(XConfigureEvent *e) height = e->height; #ifdef MYX11_DEBUG - qDebug() << hex << window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height; + qDebug() << hex << window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height << "img:" << shm_img.size(); #endif + if (shm_img.size() != QSize(width, height)) + resizeShmImage(width, height); + windowSurface->handleGeometryChange(xpos, ypos, width, height); } @@ -499,9 +593,13 @@ void MyWindow::setSize(int w, int h) void MyWindow::setGeometry(int x, int y, int w, int h) { #ifdef MYX11_DEBUG - qDebug() << "MyWindow::setGeometry" << hex << window << dec << x << y << w << h; + qDebug() << "MyWindow::setGeometry" << hex << window << dec << x << y << w << h << "img:" << shm_img.size(); #endif XMoveResizeWindow(xd->display, window, x, y, w, h); + + if (shm_img.size() != QSize(w, h)) { + resizeShmImage(w, h); + } } diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h index 2a73f3e..08fd0ce 100644 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -86,6 +86,8 @@ public: //### class QTestLiteWindowSurface; //### abstract callback interface, anyone? +struct MyShmImageInfo; + class MyWindow : public QObject { Q_OBJECT; @@ -120,11 +122,12 @@ public: void setWindowTitle(const QString &title); + QImage *image() { return &shm_img; } + public: //### int xpos, ypos; int width, height; - QImage img; Window window; MyDisplay *xd; GC gc; @@ -132,6 +135,12 @@ public: //### QTestLiteWindowSurface *windowSurface; int currentCursor; + +private: + void resizeShmImage(int width, int height); + + QImage shm_img; + MyShmImageInfo *image_info; }; class MyX11CursorNode -- cgit v0.12 From a8cf2de36dc570d2e73248d4cbe88ee3eb330dc0 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 19 Jan 2010 17:27:42 +0100 Subject: Enable MIT SHM and implement scrolling in the window surface Stealing a bit from the Qt X11 source code... --- .../testlite/qwindowsurface_testlite.cpp | 59 +++++++++++++++++++++- src/plugins/graphicssystems/testlite/x11util.cpp | 14 +++-- 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index c0a0cc9..0afbf2f 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -114,11 +114,68 @@ void QTestLiteWindowSurface::setGeometry(const QRect &rect) xw->setGeometry(rect.x(), rect.y(), rect.width(), rect.height()); } +//### scroll logic copied from QRasterWindowSurface, we should make better API for this + +void copied_qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) +{ + // make sure we don't detach + uchar *mem = const_cast(const_cast(img).bits()); + + int lineskip = img.bytesPerLine(); + int depth = img.depth() >> 3; + + const QRect imageRect(0, 0, img.width(), img.height()); + const QRect r = rect & imageRect & imageRect.translated(-offset); + const QPoint p = rect.topLeft() + offset; + + if (r.isEmpty()) + return; + + const uchar *src; + uchar *dest; + + if (r.top() < p.y()) { + src = mem + r.bottom() * lineskip + r.left() * depth; + dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth; + lineskip = -lineskip; + } else { + src = mem + r.top() * lineskip + r.left() * depth; + dest = mem + p.y() * lineskip + p.x() * depth; + } + + const int w = r.width(); + int h = r.height(); + const int bytes = w * depth; + + // overlapping segments? + if (offset.y() == 0 && qAbs(offset.x()) < w) { + do { + ::memmove(dest, src, bytes); + dest += lineskip; + src += lineskip; + } while (--h); + } else { + do { + ::memcpy(dest, src, bytes); + dest += lineskip; + src += lineskip; + } while (--h); + } +} + bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) { - return QWindowSurface::scroll(area, dx, dy); + if (!xw->image() || xw->image()->isNull()) + return false; + + const QVector rects = area.rects(); + for (int i = 0; i < rects.size(); ++i) + copied_qt_scrollRectInImage(*xw->image(), rects.at(i), QPoint(dx, dy)); + + return true; } + void QTestLiteWindowSurface::beginPaint(const QRegion ®ion) { Q_UNUSED(region); diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index f3b6dc2..de2a6d9 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -73,9 +73,7 @@ //#define MYX11_DEBUG -//MIT SHM disabled by default, since we haven't implemented ShmCompletion synchronization yet - -#define DONT_USE_MIT_SHM +//#define DONT_USE_MIT_SHM static int (*original_x_errhandler)(Display *dpy, XErrorEvent *); static bool seen_badwindow; @@ -506,14 +504,14 @@ void MyWindow::paintEvent() //qDebug() << "Here we go" << image_info->image->width << image_info->image->height; int x = 0; int y = 0; - // We should really set send_event to true, and then use the XShmCompletionEvent - // to synchronize painting + + // We could set send_event to true, and then use the ShmCompletion to synchronize, + // but let's do like Qt/11 and just use XSync XShmPutImage (xd->display, window, gc, image_info->image, 0, 0, x, y, image_info->image->width, image_info->image->height, - /*send_event*/ false); + /*send_event*/ False); - //### This makes output visible, probably not ideal from a performance point of view... - XFlush(xd->display); + XSync(xd->display, False); } #endif } -- cgit v0.12 From 5628a07e554d220396548f6914c798da8a556585 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 22 Jan 2010 10:42:43 +0100 Subject: Implement grabWindow() --- .../testlite/qgraphicssystem_testlite.cpp | 4 +-- src/plugins/graphicssystems/testlite/x11util.cpp | 42 +++++++++++++++++++++- src/plugins/graphicssystems/testlite/x11util.h | 1 + 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp index 72d364a..ed8f883 100644 --- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp @@ -112,8 +112,8 @@ QWindowSurface *QTestLiteGraphicsSystem::createWindowSurface(QWidget *widget) co QPixmap QTestLiteGraphicsSystem::grabWindow(WId window, int x, int y, int width, int height) const { - qDebug() << "grabWindow" << hex << window << dec<< x << y << width << height; - return QPixmap(); + QImage img = xd->grabWindow(window, x, y, width, height); + return QPixmap::fromImage(img); } diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index de2a6d9..7ad3ed5 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -377,6 +377,45 @@ void MyDisplay::eventDispatcher() } } + +QImage MyDisplay::grabWindow(Window window, int x, int y, int w, int h) +{ + if (w == 0 || h ==0) + return QImage(); + + //WinId 0 means the desktop widget + if (!window) + window = rootWindow(); + + XWindowAttributes window_attr; + if (!XGetWindowAttributes(display, window, &window_attr)) + return QImage(); + + if (w < 0) + w = window_attr.width - x; + if (h < 0) + h = window_attr.height - y; + + // Ideally, we should also limit ourselves to the screen area, but the Qt docs say + // that it's "unsafe" to go outside the screen, so we can ignore that problem. + + //We're definitely not optimizing for speed... + XImage *xi = XGetImage(display, window, x, y, w, h, AllPlanes, ZPixmap); + + if (!xi) + return QImage(); + + //taking a copy to make sure we have ownership -- not fast + QImage result = QImage( (uchar*) xi->data, xi->width, xi->height, xi->bytes_per_line, QImage::Format_RGB32 ).copy(); + + XDestroyImage(xi); + + return result; +} + + + + struct MyShmImageInfo { MyShmImageInfo(Display *xdisplay) : image(0), display(xdisplay) {} ~MyShmImageInfo() { destroy(); } @@ -477,13 +516,14 @@ void MyWindow::closeEvent() void MyWindow::paintEvent() { - Visual *visual = DefaultVisual(xd->display, xd->screen); #ifdef MYX11_DEBUG qDebug() << "MyWindow::paintEvent" << shm_img.size(); #endif #ifdef DONT_USE_MIT_SHM // just convert the image every time... if (!shm_img.isNull()) { + Visual *visual = DefaultVisual(xd->display, xd->screen); + QImage image = shm_img; //img.convertToFormat( XImage *xi = XCreateImage(xd->display, visual, 24, ZPixmap, diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h index 08fd0ce..db87d92 100644 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -68,6 +68,7 @@ public: unsigned long whitePixel() { return WhitePixel(display, screen); } bool handleEvent(XEvent *xe); + QImage grabWindow(Window w, int x, int y, int w, int h); public slots: void eventDispatcher(); -- cgit v0.12 From 05fefd9fcfb05d6ca6d60c1da2d8a1dca9b32874 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 22 Jan 2010 13:55:31 +0100 Subject: revert parts of 10392eef4fd4f9 We can't call QCOMPARE from within a nested function, because the return statement will just exit that function. VERIFY_COLOR can't be turned into a function this way. --- tests/auto/qwidget/tst_qwidget.cpp | 50 ++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index ee4e726..ea90ae3 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -5439,26 +5439,24 @@ public: QRegion r; }; -template -void verifyColor(R const& region, C const& color) -{ - const QRegion r = QRegion(region); - for (int i = 0; i < r.rects().size(); ++i) { - const QRect rect = r.rects().at(i); - for (int t = 0; t < 5; t++) { - const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), - rect.left(), rect.top(), - rect.width(), rect.height()); - QCOMPARE(pixmap.size(), rect.size()); - QPixmap expectedPixmap(pixmap); /* ensure equal formats */ - expectedPixmap.fill(color); - if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) - { QTest::qWait(200); continue; } - QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); - QCOMPARE(pixmap, expectedPixmap); - break; - } - } +#define VERIFY_COLOR(region, color) { \ + const QRegion r = QRegion(region); \ + for (int i = 0; i < r.rects().size(); ++i) { \ + const QRect rect = r.rects().at(i); \ + for (int t = 0; t < 5; t++) { \ + const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), \ + rect.left(), rect.top(), \ + rect.width(), rect.height()); \ + QCOMPARE(pixmap.size(), rect.size()); \ + QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ + expectedPixmap.fill(color); \ + if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) \ + { QTest::qWait(200); continue; } \ + QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); \ + QCOMPARE(pixmap, expectedPixmap); \ + break; \ + } \ + } \ } void tst_QWidget::moveChild_data() @@ -5499,9 +5497,9 @@ void tst_QWidget::moveChild() #endif QTRY_COMPARE(parent.r, QRegion(parent.rect()) - child.geometry()); QTRY_COMPARE(child.r, QRegion(child.rect())); - verifyColor(child.geometry().translated(tlwOffset), + VERIFY_COLOR(child.geometry().translated(tlwOffset), child.color); - verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), parent.color); parent.reset(); child.reset(); @@ -5520,9 +5518,9 @@ void tst_QWidget::moveChild() // should be scrolled in backingstore QCOMPARE(child.r, QRegion()); #endif - verifyColor(child.geometry().translated(tlwOffset), + VERIFY_COLOR(child.geometry().translated(tlwOffset), child.color); - verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), parent.color); } @@ -5553,8 +5551,8 @@ void tst_QWidget::showAndMoveChild() child.move(desktopDimensions.width()/2, desktopDimensions.height()/2); qApp->processEvents(); - verifyColor(child.geometry().translated(tlwOffset), Qt::blue); - verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red); + VERIFY_COLOR(child.geometry().translated(tlwOffset), Qt::blue); + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red); } void tst_QWidget::subtractOpaqueSiblings() -- cgit v0.12 From f0f1d8588892ba94301ecad2aa4495e9bfa364ae Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 25 Jan 2010 14:45:46 +0100 Subject: Handle RGB_32 format pixmaps correctly The alpha channel is undefined for RGB_32 --- tests/auto/qwidget/tst_qwidget.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index ea90ae3..9ed2d37 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -5450,9 +5450,12 @@ public: QCOMPARE(pixmap.size(), rect.size()); \ QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ expectedPixmap.fill(color); \ - if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) \ + QImage image = pixmap.toImage(); \ + uint alphaCorrection = image.format() == QImage::Format_RGB32 ? 0xff000000 : 0; \ + uint firstPixel = image.pixel(0,0) | alphaCorrection; \ + if ( firstPixel != QColor(color).rgb() && t < 4 ) \ { QTest::qWait(200); continue; } \ - QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); \ + QCOMPARE(firstPixel, QColor(color).rgb()); \ QCOMPARE(pixmap, expectedPixmap); \ break; \ } \ -- cgit v0.12 From 33a5ecd4908690d6a8366d8f7384ad1e8cf86f92 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 26 Jan 2010 14:52:09 +0100 Subject: queue user mouse, wheel, and keyboard input events For plugins: testlite, minimaldfb, vnc, LinuxInput[Mouse|Keyboard] --- src/gui/embedded/qkbd_qws.cpp | 3 +- src/gui/kernel/kernel.pri | 15 ++- src/gui/kernel/qapplication_lite.cpp | 133 +++++++++++++------ src/gui/kernel/qapplication_p.h | 74 ++++++++++- src/gui/kernel/qeventdispatcher_glib_lite.cpp | 138 ++++++++++++++++++++ src/gui/kernel/qeventdispatcher_glib_lite_p.h | 88 +++++++++++++ src/gui/kernel/qeventdispatcher_lite.cpp | 141 +++++++++++++++++++++ src/gui/kernel/qeventdispatcher_lite_p.h | 86 +++++++++++++ src/gui/kernel/qeventdispatcher_qws_p.h | 2 +- src/plugins/generic/linuxinput/qlinuxinput.cpp | 34 ++--- .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 16 +-- .../testlite/qwindowsurface_testlite.cpp | 27 ++-- src/plugins/graphicssystems/testlite/x11util.h | 2 +- src/plugins/graphicssystems/vnc/qvncserver.cpp | 54 +------- src/plugins/graphicssystems/vnc/qvncserver.h | 5 - 15 files changed, 673 insertions(+), 145 deletions(-) create mode 100644 src/gui/kernel/qeventdispatcher_glib_lite.cpp create mode 100644 src/gui/kernel/qeventdispatcher_glib_lite_p.h create mode 100644 src/gui/kernel/qeventdispatcher_lite.cpp create mode 100644 src/gui/kernel/qeventdispatcher_lite_p.h diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp index 233b6fa..97fb7a0 100644 --- a/src/gui/embedded/qkbd_qws.cpp +++ b/src/gui/embedded/qkbd_qws.cpp @@ -367,8 +367,7 @@ void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardM QString str; if (unicode != 0xffff) str = QString(unicode); - QKeyEvent ke(type, keycode, modifiers, str); - QApplicationPrivate::handleKeyEvent(0, &ke); + QApplicationPrivate::handleKeyEvent(0, type, keycode, modifiers, str); #endif } diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 9fbdfc8..0c7231e 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -195,7 +195,8 @@ embedded { embedded_lite { HEADERS += \ kernel/qgenericpluginfactory_lite.h \ - kernel/qgenericplugin_lite.h + kernel/qgenericplugin_lite.h \ + kernel/qeventdispatcher_lite_p.h SOURCES += \ kernel/qapplication_lite.cpp \ @@ -207,7 +208,17 @@ embedded_lite { kernel/qgenericplugin_lite.cpp \ kernel/qkeymapper_qws.cpp \ kernel/qsound_lite.cpp \ - kernel/qwidget_lite.cpp + kernel/qwidget_lite.cpp \ + kernel/qeventdispatcher_lite.cpp + + contains(QT_CONFIG, glib) { + SOURCES += \ + kernel/qeventdispatcher_glib_lite.cpp + HEADERS += \ + kernel/qeventdispatcher_glib_lite_p.h + QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB + LIBS_PRIVATE +=$$QT_LIBS_GLIB + } } !embedded:!embedded_lite:!x11:mac { diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 57f6d72..4242ff7 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -43,9 +43,9 @@ #include "qcolormap.h" #include "qpixmapcache.h" #if !defined(QT_NO_GLIB) -#include "private/qeventdispatcher_glib_p.h" +#include "qeventdispatcher_glib_lite_p.h" #endif -#include "private/qeventdispatcher_unix_p.h" +#include "qeventdispatcher_lite_p.h" #ifndef QT_NO_CURSOR #include "private/qcursor_p.h" #endif @@ -75,6 +75,32 @@ int qt_last_x = 0; int qt_last_y = 0; QPointer qt_last_mouse_receiver = 0; +QList QApplicationPrivate::userEventQueue; +static Qt::KeyboardModifiers modifiers = Qt::NoModifier; +static Qt::MouseButtons buttons = Qt::NoButton; + +void QApplicationPrivate::processUserEvent(UserEvent *e) +{ + switch(e->type) { + case QEvent::MouseButtonDblClick: // if mouse event, calculate appropriate widget and local coordinates + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + QApplicationPrivate::processMouseEvent(static_cast(e)); + break; + case QEvent::Wheel: + QApplicationPrivate::processWheelEvent(static_cast(e)); + break; + case QEvent::KeyPress: + case QEvent::KeyRelease: + QApplicationPrivate::processKeyEvent(static_cast(e)); + break; + default: + qWarning() << "Unknown user input event type:" << e->type; + break; + } +} + QString QApplicationPrivate::appName() const { return QT_PREPEND_NAMESPACE(appName); @@ -85,13 +111,13 @@ void QApplicationPrivate::createEventDispatcher() Q_Q(QApplication); #if !defined(QT_NO_GLIB) if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported()) - eventDispatcher = new QEventDispatcherGlib(q); + eventDispatcher = new QLiteEventDispatcherGlib(q); else #endif - eventDispatcher = new QEventDispatcherUNIX(q); + eventDispatcher = new QEventDispatcherLite(q); } -static bool qt_try_modal(QWidget *widget, const QEvent *event) +static bool qt_try_modal(QWidget *widget, QEvent::Type type) { QWidget * top = 0; @@ -101,7 +127,7 @@ static bool qt_try_modal(QWidget *widget, const QEvent *event) bool block_event = false; bool paint_event = false; - switch (event->type()) { + switch (type) { #if 0 case QEvent::Focus: if (!static_cast(event)->simpleData.get_focus) @@ -520,22 +546,51 @@ void QApplicationPrivate::handleLeaveEvent(QWidget *tlw) qt_last_mouse_receiver = 0; } -void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) +void QApplicationPrivate::processMouseEvent(MouseEvent *e) { // qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons(); - static QWidget *implicit_mouse_grabber=0; - QPointer cursor = QGraphicsSystemCursor::getInstance(); - if (cursor) - cursor->pointerEvent(ev); + QEvent::Type type; + // move first + Qt::MouseButtons stateChange = e->buttons ^ buttons; + if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) { + MouseEvent * newMouseEvent = new MouseEvent(e->tlw, e->localPos, e->globalPos, e->buttons); + userEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop + stateChange = Qt::NoButton; + } - QPoint localPoint = ev.pos(); - QPoint globalPoint = ev.globalPos(); - QWidget *mouseWindow = tlw; + QPoint localPoint = e->localPos; + QPoint globalPoint = e->globalPos; + QWidget *mouseWindow = e->tlw; + + Qt::MouseButton button = Qt::NoButton; - qt_last_x = globalPoint.x(); - qt_last_y = globalPoint.y(); + + if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) { + type = QEvent::MouseMove; + qt_last_x = globalPoint.x(); + qt_last_y = globalPoint.y(); + } + else { // check to see if a new button has been pressed/released + for (int check = Qt::LeftButton; + check <= Qt::XButton2; + check = check << 1) { + if (check & stateChange) { + button = Qt::MouseButton(check); + break; + } + } + if (button == Qt::NoButton) { + // Ignore mouse events that don't change the current state + return; + } + buttons = e->buttons; + if (button & e->buttons) + type = QEvent::MouseButtonPress; + else + type = QEvent::MouseButtonRelease; + } if (self->inPopupMode()) { //popup mouse handling is magical... @@ -544,11 +599,11 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) implicit_mouse_grabber = 0; //### how should popup mode and implicit mouse grab interact? - } else if (tlw && app_do_modal && !qt_try_modal(tlw, &ev) ) { + } else if (e->tlw && app_do_modal && !qt_try_modal(e->tlw, e->type) ) { //even if we're blocked by modality, we should deliver the mouse release event.. //### this code is not completely correct: multiple buttons can be pressed simultaneously - if (!(implicit_mouse_grabber && ev.buttons() == Qt::NoButton)) { - qDebug() << "modal blocked mouse event to" << tlw; + if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) { + qDebug() << "modal blocked mouse event to" << e->tlw; return; } } @@ -561,7 +616,7 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) if (!mouseWindow && !implicit_mouse_grabber) mouseWindow = QApplication::desktop(); - if (mouseWindow && mouseWindow != tlw) { + if (mouseWindow && mouseWindow != e->tlw) { //we did not get a sensible localPoint from the window system, so let's calculate it localPoint = mouseWindow->mapFromGlobal(globalPoint); } @@ -576,7 +631,7 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) } //handle implicit mouse grab - if (ev.type() == QEvent::MouseButtonPress && !implicit_mouse_grabber) { + if (type == QEvent::MouseButtonPress && !implicit_mouse_grabber) { implicit_mouse_grabber = mouseWidget; Q_ASSERT(mouseWindow); @@ -584,7 +639,7 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) } else if (implicit_mouse_grabber) { mouseWidget = implicit_mouse_grabber; mouseWindow = mouseWidget->window(); - if (mouseWindow != tlw) + if (mouseWindow != e->tlw) localPoint = mouseWindow->mapFromGlobal(globalPoint); } @@ -593,7 +648,7 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) //localPoint is local to mouseWindow, but it needs to be local to mouseWidget localPoint = mouseWidget->mapFrom(mouseWindow, localPoint); - if (ev.buttons() == Qt::NoButton) { + if (buttons == Qt::NoButton) { //qDebug() << "resetting mouse grabber"; implicit_mouse_grabber = 0; } @@ -608,25 +663,29 @@ void QApplicationPrivate::handleMouseEvent(QWidget *tlw, const QMouseEvent &ev) // qDebug() << "sending mouse ev." << ev.type() << localPoint << globalPoint << ev.button() << ev.buttons() << mouseWidget << "mouse grabber" << implicit_mouse_grabber; - QMouseEvent e(ev.type(), localPoint, globalPoint, ev.button(), ev.buttons(), ev.modifiers()); - QApplication::sendSpontaneousEvent(mouseWidget, &e); + QMouseEvent ev(type, localPoint, globalPoint, button, buttons, modifiers); + + QPointer cursor = QGraphicsSystemCursor::getInstance(); + if (cursor) + cursor->pointerEvent(ev); + QApplication::sendSpontaneousEvent(mouseWidget, &ev); } //### there's a lot of duplicated logic here -- refactoring required! -void QApplicationPrivate::handleWheelEvent(QWidget *tlw, QWheelEvent &ev) +void QApplicationPrivate::processWheelEvent(WheelEvent *e) { // QPoint localPoint = ev.pos(); - QPoint globalPoint = ev.globalPos(); + QPoint globalPoint = e->globalPos; // bool trustLocalPoint = !!tlw; //is there something the local point can be local to? QWidget *mouseWidget; qt_last_x = globalPoint.x(); qt_last_y = globalPoint.y(); - QWidget *mouseWindow = tlw; + QWidget *mouseWindow = e->tlw; // find the tlw if we didn't get it from the plugin if (!mouseWindow) { @@ -638,7 +697,7 @@ void QApplicationPrivate::handleWheelEvent(QWidget *tlw, QWheelEvent &ev) mouseWidget = mouseWindow; - if (app_do_modal && !qt_try_modal(mouseWindow, &ev) ) { + if (app_do_modal && !qt_try_modal(mouseWindow, e->type) ) { qDebug() << "modal blocked wheel event" << mouseWindow; return; } @@ -649,16 +708,16 @@ void QApplicationPrivate::handleWheelEvent(QWidget *tlw, QWheelEvent &ev) p = mouseWidget->mapFromGlobal(globalPoint); } - QWheelEvent e(p, globalPoint, ev.delta(), ev.buttons(), ev.modifiers(), - ev.orientation()); - QApplication::sendSpontaneousEvent(mouseWidget, &e); + QWheelEvent ev(p, globalPoint, e->delta, buttons, modifiers, + e->orient); + QApplication::sendSpontaneousEvent(mouseWidget, &ev); } // Remember, Qt convention is: keyboard state is state *before* -void QApplicationPrivate::handleKeyEvent(QWidget *tlw, QKeyEvent *e) +void QApplicationPrivate::processKeyEvent(KeyEvent *e) { QWidget *focusW = 0; if (self->inPopupMode()) { @@ -668,7 +727,7 @@ void QApplicationPrivate::handleKeyEvent(QWidget *tlw, QKeyEvent *e) if (!focusW) focusW = QApplication::focusWidget(); if (!focusW) - focusW = tlw; + focusW = e->tlw; if (!focusW) focusW = QApplication::activeWindow(); @@ -676,10 +735,12 @@ void QApplicationPrivate::handleKeyEvent(QWidget *tlw, QKeyEvent *e) if (!focusW) return; - if (app_do_modal && !qt_try_modal(focusW, e)) + if (app_do_modal && !qt_try_modal(focusW, e->type)) return; - QApplication::sendSpontaneousEvent(focusW, e); + modifiers = e->modifiers; + QKeyEvent ev(e->type, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount); + QApplication::sendSpontaneousEvent(focusW, &ev); } diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index a93fd63..955a3fc 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -65,8 +65,9 @@ #include "QtCore/qhash.h" #include "QtCore/qpointer.h" #include "private/qcoreapplication_p.h" -#include "private/qshortcutmap_p.h" +#include "QtGui/private/qshortcutmap_p.h" #include +#include "QtCore/qpoint.h" #ifdef Q_WS_QWS #include "QtGui/qscreen_qws.h" #include @@ -564,11 +565,72 @@ public: #endif #ifdef Q_WS_LITE - static void handleMouseEvent(QWidget *tlw, const QMouseEvent &ev); - static void handleKeyEvent(QWidget *tlw, QKeyEvent *e); + + class UserEvent { + public: + UserEvent(QWidget *w) { tlw = w; } + QWidget * tlw; + QEvent::Type type; + }; + + class MouseEvent : public UserEvent { + public: + MouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) + : UserEvent(w){ localPos = local; globalPos = global; buttons = b; type = QEvent::MouseMove; } + QPoint localPos; + QPoint globalPos; + Qt::MouseButtons buttons; + }; + + class WheelEvent : public UserEvent { + public: + WheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) + : UserEvent(w) { localPos = local; globalPos = global; delta = d; orient = o; type = QEvent::Wheel; } + int delta; + QPoint localPos; + QPoint globalPos; + Qt::Orientation orient; + }; + + class KeyEvent : public UserEvent { + public: + KeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) + :UserEvent(w){ type = t; key = k; unicode = text; repeat = autorep; repeatCount = count; modifiers = mods; } + int key; + QString unicode; + bool repeat; + ushort repeatCount; + Qt::KeyboardModifiers modifiers; + }; + + static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { + MouseEvent * e = new MouseEvent(w, local, global, b); + queueUserEvent(e); + } + + static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { + KeyEvent * e = new KeyEvent(w, t, k, mods, text, autorep, count); + queueUserEvent(e); + } + + static void handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { + WheelEvent *e = new WheelEvent(w, local, global, d, o); + queueUserEvent(e); + } + + static void queueUserEvent(UserEvent *ev) { userEventQueue.append(ev); } + static void processUserEvent(UserEvent *e); + static int userEventsQueued() { return userEventQueue.count(); } + static UserEvent * getUserEvent() { return userEventQueue.takeFirst(); } + + // could be private, should only be used by deliverUserEvents() + static void processMouseEvent(MouseEvent *e); + static void processKeyEvent(KeyEvent *e); + static void processWheelEvent(WheelEvent *e); + + // delivered directly by the plugin via spontaneous events static void handleGeometryChange(QWidget *tlw, const QRect &newRect); static void handleCloseEvent(QWidget *tlw); - static void handleWheelEvent(QWidget *tlw, QWheelEvent &e); static void handleEnterEvent(QWidget *tlw); static void handleLeaveEvent(QWidget *tlw); #endif @@ -587,6 +649,10 @@ private: static QHash scanCodeCache; #endif +#ifdef Q_WS_LITE + static QList userEventQueue; +#endif + static QApplicationPrivate *self; static void giveFocusAccordingToFocusPolicy(QWidget *w, diff --git a/src/gui/kernel/qeventdispatcher_glib_lite.cpp b/src/gui/kernel/qeventdispatcher_glib_lite.cpp new file mode 100644 index 0000000..b8d2a5b --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_glib_lite.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** 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 QtCore 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 "qeventdispatcher_glib_lite_p.h" + +#include "qapplication.h" + +#include "qplatformdefs.h" +#include "qapplication.h" + +#include +#include "qapplication_p.h" + +#include + +QT_BEGIN_NAMESPACE + +struct GUserEventSource +{ + GSource source; + QLiteEventDispatcherGlib *q; +}; + +static gboolean userEventSourcePrepare(GSource *s, gint *timeout) +{ + Q_UNUSED(s) + Q_UNUSED(timeout) + + return QApplicationPrivate::userEventsQueued() > 0; +} + +static gboolean userEventSourceCheck(GSource *source) +{ + return userEventSourcePrepare(source, 0); +} + +static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer) +{ + GUserEventSource * source = reinterpret_cast(s); + + int i = QApplicationPrivate::userEventsQueued(); + QApplicationPrivate::UserEvent * event; + while (i--) { + event = QApplicationPrivate::getUserEvent(); + + // send through event filter + if (source->q->filterEvent(event)) { + delete event; + continue; + } + QApplicationPrivate::processUserEvent(event); + delete event; + } + + return true; +} + + +static GSourceFuncs userEventSourceFuncs = { + userEventSourcePrepare, + userEventSourceCheck, + userEventSourceDispatch, + NULL, + NULL, + NULL +}; + +QLiteEventDispatcherGlibPrivate::QLiteEventDispatcherGlibPrivate(GMainContext *context) + : QEventDispatcherGlibPrivate(context) +{ + userEventSource = reinterpret_cast(g_source_new(&userEventSourceFuncs, + sizeof(GUserEventSource))); + userEventSource->q = 0; + g_source_set_can_recurse(&userEventSource->source, true); + g_source_attach(&userEventSource->source, mainContext); +} + + +QLiteEventDispatcherGlib::QLiteEventDispatcherGlib(QObject *parent) + : QEventDispatcherGlib(*new QLiteEventDispatcherGlibPrivate, parent) +{ + Q_D(QLiteEventDispatcherGlib); + d->userEventSource->q = this; +} + +QLiteEventDispatcherGlib::~QLiteEventDispatcherGlib() +{ + Q_D(QLiteEventDispatcherGlib); + + g_source_destroy(&d->userEventSource->source); + g_source_unref(&d->userEventSource->source); + d->userEventSource = 0; +} + +bool QLiteEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags) +{ + return QEventDispatcherGlib::processEvents(flags); +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qeventdispatcher_glib_lite_p.h b/src/gui/kernel/qeventdispatcher_glib_lite_p.h new file mode 100644 index 0000000..6ebdb25 --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_glib_lite_p.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 QtCore 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 QLITEEVENTDISPATCHER_GLIB_P_H +#define QLITEEVENTDISPATCHER_GLIB_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include + +typedef struct _GMainContext GMainContext; + +QT_BEGIN_NAMESPACE +class QLiteEventDispatcherGlibPrivate; + +class QLiteEventDispatcherGlib : public QEventDispatcherGlib +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QLiteEventDispatcherGlib) + +public: + explicit QLiteEventDispatcherGlib(QObject *parent = 0); + ~QLiteEventDispatcherGlib(); + + bool processEvents(QEventLoop::ProcessEventsFlags flags); +}; + +struct GUserEventSource; + +class QLiteEventDispatcherGlibPrivate : public QEventDispatcherGlibPrivate +{ + Q_DECLARE_PUBLIC(QLiteEventDispatcherGlib) +public: + QLiteEventDispatcherGlibPrivate(GMainContext *context = 0); + GUserEventSource *userEventSource; +}; + + +QT_END_NAMESPACE + +#endif // QLITEEVENTDISPATCHER_GLIB_P_H diff --git a/src/gui/kernel/qeventdispatcher_lite.cpp b/src/gui/kernel/qeventdispatcher_lite.cpp new file mode 100644 index 0000000..39eef96 --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_lite.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** 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 "qplatformdefs.h" +#include "qapplication.h" +#include "qeventdispatcher_lite_p.h" +#include "private/qeventdispatcher_unix_p.h" +#include "qapplication_p.h" +#ifndef QT_NO_THREAD +# include "qmutex.h" +#endif + +#include +QT_BEGIN_NAMESPACE + +QT_USE_NAMESPACE + +class QEventDispatcherLitePrivate : public QEventDispatcherUNIXPrivate +{ + Q_DECLARE_PUBLIC(QEventDispatcherLite) +public: + inline QEventDispatcherLitePrivate() + { } +}; + + +QEventDispatcherLite::QEventDispatcherLite(QObject *parent) + : QEventDispatcherUNIX(*new QEventDispatcherLitePrivate, parent) +{ } + +QEventDispatcherLite::~QEventDispatcherLite() +{ } + + + +//#define ZERO_FOR_THE_MOMENT + +bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags) +{ + Q_D(QEventDispatcherLite); + int nevents = 0; + + // handle gui and posted events + d->interrupt = false; + QApplication::sendPostedEvents(); + + while (!d->interrupt) { // also flushes output buffer ###can be optimized + QApplicationPrivate::UserEvent *event; + if (!(flags & QEventLoop::ExcludeUserInputEvents) + && QApplicationPrivate::userEventsQueued() > 0) { + // process a pending user input event + event = QApplicationPrivate::getUserEvent(); + } else { + break; + } + + if (filterEvent(event)) { + delete event; + continue; + } + nevents++; + + QApplicationPrivate::processUserEvent(event); + delete event; + } + + if (!d->interrupt) { + if (QEventDispatcherUNIX::processEvents(flags)) + return true; + } + return (nevents > 0); +} + +bool QEventDispatcherLite::hasPendingEvents() +{ + extern uint qGlobalPostedEventsCount(); // from qapplication.cpp + return qGlobalPostedEventsCount() || QApplicationPrivate::userEventsQueued();; +} + +void QEventDispatcherLite::startingUp() +{ + +} + +void QEventDispatcherLite::closingDown() +{ + +} + +void QEventDispatcherLite::flush() +{ + if(qApp) + qApp->sendPostedEvents(); +} + + +int QEventDispatcherLite::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + timeval *timeout) +{ + return QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout); +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qeventdispatcher_lite_p.h b/src/gui/kernel/qeventdispatcher_lite_p.h new file mode 100644 index 0000000..c098e6c --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_lite_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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 QEVENTDISPATCHER_LITE_P_H +#define QEVENTDISPATCHER_LITE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qeventdispatcher_unix_p.h" + +QT_BEGIN_NAMESPACE + +class QEventDispatcherLitePrivate; + +class QEventDispatcherLite : public QEventDispatcherUNIX +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QEventDispatcherLite) + +public: + explicit QEventDispatcherLite(QObject *parent = 0); + ~QEventDispatcherLite(); + + bool processEvents(QEventLoop::ProcessEventsFlags flags); + bool hasPendingEvents(); + + void flush(); + + void startingUp(); + void closingDown(); + +protected: + int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + timeval *timeout); +}; + +QT_END_NAMESPACE + +#endif // QEVENTDISPATCHER_LITE_P_H diff --git a/src/gui/kernel/qeventdispatcher_qws_p.h b/src/gui/kernel/qeventdispatcher_qws_p.h index 8d8d61c..5a2b016 100644 --- a/src/gui/kernel/qeventdispatcher_qws_p.h +++ b/src/gui/kernel/qeventdispatcher_qws_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -class QEventDispatcherQWSPrivate; +class QEventDispatcherLitePrivate; class QEventDispatcherQWS : public QEventDispatcherUNIX { diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 308af6b..363e91f 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include @@ -100,6 +99,7 @@ void QLinuxInputMouseHandler::readMouseData() { struct ::input_event buffer[32]; int n = 0; + bool posChanged = false; forever { n = QT_READ(m_fd, reinterpret_cast(buffer) + n, sizeof(buffer) - n); @@ -122,28 +122,34 @@ void QLinuxInputMouseHandler::readMouseData() bool unknown = false; if (data->type == EV_ABS) { - if (data->code == ABS_X) { + if (data->code == ABS_X && m_x != data->value) { m_x = data->value; - } else if (data->code == ABS_Y) { + posChanged = true; + } else if (data->code == ABS_Y && m_y != data->value) { m_y = data->value; + posChanged = true; } else { unknown = true; } } else if (data->type == EV_REL) { if (data->code == REL_X) { m_x += data->value; + posChanged = true; } else if (data->code == REL_Y) { m_y += data->value; + posChanged = true; } else if (data->code == ABS_WHEEL) { // vertical scroll // data->value: 1 == up, -1 == down int delta = 120 * data->value; - QWheelEvent we(QPoint(m_x, m_y), QPoint(m_x, m_y), delta, m_buttons, Qt::NoModifier, Qt::Vertical); - QApplicationPrivate::handleWheelEvent(0, we); + QApplicationPrivate::handleWheelEvent(0, QPoint(m_x, m_y), + QPoint(m_x, m_y), + delta, Qt::Vertical); } else if (data->code == ABS_THROTTLE) { // horizontal scroll // data->value: 1 == right, -1 == left int delta = 120 * -data->value; - QWheelEvent we(QPoint(m_x, m_y), QPoint(m_x, m_y), delta, m_buttons, Qt::NoModifier, Qt::Horizontal); - QApplicationPrivate::handleWheelEvent(0, we); + QApplicationPrivate::handleWheelEvent(0, QPoint(m_x, m_y), + QPoint(m_x, m_y), + delta, Qt::Horizontal); } else { unknown = true; } @@ -161,17 +167,15 @@ void QLinuxInputMouseHandler::readMouseData() else m_buttons &= ~button; - Qt::KeyboardModifiers modifiers = Qt::NoModifier; //### - QMouseEvent m(data->value ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease, - QPoint(m_x, m_y), QPoint(m_x, m_y), button, m_buttons, modifiers); - QApplicationPrivate::handleMouseEvent(0, m); + QApplicationPrivate::handleMouseEvent(0, QPoint(m_x, m_y), + QPoint(m_x, m_y), m_buttons); } else if (data->type == EV_SYN && data->code == SYN_REPORT) { + if (!posChanged) + continue; + posChanged = false; QPoint pos(m_x, m_y); - Qt::KeyboardModifiers modifiers = Qt::NoModifier; //### - QMouseEvent m(QEvent::MouseMove, QPoint(m_x, m_y), QPoint(m_x, m_y), - Qt::NoButton, m_buttons, modifiers); - QApplicationPrivate::handleMouseEvent(0, m); + QApplicationPrivate::handleMouseEvent(0, pos, pos, m_buttons); // pos = m_handler->transform(pos); //m_handler->limitToScreen(pos); diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 17fdd10..8809536 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -109,7 +109,6 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) QEvent::Type type = QDirectFbConvenience::eventType(event.window.type); QPoint p(event.window.x, event.window.y); QPoint globalPos = globalPoint(event); - Qt::MouseButton button = QDirectFbConvenience::mouseButton(event.window.button); Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); QWidget *tlw = tlwMap.value(event.window.window_id); @@ -141,9 +140,7 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) window->UngrabPointer(window); } - //DFB doesn't give keyboardmodifiers on mouseevents - QMouseEvent mouseEvent(type,p,globalPos,button, buttons,(Qt::KeyboardModifiers)0); - QApplicationPrivate::handleMouseEvent(tlw,mouseEvent); + QApplicationPrivate::handleMouseEvent(tlw, p, globalPos, buttons); } void QDirectFbInput::applicationEnd() @@ -156,13 +153,11 @@ void QDirectFbInput::handleWheelEvent(const DFBEvent &event) { QPoint p(event.window.cx, event.window.cy); QPoint globalPos = globalPoint(event); - Qt::MouseButton button = QDirectFbConvenience::mouseButton(event.window.button); - Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); QWidget *tlw = tlwMap.value(event.window.window_id); - QWheelEvent wheelEvent(p,globalPos,event.window.step*120,buttons,Qt::NoModifier,Qt::Vertical); - QApplicationPrivate::handleWheelEvent(tlw,wheelEvent); - + QApplicationPrivate::handleWheelEvent(tlw, p, globalPos, + event.window.step*120, + Qt::Vertical); } void QDirectFbInput::handleKeyEvents(const DFBEvent &event) @@ -171,9 +166,8 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event) Qt::Key key = QDirectFbConvenience::keyMap()->value(event.window.key_symbol); Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers); - QKeyEvent keyEvent(type,key,modifiers,QChar(event.window.key_symbol)); QWidget *tlw = tlwMap.value(event.window.window_id); - QApplicationPrivate::handleKeyEvent(tlw,&keyEvent); + QApplicationPrivate::handleKeyEvent(tlw, type, key, modifiers, QChar(event.window.key_symbol)); } void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 0afbf2f..26a7675 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -254,9 +254,10 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) bool hor = (((e->button == Button4 || e->button == Button5) && (modifiers & Qt::AltModifier)) || (e->button == 6 || e->button == 7)); - QWheelEvent we(QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), delta, - buttons, modifiers, hor ? Qt::Horizontal : Qt::Vertical); - QApplicationPrivate::handleWheelEvent(window(),we); + QApplicationPrivate::handleWheelEvent(window(), + QPoint(e->x, e->y), + QPoint(e->x_root, e->y_root), + delta, hor ? Qt::Horizontal : Qt::Vertical); } return; } @@ -264,18 +265,12 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) } } - if (type == QEvent::MouseButtonPress && mousePoint != QPoint(e->x_root, e->y_root)) { - //we've missed a mouse move event somewhere (maybe because we - //haven't implemented mouse tracking yet); let's synthesize it. - QMouseEvent me(QEvent::MouseMove, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), - Qt::NoButton, buttons, modifiers); - QApplicationPrivate::handleMouseEvent(window(), me); - } - buttons ^= button; // X event uses state *before*, Qt uses state *after* - QMouseEvent me(type, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), button, buttons, modifiers); - QApplicationPrivate::handleMouseEvent(window(), me); + QApplicationPrivate::handleMouseEvent(window(), QPoint(e->x, e->y), + QPoint(e->x_root, e->y_root), + buttons); + mousePoint = QPoint(e->x_root, e->y_root); } @@ -587,14 +582,12 @@ void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) // qDebug() << "lookup: " << hex << keySym << qtcode << "mod" << modifiers; if (qtcode) { - QKeyEvent keyEvent(type, qtcode, modifiers); - QApplicationPrivate::handleKeyEvent(window(), &keyEvent); + QApplicationPrivate::handleKeyEvent(window(), type, qtcode, modifiers); } else if (chars[0]) { int qtcode = chars.toUpper()[0]; //Not exactly right... if (modifiers & Qt::ControlModifier && qtcode < ' ') qtcode = chars[0] + '@'; - QKeyEvent keyEvent(type, qtcode, modifiers, QString::fromLatin1(chars)); - QApplicationPrivate::handleKeyEvent(window(), &keyEvent); + QApplicationPrivate::handleKeyEvent(window(), type, qtcode, modifiers, QString::fromLatin1(chars)); } else { qWarning() << "unknown X keycode" << hex << e->keycode << keySym; } diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h index db87d92..76e029d 100644 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -68,7 +68,7 @@ public: unsigned long whitePixel() { return WhitePixel(display, screen); } bool handleEvent(XEvent *xe); - QImage grabWindow(Window w, int x, int y, int w, int h); + QImage grabWindow(Window window, int x, int y, int w, int h); public slots: void eventDispatcher(); diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp index 9576d10..490ca02 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -399,10 +399,6 @@ void QVNCServer::init(uint port) qvnc_cursor = 0; #endif encoder = 0; - - eventTimer.setInterval(0); - eventTimer.setSingleShot(true); - connect(&eventTimer, SIGNAL(timeout()), this, SLOT(sendInputEvents())); } QVNCServer::~QVNCServer() @@ -833,35 +829,6 @@ static bool buttonChange(Qt::MouseButtons before, Qt::MouseButtons after, Qt::Mo return false; } -void QVNCServer::sendInputEvents() -{ - EventPair pair; - QMouseEvent *me; - QKeyEvent *ke; - QWheelEvent *we; - - while(!eventList.isEmpty()) { - pair = eventList.takeFirst(); - switch(pair.first) { - case MouseEvent: - me = static_cast(pair.second); - QApplicationPrivate::handleMouseEvent(0, *me); - delete me; - break; - case KeyboardEvent: - ke = static_cast(pair.second); - QApplicationPrivate::handleKeyEvent(0, ke); - delete ke; - break; - case WheelEvent: - we = static_cast(pair.second); - QApplicationPrivate::handleWheelEvent(0, *we); - delete we; - break; - } - } -} - void QVNCServer::pointerEvent() { QRfbPointerEvent ev; @@ -870,7 +837,6 @@ void QVNCServer::pointerEvent() // QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons); - EventPair pair; //qDebug() << "pointerEvent" << ev.x << ev.y << hex << ev.buttons; if (ev.wheelDirection == ev.WheelNone) { QEvent::Type type = QEvent::MouseMove; @@ -878,10 +844,7 @@ void QVNCServer::pointerEvent() bool isPress; if (buttonChange(buttons, ev.buttons, &button, &isPress)) type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - QMouseEvent * me = new QMouseEvent(type, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), button, ev.buttons, keymod); - pair.first = MouseEvent; - pair.second = me; - buttons = ev.buttons; + QApplicationPrivate::handleMouseEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), ev.buttons); } else { // No buttons or motion reported at the same time as wheel events Qt::Orientation orientation; @@ -890,13 +853,8 @@ void QVNCServer::pointerEvent() else orientation = Qt::Vertical; int delta = 120 * ((ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelUp) ? 1 : -1); - QWheelEvent *we = new QWheelEvent(QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), delta, buttons, keymod, orientation); - pair.first = WheelEvent; - pair.second = we; + QApplicationPrivate::handleWheelEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), delta, orientation); } - eventList.append(pair); - if (!eventTimer.isActive()) - eventTimer.start(); handleMsg = false; } } @@ -921,13 +879,7 @@ void QVNCServer::keyEvent() QString str; if (ev.unicode && ev.unicode != 0xffff) str = QString(ev.unicode); - QKeyEvent *keyEvent = new QKeyEvent(type, ev.keycode, keymod, str); - EventPair pair; - pair.first = KeyboardEvent; - pair.second = keyEvent; - eventList.append(pair); - if (!eventTimer.isActive()) - eventTimer.start(); + QApplicationPrivate::handleKeyEvent(0, type, ev.keycode, keymod, str); } handleMsg = false; } diff --git a/src/plugins/graphicssystems/vnc/qvncserver.h b/src/plugins/graphicssystems/vnc/qvncserver.h index 7532cb4..4fcdbae 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.h +++ b/src/plugins/graphicssystems/vnc/qvncserver.h @@ -526,11 +526,6 @@ private: QRfbEncoder *encoder; QVNCCursor *cursor; - - enum EventType { MouseEvent, KeyboardEvent, WheelEvent }; - QTimer eventTimer; - typedef QPair EventPair; - QList eventList; }; -- cgit v0.12 From 5bc4ed0c33bad23ce2988e74ae8e7f9a4e5a3250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 27 Jan 2010 15:02:54 +0100 Subject: Fix QPixmap::fill autotest and cachekey autotest Also make sure it didn't failed with a QFATAL when drawing bitmaps and tried to make sure all surfaces er unlocked when opperations are being performed on them from the windowsurface. There are still test failuers :( --- src/gui/image/qpixmap_blitter.cpp | 35 ++++++++++++++++++++-- src/gui/painting/qpaintengine_blitter.cpp | 2 ++ .../minimaldfb/qblitter_directfb.cpp | 2 ++ .../minimaldfb/qdirectfbconvenience.cpp | 12 ++++---- .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 2 ++ .../minimaldfb/qwindowsurface_minimaldfb.cpp | 7 +++-- .../minimaldfb/qwindowsurface_minimaldfb.h | 2 ++ 7 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 175c234..6e34fbd 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -5,9 +5,14 @@ #include #include +#include + +static int global_ser_no = 0; + QBlittablePixmapData::QBlittablePixmapData(QPixmapData::PixelType type) : QPixmapData(type,BlitterClass), m_engine(0), m_blittable(0) { + setSerialNumber(++global_ser_no); } QBlittablePixmapData::~QBlittablePixmapData() @@ -21,7 +26,6 @@ QBlittable *QBlittablePixmapData::blittable() const if (!m_blittable) { QBlittablePixmapData *that = const_cast(this); that->m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QRect(0,0,w,h)); - that->setSerialNumber(m_blittable->lock()->serialNumber()); } return m_blittable; @@ -77,11 +81,36 @@ int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const void QBlittablePixmapData::fill(const QColor &color) { + //jlind: todo: change when blittables can support non opaque fillRects if (color.alpha() == 255 && blittable()->capabilities() & QBlittable::SolidRectCapability) { blittable()->unlock(); blittable()->fillRect(QRectF(0,0,w,h),color); - }else - blittable()->lock()->fill(color.rgba()); + }else { + uint pixel; + switch (blittable()->lock()->format()) { + case QImage::Format_ARGB32_Premultiplied: + pixel = PREMUL(color.rgba()); + break; + case QImage::Format_ARGB8565_Premultiplied: + pixel = qargb8565(color.rgba()).rawValue(); + break; + case QImage::Format_ARGB8555_Premultiplied: + pixel = qargb8555(color.rgba()).rawValue(); + break; + case QImage::Format_ARGB6666_Premultiplied: + pixel = qargb6666(color.rgba()).rawValue(); + break; + case QImage::Format_ARGB4444_Premultiplied: + pixel = qargb4444(color.rgba()).rawValue(); + break; + default: + pixel = color.rgba(); + break; + } + //so premultiplied formats are supported and ARGB32 and RGB32 + blittable()->lock()->fill(pixel); + } + } QImage *QBlittablePixmapData::buffer() diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 0f6b5cf..1a1d5e0 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -63,6 +63,8 @@ public: bool canBlitterDrawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) const { + if (pm.pixmapData()->classId() != QPixmapData::BlitterClass) + return false; if ((!drawPixmapState) || drawPixmapState & drawPixmapMask) { if (m_capabilities & (QBlittable::SourceOverPixmapCapability | QBlittable::SourceOverScaledPixmapCapability)) { diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp index c2e4b4f..ded57d3 100644 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp @@ -33,6 +33,7 @@ QDirectFbBlitter::QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface) QDirectFbBlitter::~QDirectFbBlitter() { + unlock(); m_surface->Release(m_surface); } @@ -55,6 +56,7 @@ void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, con Q_ASSERT(data->classId() == QPixmapData::BlitterClass); QBlittablePixmapData *blitPm = static_cast(data); QDirectFbBlitter *dfbBlitter = static_cast(blitPm->blittable()); + dfbBlitter->unlock(); IDirectFBSurface *s = dfbBlitter->m_surface; diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp index 57d03fc..8594c09 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp @@ -5,11 +5,13 @@ IDirectFB *QDirectFbConvenience::dfbInterface() { - IDirectFB *dfb; - DFBResult result = DirectFBCreate(&dfb); - if (result != DFB_OK) { - DirectFBError("QDirectFBConvenience: error creating DirectFB interface",result); - return 0; + static IDirectFB *dfb = 0; + if (!dfb) { + DFBResult result = DirectFBCreate(&dfb); + if (result != DFB_OK) { + DirectFBError("QDirectFBConvenience: error creating DirectFB interface",result); + return 0; + } } return dfb; } diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index f1f2215..06ae800 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -130,6 +130,8 @@ QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() } delete[] argv; + //init directfb + QDirectFbConvenience::dfbInterface(); mPrimaryScreen = new QDirectFbGraphicsSystemScreen(0); mScreens.append(mPrimaryScreen); diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 7f3e165..4be61df 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -66,7 +66,7 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QDirectFbGraphicsSystemScreen *sc qDebug() << "WindowSurface format " << QDirectFbConvenience::imageFormatFromSurfaceFormat(format,caps); - QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); + blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); m_pmdata->setBlittable(blitter); m_pixmap = new QPixmap(m_pmdata); @@ -88,7 +88,7 @@ void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const Q_UNUSED(widget); Q_UNUSED(offset); - m_dfbSurface->Unlock(m_dfbSurface); + blitter->unlock(); const quint8 windowOpacity = quint8(widget->windowOpacity() * 0xff); m_dfbWindow->SetOpacity(m_dfbWindow,windowOpacity); @@ -102,6 +102,7 @@ void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const void QDirectFbWindowSurface::setGeometry(const QRect &rect) { + blitter->unlock(); QWindowSurface::setGeometry(rect); m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), rect.width(), rect.height()); @@ -123,6 +124,7 @@ static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) { + blitter->unlock(); if (!m_dfbSurface || area.isEmpty()) return false; m_dfbSurface->SetBlittingFlags(m_dfbSurface, DSBLIT_NOFX); @@ -150,6 +152,7 @@ void QDirectFbWindowSurface::endPaint(const QRegion ®ion) void QDirectFbWindowSurface::setVisible(bool visible) { + blitter->unlock(); if (visible) { int x = this->geometry().x(); int y = this->geometry().y(); diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h index f74fb29..088aeba 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE class QDirectFbGraphicsSystemScreen; +class QDirectFbBlitter; class QDirectFbWindowSurface : public QWindowSurface { @@ -80,6 +81,7 @@ private: IDirectFBWindow *m_dfbWindow; IDirectFBSurface *m_dfbSurface; + QDirectFbBlitter *blitter; }; QT_END_NAMESPACE -- cgit v0.12 From 8ef9ec9f2ca3e4c590330aec234a7bf1b4410252 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 27 Jan 2010 15:36:45 +0100 Subject: double click events --- src/gui/kernel/qapplication_lite.cpp | 26 +++++++++++++++++++++++--- src/gui/kernel/qapplication_p.h | 35 +++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 4242ff7..42932ba 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -78,6 +78,12 @@ QPointer qt_last_mouse_receiver = 0; QList QApplicationPrivate::userEventQueue; static Qt::KeyboardModifiers modifiers = Qt::NoModifier; static Qt::MouseButtons buttons = Qt::NoButton; +static ulong mousePressTime; +static Qt::MouseButton mousePressButton = Qt::NoButton; +static int mousePressX; +static int mousePressY; +static int mouse_double_click_distance = 5; +QTime QApplicationPrivate::time; void QApplicationPrivate::processUserEvent(UserEvent *e) { @@ -555,7 +561,7 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e) // move first Qt::MouseButtons stateChange = e->buttons ^ buttons; if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) { - MouseEvent * newMouseEvent = new MouseEvent(e->tlw, e->localPos, e->globalPos, e->buttons); + MouseEvent * newMouseEvent = new MouseEvent(e->tlw, e->timestamp, e->localPos, e->globalPos, e->buttons); userEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop stateChange = Qt::NoButton; } @@ -571,6 +577,9 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e) type = QEvent::MouseMove; qt_last_x = globalPoint.x(); qt_last_y = globalPoint.y(); + if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance|| + qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance) + mousePressButton = Qt::NoButton; } else { // check to see if a new button has been pressed/released for (int check = Qt::LeftButton; @@ -586,8 +595,19 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e) return; } buttons = e->buttons; - if (button & e->buttons) - type = QEvent::MouseButtonPress; + if (button & e->buttons) { + if ((e->timestamp - mousePressTime) < static_cast(QApplication::doubleClickInterval()) && button == mousePressButton) { + type = QEvent::MouseButtonDblClick; + mousePressButton = Qt::NoButton; + } + else { + type = QEvent::MouseButtonPress; + mousePressTime = e->timestamp; + mousePressButton = button; + mousePressX = qt_last_x; + mousePressY = qt_last_y; + } + } else type = QEvent::MouseButtonRelease; } diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 955a3fc..a2bded4 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -68,6 +68,7 @@ #include "QtGui/private/qshortcutmap_p.h" #include #include "QtCore/qpoint.h" +#include #ifdef Q_WS_QWS #include "QtGui/qscreen_qws.h" #include @@ -565,18 +566,20 @@ public: #endif #ifdef Q_WS_LITE + static QTime time; class UserEvent { public: - UserEvent(QWidget *w) { tlw = w; } + UserEvent(QWidget *w, QEvent::Type t, ulong time) { tlw = w; type = t; timestamp = time; } QWidget * tlw; QEvent::Type type; + unsigned long timestamp; }; class MouseEvent : public UserEvent { public: - MouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) - : UserEvent(w){ localPos = local; globalPos = global; buttons = b; type = QEvent::MouseMove; } + MouseEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b) + : UserEvent(w, QEvent::MouseMove, time){ localPos = local; globalPos = global; buttons = b; } QPoint localPos; QPoint globalPos; Qt::MouseButtons buttons; @@ -584,8 +587,8 @@ public: class WheelEvent : public UserEvent { public: - WheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) - : UserEvent(w) { localPos = local; globalPos = global; delta = d; orient = o; type = QEvent::Wheel; } + WheelEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) + : UserEvent(w, QEvent::Wheel, time) { localPos = local; globalPos = global; delta = d; orient = o; } int delta; QPoint localPos; QPoint globalPos; @@ -594,8 +597,8 @@ public: class KeyEvent : public UserEvent { public: - KeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) - :UserEvent(w){ type = t; key = k; unicode = text; repeat = autorep; repeatCount = count; modifiers = mods; } + KeyEvent(QWidget *w, QEvent::Type t, ulong time, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) + :UserEvent(w, t, time){ key = k; unicode = text; repeat = autorep; repeatCount = count; modifiers = mods; } int key; QString unicode; bool repeat; @@ -604,17 +607,29 @@ public: }; static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { - MouseEvent * e = new MouseEvent(w, local, global, b); + handleMouseEvent(w, local, global, b, time.elapsed()); + } + + static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b, ulong timestamp) { + MouseEvent * e = new MouseEvent(w, timestamp, local, global, b); queueUserEvent(e); } static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { - KeyEvent * e = new KeyEvent(w, t, k, mods, text, autorep, count); + handleKeyEvent(w, t, time.elapsed(), k, mods, text, autorep, count); + } + + static void handleKeyEvent(QWidget *w, QEvent::Type t, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { + KeyEvent * e = new KeyEvent(w, t, timestamp, k, mods, text, autorep, count); queueUserEvent(e); } static void handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { - WheelEvent *e = new WheelEvent(w, local, global, d, o); + handleWheelEvent(w, time.elapsed(), local, global, d, o); + } + + static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { + WheelEvent *e = new WheelEvent(w, timestamp, local, global, d, o); queueUserEvent(e); } -- cgit v0.12 From 00de571cfaba6eca36fea49a820b6af7111c450c Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 27 Jan 2010 16:41:37 +0100 Subject: make timestamp the second argument for QApplicationPrivate::handleMouseEvent() --- src/gui/kernel/qapplication_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index a2bded4..0741148 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -610,7 +610,7 @@ public: handleMouseEvent(w, local, global, b, time.elapsed()); } - static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b, ulong timestamp) { + static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { MouseEvent * e = new MouseEvent(w, timestamp, local, global, b); queueUserEvent(e); } -- cgit v0.12 From 5a14ca2ad6c601eeff4ed24085d10a7a57b9ebd9 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 27 Jan 2010 16:47:35 +0100 Subject: make timestamp the second argument ... part 2 --- src/gui/kernel/qapplication_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 0741148..75bc5bd 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -607,7 +607,7 @@ public: }; static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { - handleMouseEvent(w, local, global, b, time.elapsed()); + handleMouseEvent(w, time.elapsed(), local, global, b); } static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { -- cgit v0.12 From 03d4a4c11688e0338cad713c2b50aec4122824d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 28 Jan 2010 10:04:14 +0100 Subject: Minimaldfb: Make sure the right blitter is used in the windowsurface --- .../minimaldfb/qwindowsurface_minimaldfb.cpp | 19 +++++++++++-------- .../minimaldfb/qwindowsurface_minimaldfb.h | 2 -- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 4be61df..1cb33f7 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -66,7 +66,7 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QDirectFbGraphicsSystemScreen *sc qDebug() << "WindowSurface format " << QDirectFbConvenience::imageFormatFromSurfaceFormat(format,caps); - blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); + QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); m_pmdata->setBlittable(blitter); m_pixmap = new QPixmap(m_pmdata); @@ -88,7 +88,8 @@ void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const Q_UNUSED(widget); Q_UNUSED(offset); - blitter->unlock(); + m_pmdata->blittable()->unlock(); + const quint8 windowOpacity = quint8(widget->windowOpacity() * 0xff); m_dfbWindow->SetOpacity(m_dfbWindow,windowOpacity); @@ -102,16 +103,16 @@ void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const void QDirectFbWindowSurface::setGeometry(const QRect &rect) { - blitter->unlock(); + m_pmdata->blittable()->unlock(); + QWindowSurface::setGeometry(rect); m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), rect.width(), rect.height()); //Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable m_dfbSurface->AddRef(m_dfbSurface); - QBlittable *blittabler = new QDirectFbBlitter(rect,m_dfbSurface); - m_pmdata->setBlittable(blittabler); - + QDirectFbBlitter *blitter = new QDirectFbBlitter(rect,m_dfbSurface); + m_pmdata->setBlittable(blitter); } static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) @@ -124,7 +125,8 @@ static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) { - blitter->unlock(); + m_pmdata->blittable()->unlock(); + if (!m_dfbSurface || area.isEmpty()) return false; m_dfbSurface->SetBlittingFlags(m_dfbSurface, DSBLIT_NOFX); @@ -152,7 +154,8 @@ void QDirectFbWindowSurface::endPaint(const QRegion ®ion) void QDirectFbWindowSurface::setVisible(bool visible) { - blitter->unlock(); + m_pmdata->blittable()->unlock(); + if (visible) { int x = this->geometry().x(); int y = this->geometry().y(); diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h index 088aeba..f74fb29 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h @@ -50,7 +50,6 @@ QT_BEGIN_NAMESPACE class QDirectFbGraphicsSystemScreen; -class QDirectFbBlitter; class QDirectFbWindowSurface : public QWindowSurface { @@ -81,7 +80,6 @@ private: IDirectFBWindow *m_dfbWindow; IDirectFBSurface *m_dfbSurface; - QDirectFbBlitter *blitter; }; QT_END_NAMESPACE -- cgit v0.12 From 85e565c76d6a37d8231e8136d80d85e5fa0608ee Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 28 Jan 2010 11:23:46 +0100 Subject: glib event loop: check that an event is still available before fetching it --- src/gui/kernel/qeventdispatcher_glib_lite.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/kernel/qeventdispatcher_glib_lite.cpp b/src/gui/kernel/qeventdispatcher_glib_lite.cpp index b8d2a5b..6d80823 100644 --- a/src/gui/kernel/qeventdispatcher_glib_lite.cpp +++ b/src/gui/kernel/qeventdispatcher_glib_lite.cpp @@ -76,9 +76,8 @@ static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer) { GUserEventSource * source = reinterpret_cast(s); - int i = QApplicationPrivate::userEventsQueued(); QApplicationPrivate::UserEvent * event; - while (i--) { + while (QApplicationPrivate::userEventsQueued()) { event = QApplicationPrivate::getUserEvent(); // send through event filter -- cgit v0.12 From 8733fcea9b9d9d587733613ee116549af0b5f8b5 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 28 Jan 2010 13:35:05 +0100 Subject: Don't crash when mouse grabber widget gets deleted --- src/gui/kernel/qapplication_lite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 42932ba..efabf14 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -555,7 +555,7 @@ void QApplicationPrivate::handleLeaveEvent(QWidget *tlw) void QApplicationPrivate::processMouseEvent(MouseEvent *e) { // qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons(); - static QWidget *implicit_mouse_grabber=0; + static QPointer implicit_mouse_grabber; QEvent::Type type; // move first -- cgit v0.12 From 77dadcc0824ba4c4900f6f3e3290772800ec1719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 28 Jan 2010 14:30:38 +0100 Subject: Minimaldfb: Making sure removing tlw doesn't cause crash --- .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 25 ++++++++++- .../graphicssystems/minimaldfb/qdirectfbinput.h | 5 ++- .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 48 ++-------------------- .../minimaldfb/qgraphicssystem_minimaldfb.h | 4 -- .../minimaldfb/qwindowsurface_minimaldfb.cpp | 43 ++++++++++++++----- .../minimaldfb/qwindowsurface_minimaldfb.h | 4 +- 6 files changed, 63 insertions(+), 66 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 8809536..8e288ba 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -42,8 +42,17 @@ void InputSocketWaiter::run() m_cleanupMutex.unlock(); } -QDirectFbInput::QDirectFbInput(QObject *parent) - : QObject(parent) +QDirectFbInput *QDirectFbInput::instance() +{ + static QDirectFbInput *input = 0; + if (!input) { + input = new QDirectFbInput(); + } + return input; +} + +QDirectFbInput::QDirectFbInput() + : QObject() { dfbInterface = QDirectFbConvenience::dfbInterface(); @@ -68,6 +77,18 @@ void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) window->AttachEventBuffer(window,eventBuffer); } +void QDirectFbInput::removeWindow(QWidget *tlw) +{ + DFBWindowID id = tlwMap.key(tlw,0); + if (id) { + IDirectFBWindow *window; + dfbDisplayLayer->GetWindow(dfbDisplayLayer,id, &window); + + window->DetachEventBuffer(window,eventBuffer); + tlwMap.remove(id); + } +} + void QDirectFbInput::handleEvents() { DFBResult hasEvent = eventBuffer->HasEvent(eventBuffer); diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h index 74ccee2..31aa082 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h @@ -33,15 +33,16 @@ class QDirectFbInput : public QObject { Q_OBJECT public: - QDirectFbInput(QObject *parent = 0); - + static QDirectFbInput *instance(); void addWindow(DFBWindowID id, QWidget *tlw); + void removeWindow(QWidget *tlw); public slots: void handleEvents(); void applicationEnd(); private: + QDirectFbInput(); void handleMouseEvents(const DFBEvent &event); void handleWheelEvent(const DFBEvent &event); diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp index 06ae800..4489e31 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(int display) - :QGraphicsSystemScreen() , m_input(this) + :QGraphicsSystemScreen() { m_layer = QDirectFbConvenience::dfbDisplayLayer(display); m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); @@ -64,56 +64,19 @@ QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(int display) m_layer->GetConfiguration(m_layer, &config); m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps); - qDebug() << QDirectFbConvenience::pixelFomatHasAlpha(config.pixelformat); - qDebug() << QDirectFbConvenience::colorDepthForSurface(config.pixelformat); - qDebug() << "GraphcisSystemScreen has format: " << m_format; m_geometry = QRect(0,0,config.width,config.height); const int dpi = 72; const qreal inch = 25.4; m_depth = 32; m_physicalSize = QSize(qRound(config.width * inch / dpi), qRound(config.height *inch / dpi)); + + cursor = new QDirectFBCursor(this); } QDirectFbGraphicsSystemScreen::~QDirectFbGraphicsSystemScreen() { } -IDirectFBWindow *QDirectFbGraphicsSystemScreen::createWindow(const QRect &rect, QWidget *tlw) -{ - IDirectFBWindow *window; - - DFBWindowDescription description; - memset(&description,0,sizeof(DFBWindowDescription)); - description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS -#if DIRECTFB_MINOR_VERSION >= 1 - |DWDESC_OPTIONS -#endif - |DWDESC_CAPS); - description.width = rect.width(); - description.height = rect.height(); - description.posx = rect.x(); - description.posy = rect.y(); -#if DIRECTFB_MINOR_VERSION >= 1 - description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); -#endif - description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL); - description.surface_caps = DSCAPS_PREMULTIPLIED; - - DFBResult result = m_layer->CreateWindow(m_layer,&description,&window); - if (result != DFB_OK) { - DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); - } - - DFBWindowID id; - window->GetID(window, &id); - m_input.addWindow(id,tlw); - - cursor = new QDirectFBCursor(this); - - return window; -} - - QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() { const QStringList args = QCoreApplication::arguments(); @@ -130,9 +93,6 @@ QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() } delete[] argv; - //init directfb - QDirectFbConvenience::dfbInterface(); - mPrimaryScreen = new QDirectFbGraphicsSystemScreen(0); mScreens.append(mPrimaryScreen); } @@ -147,7 +107,7 @@ QPixmapData *QDirectFbGraphicsSystem::createPixmapData(QPixmapData::PixelType ty QWindowSurface *QDirectFbGraphicsSystem::createWindowSurface(QWidget *widget) const { - return new QDirectFbWindowSurface (mPrimaryScreen, widget); + return new QDirectFbWindowSurface (widget); } QBlittable *QDirectFbGraphicsSystem::createBlittable(const QRect &rect) const diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h index 892bc58..b16153d 100644 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h @@ -63,16 +63,12 @@ public: QImage::Format format() const { return m_format; } QSize physicalSize() const { return m_physicalSize; } - IDirectFBWindow *createWindow(const QRect &,QWidget *tlw); - public: QRect m_geometry; int m_depth; QImage::Format m_format; QSize m_physicalSize; - QDirectFbInput m_input; - IDirectFBDisplayLayer *m_layer; private: diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 1cb33f7..9a424cd 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -49,23 +49,43 @@ QT_BEGIN_NAMESPACE -QDirectFbWindowSurface::QDirectFbWindowSurface(QDirectFbGraphicsSystemScreen *screen, QWidget *window) - : QWindowSurface(window), m_screen(screen), m_pixmap(0), m_pmdata(0), +QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window) + : QWindowSurface(window), m_pixmap(0), m_pmdata(0), m_dfbWindow(0), m_dfbSurface(0) { window->setWindowSurface(this); - m_dfbWindow = m_screen->createWindow(window->rect(),window); - m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); - DFBSurfaceCapabilities caps; - m_dfbSurface->GetCapabilities(m_dfbSurface, &caps); - DFBSurfacePixelFormat format; - m_dfbSurface->GetPixelFormat(m_dfbSurface, &format); - qDebug() << QDirectFbConvenience::pixelFomatHasAlpha(format); - qDebug() << QDirectFbConvenience::colorDepthForSurface(format); - qDebug() << "WindowSurface format " << QDirectFbConvenience::imageFormatFromSurfaceFormat(format,caps); + DFBWindowDescription description; + memset(&description,0,sizeof(DFBWindowDescription)); + description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS +#if DIRECTFB_MINOR_VERSION >= 1 + |DWDESC_OPTIONS +#endif + |DWDESC_CAPS); + description.width = window->rect().width(); + description.height = window->rect().height(); + description.posx = window->rect().x(); + description.posy = window->rect().y(); +#if DIRECTFB_MINOR_VERSION >= 1 + description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); +#endif + description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL); + description.surface_caps = DSCAPS_PREMULTIPLIED; + + IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); + DFBResult result = layer->CreateWindow(layer,&description,&m_dfbWindow); + if (result != DFB_OK) { + DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); + } + + DFBWindowID id; + m_dfbWindow->GetID(m_dfbWindow, &id); + QDirectFbInput::instance()->addWindow(id,window); + + m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); + QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); m_pmdata->setBlittable(blitter); @@ -76,6 +96,7 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QDirectFbGraphicsSystemScreen *sc QDirectFbWindowSurface::~QDirectFbWindowSurface() { + QDirectFbInput::instance()->removeWindow(this->window()); } QPaintDevice *QDirectFbWindowSurface::paintDevice() diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h index f74fb29..f6d48c6 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h @@ -54,8 +54,7 @@ class QDirectFbGraphicsSystemScreen; class QDirectFbWindowSurface : public QWindowSurface { public: - QDirectFbWindowSurface - (QDirectFbGraphicsSystemScreen *screen, QWidget *window); + QDirectFbWindowSurface(QWidget *window); ~QDirectFbWindowSurface(); QPaintDevice *paintDevice(); @@ -74,7 +73,6 @@ public: private: void lockSurfaceToImage(); - QDirectFbGraphicsSystemScreen *m_screen; QPixmap *m_pixmap; QBlittablePixmapData *m_pmdata; -- cgit v0.12 From 112a81b92ed7a45c9d1ae461eb6aa61e0ca45e8f Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 28 Jan 2010 15:59:05 +0100 Subject: Fix keyboard modifier state. --- .../testlite/qwindowsurface_testlite.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 26a7675..cbb720e 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -562,6 +562,22 @@ static int lookupCode(unsigned int xkeycode) } +static Qt::KeyboardModifiers modifierFromKeyCode(int qtcode) +{ + switch (qtcode) { + case Qt::Key_Control: + return Qt::ControlModifier; + case Qt::Key_Alt: + return Qt::AltModifier; + case Qt::Key_Shift: + return Qt::ShiftModifier; + case Qt::Key_Meta: + return Qt::MetaModifier; + default: + return Qt::NoModifier; + } +} + void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) { XKeyEvent *e = static_cast(ev); @@ -581,6 +597,10 @@ void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) int qtcode = lookupCode(keySym); // qDebug() << "lookup: " << hex << keySym << qtcode << "mod" << modifiers; + //X11 specifies state *before*, Qt expects state *after* the event + + modifiers ^= modifierFromKeyCode(qtcode); + if (qtcode) { QApplicationPrivate::handleKeyEvent(window(), type, qtcode, modifiers); } else if (chars[0]) { -- cgit v0.12 From ceb4feb8f5c65aa15213bc01dbf1268f3bc7119e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 28 Jan 2010 17:36:51 +0100 Subject: Make tlw update when resizing --- src/gui/kernel/qwidget_lite.cpp | 2 ++ .../graphicssystems/testlite/qwindowsurface_testlite.cpp | 14 +------------- .../graphicssystems/testlite/qwindowsurface_testlite.h | 1 - 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 8601855..3913708 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -507,6 +507,8 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (isResize) { QResizeEvent e(r.size(), olds); QApplication::sendEvent(q, &e); + if (q->isWindow()) + q->update(); } } else { // not visible if (isMove && q->pos() != oldPos) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index cbb720e..65407fd 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -90,24 +90,13 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const } -void QTestLiteWindowSurface::geometryChanged(const QRect &rect) -{ - bool resize = rect.size() != geometry().size(); - QWindowSurface::setGeometry(rect); - - if (resize) { - window()->update(); //### this is the wrong place for this... - } -} - - void QTestLiteWindowSurface::setGeometry(const QRect &rect) { QRect oldRect = geometry(); if (rect == oldRect) return; - QTestLiteWindowSurface::geometryChanged(rect); + QWindowSurface::setGeometry(rect); //if unchanged ### // xw->setSize(rect.width(), rect.height()); @@ -276,7 +265,6 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) void QTestLiteWindowSurface::handleGeometryChange(int x, int y, int w, int h) { - geometryChanged(QRect(x,y,w,h)); QApplicationPrivate::handleGeometryChange(window(), QRect(x,y,w,h)); } diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h index 9f9f052..0c4df1a 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h @@ -62,7 +62,6 @@ public: QPaintDevice *paintDevice(); void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); void setGeometry(const QRect &rect); - void geometryChanged(const QRect &rect); bool scroll(const QRegion &area, int dx, int dy); void beginPaint(const QRegion ®ion); -- cgit v0.12 From 990968b87ef6bee329ba23227b78bac0e58bdd02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 28 Jan 2010 17:38:18 +0100 Subject: minimaldfb: cleanup in dfb. Not using the DWET_DESTROY event yet in the input driver --- .../graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 9a424cd..422ed14 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -82,21 +82,18 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window) m_dfbWindow->GetID(m_dfbWindow, &id); QDirectFbInput::instance()->addWindow(id,window); - - m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); m_pmdata->setBlittable(blitter); m_pixmap = new QPixmap(m_pmdata); - - } QDirectFbWindowSurface::~QDirectFbWindowSurface() { QDirectFbInput::instance()->removeWindow(this->window()); + m_dfbWindow->Destroy(m_dfbWindow); } QPaintDevice *QDirectFbWindowSurface::paintDevice() @@ -106,9 +103,6 @@ QPaintDevice *QDirectFbWindowSurface::paintDevice() void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { - Q_UNUSED(widget); - Q_UNUSED(offset); - m_pmdata->blittable()->unlock(); const quint8 windowOpacity = quint8(widget->windowOpacity() * 0xff); -- cgit v0.12 From edd4a524c19283674402a7f0611e391358a5cdb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 1 Feb 2010 12:28:36 +0100 Subject: Send events to popups --- src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index 422ed14..d2b038c 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -188,7 +188,6 @@ void QDirectFbWindowSurface::setVisible(bool visible) Qt::WindowFlags QDirectFbWindowSurface::setWindowFlags(Qt::WindowFlags flags) { switch (flags & Qt::WindowType_Mask) { - case Qt::Popup: case Qt::ToolTip: { DFBWindowOptions options; m_dfbWindow->GetOptions(m_dfbWindow,&options); -- cgit v0.12 From 6fe259f696b5cc302bda6befcefe0a94e2676325 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 1 Feb 2010 11:38:03 +0100 Subject: QWeakPointer is the new QPointer --- src/gui/kernel/qapplication_lite.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index efabf14..8bbc756 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -555,7 +555,7 @@ void QApplicationPrivate::handleLeaveEvent(QWidget *tlw) void QApplicationPrivate::processMouseEvent(MouseEvent *e) { // qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons(); - static QPointer implicit_mouse_grabber; + static QWeakPointer implicit_mouse_grabber; QEvent::Type type; // move first @@ -616,7 +616,7 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e) //popup mouse handling is magical... mouseWindow = qApp->activePopupWidget(); - implicit_mouse_grabber = 0; + implicit_mouse_grabber.clear(); //### how should popup mode and implicit mouse grab interact? } else if (e->tlw && app_do_modal && !qt_try_modal(e->tlw, e->type) ) { @@ -657,7 +657,7 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e) Q_ASSERT(mouseWindow); mouseWindow->activateWindow(); //focus } else if (implicit_mouse_grabber) { - mouseWidget = implicit_mouse_grabber; + mouseWidget = implicit_mouse_grabber.data(); mouseWindow = mouseWidget->window(); if (mouseWindow != e->tlw) localPoint = mouseWindow->mapFromGlobal(globalPoint); @@ -670,7 +670,7 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e) if (buttons == Qt::NoButton) { //qDebug() << "resetting mouse grabber"; - implicit_mouse_grabber = 0; + implicit_mouse_grabber.clear(); } if (mouseWidget != qt_last_mouse_receiver) { -- cgit v0.12 From f4588871d38d244c83e50354da66d145ae40be8f Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 1 Feb 2010 13:42:56 +0100 Subject: Change mouse, key, and wheel events to use a window id instead of a pointer to a QWidget --- src/gui/kernel/qapplication_lite.cpp | 29 ++++++++++++++------ src/gui/kernel/qapplication_p.h | 32 +++++++++++----------- .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 18 +++++++----- .../testlite/qwindowsurface_testlite.cpp | 8 +++--- 4 files changed, 51 insertions(+), 36 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 8bbc756..39cc29f 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -561,14 +561,20 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e) // move first Qt::MouseButtons stateChange = e->buttons ^ buttons; if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) { - MouseEvent * newMouseEvent = new MouseEvent(e->tlw, e->timestamp, e->localPos, e->globalPos, e->buttons); + MouseEvent * newMouseEvent = new MouseEvent(e->id, e->timestamp, e->localPos, e->globalPos, e->buttons); userEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop stateChange = Qt::NoButton; } + QWidget * tlw; + if (e->id) + tlw = QWidget::find(e->id); + else + tlw = 0; + QPoint localPoint = e->localPos; QPoint globalPoint = e->globalPos; - QWidget *mouseWindow = e->tlw; + QWidget *mouseWindow = tlw; Qt::MouseButton button = Qt::NoButton; @@ -619,11 +625,11 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e) implicit_mouse_grabber.clear(); //### how should popup mode and implicit mouse grab interact? - } else if (e->tlw && app_do_modal && !qt_try_modal(e->tlw, e->type) ) { + } else if (tlw && app_do_modal && !qt_try_modal(tlw, e->type) ) { //even if we're blocked by modality, we should deliver the mouse release event.. //### this code is not completely correct: multiple buttons can be pressed simultaneously if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) { - qDebug() << "modal blocked mouse event to" << e->tlw; + qDebug() << "modal blocked mouse event to" << tlw; return; } } @@ -636,7 +642,7 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e) if (!mouseWindow && !implicit_mouse_grabber) mouseWindow = QApplication::desktop(); - if (mouseWindow && mouseWindow != e->tlw) { + if (mouseWindow && mouseWindow != tlw) { //we did not get a sensible localPoint from the window system, so let's calculate it localPoint = mouseWindow->mapFromGlobal(globalPoint); } @@ -659,7 +665,7 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e) } else if (implicit_mouse_grabber) { mouseWidget = implicit_mouse_grabber.data(); mouseWindow = mouseWidget->window(); - if (mouseWindow != e->tlw) + if (mouseWindow != tlw) localPoint = mouseWindow->mapFromGlobal(globalPoint); } @@ -705,7 +711,11 @@ void QApplicationPrivate::processWheelEvent(WheelEvent *e) qt_last_x = globalPoint.x(); qt_last_y = globalPoint.y(); - QWidget *mouseWindow = e->tlw; + QWidget *mouseWindow; + if (e->id) + mouseWindow = QWidget::find(e->id); + else + mouseWindow = 0; // find the tlw if we didn't get it from the plugin if (!mouseWindow) { @@ -746,8 +756,9 @@ void QApplicationPrivate::processKeyEvent(KeyEvent *e) } if (!focusW) focusW = QApplication::focusWidget(); - if (!focusW) - focusW = e->tlw; + if (!focusW && e->id) { + focusW = QWidget::find(e->id); + } if (!focusW) focusW = QApplication::activeWindow(); diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 75bc5bd..d07b83b 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -570,16 +570,16 @@ public: class UserEvent { public: - UserEvent(QWidget *w, QEvent::Type t, ulong time) { tlw = w; type = t; timestamp = time; } - QWidget * tlw; + UserEvent(WId w, ulong time, QEvent::Type t) { id = w; type = t; timestamp = time; } + WId id; QEvent::Type type; unsigned long timestamp; }; class MouseEvent : public UserEvent { public: - MouseEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b) - : UserEvent(w, QEvent::MouseMove, time){ localPos = local; globalPos = global; buttons = b; } + MouseEvent(WId w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b) + : UserEvent(w, time, QEvent::MouseMove){ localPos = local; globalPos = global; buttons = b; } QPoint localPos; QPoint globalPos; Qt::MouseButtons buttons; @@ -587,8 +587,8 @@ public: class WheelEvent : public UserEvent { public: - WheelEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) - : UserEvent(w, QEvent::Wheel, time) { localPos = local; globalPos = global; delta = d; orient = o; } + WheelEvent(WId w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) + : UserEvent(w, time, QEvent::Wheel) { localPos = local; globalPos = global; delta = d; orient = o; } int delta; QPoint localPos; QPoint globalPos; @@ -597,8 +597,8 @@ public: class KeyEvent : public UserEvent { public: - KeyEvent(QWidget *w, QEvent::Type t, ulong time, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) - :UserEvent(w, t, time){ key = k; unicode = text; repeat = autorep; repeatCount = count; modifiers = mods; } + KeyEvent(WId w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) + :UserEvent(w, time, t){ key = k; unicode = text; repeat = autorep; repeatCount = count; modifiers = mods; } int key; QString unicode; bool repeat; @@ -606,29 +606,29 @@ public: Qt::KeyboardModifiers modifiers; }; - static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { + static void handleMouseEvent(WId w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { handleMouseEvent(w, time.elapsed(), local, global, b); } - static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { + static void handleMouseEvent(WId w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { MouseEvent * e = new MouseEvent(w, timestamp, local, global, b); queueUserEvent(e); } - static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { - handleKeyEvent(w, t, time.elapsed(), k, mods, text, autorep, count); + static void handleKeyEvent(WId w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { + handleKeyEvent(w, time.elapsed(), t, k, mods, text, autorep, count); } - static void handleKeyEvent(QWidget *w, QEvent::Type t, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { - KeyEvent * e = new KeyEvent(w, t, timestamp, k, mods, text, autorep, count); + static void handleKeyEvent(WId w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { + KeyEvent * e = new KeyEvent(w, timestamp, t, k, mods, text, autorep, count); queueUserEvent(e); } - static void handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { + static void handleWheelEvent(WId w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { handleWheelEvent(w, time.elapsed(), local, global, d, o); } - static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { + static void handleWheelEvent(WId w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { WheelEvent *e = new WheelEvent(w, timestamp, local, global, d, o); queueUserEvent(e); } diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 8e288ba..6229b46 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -137,13 +137,14 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) IDirectFBWindow *window; layer->GetWindow(layer,event.window.window_id,&window); + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + timestamp /= 1000; + if (event.window.type == DWET_BUTTONDOWN) { static long prevTime = 0; static QWidget *prevWindow; static int prevX = -999; static int prevY = -999; - long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); - timestamp /= 1000; if (tlw == prevWindow && timestamp - prevTime < QApplication::doubleClickInterval() && qAbs(event.window.cx - prevX) < 5 && qAbs(event.window.cy - prevY) < 5) { @@ -161,7 +162,7 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) window->UngrabPointer(window); } - QApplicationPrivate::handleMouseEvent(tlw, p, globalPos, buttons); + QApplicationPrivate::handleMouseEvent(event.window.window_id, timestamp, p, globalPos, buttons); } void QDirectFbInput::applicationEnd() @@ -174,9 +175,10 @@ void QDirectFbInput::handleWheelEvent(const DFBEvent &event) { QPoint p(event.window.cx, event.window.cy); QPoint globalPos = globalPoint(event); - QWidget *tlw = tlwMap.value(event.window.window_id); + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + timestamp /= 1000; - QApplicationPrivate::handleWheelEvent(tlw, p, globalPos, + QApplicationPrivate::handleWheelEvent(event.window.window_id, timestamp, p, globalPos, event.window.step*120, Qt::Vertical); } @@ -187,8 +189,10 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event) Qt::Key key = QDirectFbConvenience::keyMap()->value(event.window.key_symbol); Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers); - QWidget *tlw = tlwMap.value(event.window.window_id); - QApplicationPrivate::handleKeyEvent(tlw, type, key, modifiers, QChar(event.window.key_symbol)); + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + timestamp /= 1000; + + QApplicationPrivate::handleKeyEvent(event.window.window_id, timestamp, type, key, modifiers, QChar(event.window.key_symbol)); } void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 65407fd..0d277b8 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -243,7 +243,7 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) bool hor = (((e->button == Button4 || e->button == Button5) && (modifiers & Qt::AltModifier)) || (e->button == 6 || e->button == 7)); - QApplicationPrivate::handleWheelEvent(window(), + QApplicationPrivate::handleWheelEvent(winId(), e->time, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), delta, hor ? Qt::Horizontal : Qt::Vertical); @@ -256,7 +256,7 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) buttons ^= button; // X event uses state *before*, Qt uses state *after* - QApplicationPrivate::handleMouseEvent(window(), QPoint(e->x, e->y), + QApplicationPrivate::handleMouseEvent(winId(), e->time, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), buttons); @@ -590,12 +590,12 @@ void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) modifiers ^= modifierFromKeyCode(qtcode); if (qtcode) { - QApplicationPrivate::handleKeyEvent(window(), type, qtcode, modifiers); + QApplicationPrivate::handleKeyEvent(winId(), e->time, type, qtcode, modifiers); } else if (chars[0]) { int qtcode = chars.toUpper()[0]; //Not exactly right... if (modifiers & Qt::ControlModifier && qtcode < ' ') qtcode = chars[0] + '@'; - QApplicationPrivate::handleKeyEvent(window(), type, qtcode, modifiers, QString::fromLatin1(chars)); + QApplicationPrivate::handleKeyEvent(winId(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars)); } else { qWarning() << "unknown X keycode" << hex << e->keycode << keySym; } -- cgit v0.12 From 9f761b8d9af22796e7b20fee2a9a464e253cf267 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 1 Feb 2010 16:47:54 +0100 Subject: winId() support for minimaldfb --- .../graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp | 8 ++++++++ .../graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index d2b038c..d51498f 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -212,4 +212,12 @@ void QDirectFbWindowSurface::lower() m_dfbWindow->LowerToBottom(m_dfbWindow); } +WId QDirectFbWindowSurface::winId() const +{ + DFBWindowID id; + m_dfbWindow->GetID(m_dfbWindow, &id); + return WId(id); +} + + QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h index f6d48c6..ca34cbf 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h @@ -70,6 +70,9 @@ public: void raise(); void lower(); + + WId winId() const; + private: void lockSurfaceToImage(); -- cgit v0.12 From 6a34243acbd6960502efefd1af4a560c245301da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 1 Feb 2010 18:30:43 +0100 Subject: minimaldfb: dont send all key presses with character --- src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index 6229b46..cfe1807 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -192,7 +192,11 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event) long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); timestamp /= 1000; - QApplicationPrivate::handleKeyEvent(event.window.window_id, timestamp, type, key, modifiers, QChar(event.window.key_symbol)); + QChar character; + if (DFB_KEY_TYPE(event.window.key_symbol) == DIKT_UNICODE) + character = QChar(event.window.key_symbol); + + QApplicationPrivate::handleKeyEvent(event.window.window_id, timestamp, type, key, modifiers, character); } void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) -- cgit v0.12 From 99ce03ef6c33a670d86706a8a7d701ac25e2e2b5 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 8 Feb 2010 12:53:15 +0100 Subject: Get rid of black flickering on resize --- src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp | 1 + src/plugins/graphicssystems/testlite/x11util.cpp | 9 +++++++-- src/plugins/graphicssystems/testlite/x11util.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index 0d277b8..d50a59e 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -86,6 +86,7 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const // qDebug() << "QTestLiteWindowSurface::flush:" << (long)this; + xw->painted = true; //there is content in the buffer xw->paintEvent(); } diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index 7ad3ed5..20d4241 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -468,7 +468,7 @@ MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) currentCursor = -1; image_info = 0; - + painted = false; } @@ -517,8 +517,11 @@ void MyWindow::closeEvent() void MyWindow::paintEvent() { #ifdef MYX11_DEBUG - qDebug() << "MyWindow::paintEvent" << shm_img.size(); + qDebug() << "MyWindow::paintEvent" << shm_img.size() << painted; #endif + if (!painted) + return; + #ifdef DONT_USE_MIT_SHM // just convert the image every time... if (!shm_img.isNull()) { @@ -596,6 +599,8 @@ void MyWindow::resizeShmImage(int width, int height) Q_ASSERT(shm_attach_status == True); shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, QImage::Format_RGB32 ); + + painted = false; #endif } diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h index 76e029d..184c1ca 100644 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -136,6 +136,7 @@ public: //### QTestLiteWindowSurface *windowSurface; int currentCursor; + bool painted; private: void resizeShmImage(int width, int height); -- cgit v0.12 From ece7ebb01c65ff0930881bff869b99c1f6889fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 5 Feb 2010 12:45:09 +0100 Subject: Second attemt on rasteroverlay in blitterpaintengine --- src/gui/image/qpixmap_blitter.cpp | 106 ++++++++++++++++++++++++++++-- src/gui/image/qpixmap_blitter_p.h | 87 ++++++++++++++++++++++++ src/gui/painting/qpaintengine_blitter.cpp | 97 ++++++++++++--------------- src/gui/painting/qpaintengine_blitter_p.h | 10 ++- 4 files changed, 236 insertions(+), 64 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 6e34fbd..f82a67d 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -1,6 +1,7 @@ #include "qpixmap_blitter_p.h" #include +#include #include #include @@ -11,6 +12,9 @@ static int global_ser_no = 0; QBlittablePixmapData::QBlittablePixmapData(QPixmapData::PixelType type) : QPixmapData(type,BlitterClass), m_engine(0), m_blittable(0) +#ifdef QT_BLITTER_RASTEROVERLAY + ,m_rasterOverlay(0), m_unmergedCopy(0) +#endif //QT_BLITTER_RASTEROVERLAY { setSerialNumber(++global_ser_no); } @@ -19,6 +23,10 @@ QBlittablePixmapData::~QBlittablePixmapData() { delete m_blittable; delete m_engine; +#ifdef QT_BLITTER_RASTEROVERLAY + delete m_rasterOverlay; + delete m_unmergedCopy; +#endif //QT_BLITTER_RASTEROVERLAY } QBlittable *QBlittablePixmapData::blittable() const @@ -132,18 +140,13 @@ void QBlittablePixmapData::fromImage(const QImage &image, Qt::ImageConversionFlags flags) { resize(image.width(),image.height()); + markRasterOverlay(QRect(0,0,w,h)); QImage *thisImg = buffer(); QImage correctFormatPic = image; if (correctFormatPic.format() != thisImg->format()) correctFormatPic = correctFormatPic.convertToFormat(thisImg->format(), flags); - //jl: This does not ALWAYS work as expected :( -// QPainter p(thisImg); -// p.setCompositionMode(QPainter::CompositionMode_Source); -// p.drawImage(0,0,image,flags); - - //So just copy strides by hand uchar *mem = thisImg->bits(); const uchar *bits = correctFormatPic.bits(); int bytesCopied = 0; @@ -163,3 +166,94 @@ QPaintEngine *QBlittablePixmapData::paintEngine() const } return m_engine; } + +#ifdef QT_BLITTER_RASTEROVERLAY + +static bool showRasterOverlay = !qgetenv("QT_BLITTER_RASTEROVERLAY").isEmpty(); + +void QBlittablePixmapData::mergeOverlay() +{ + if (m_unmergedCopy || !showRasterOverlay) + return; + m_unmergedCopy = new QImage(buffer()->copy()); + QPainter p(buffer()); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + p.drawImage(0,0,*overlay()); + p.end(); +} + +void QBlittablePixmapData::unmergeOverlay() +{ + if (!m_unmergedCopy || !showRasterOverlay) + return; + QPainter p(buffer()); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.drawImage(0,0,*m_unmergedCopy); + p.end(); + + delete m_unmergedCopy; + m_unmergedCopy = 0; +} + +QImage *QBlittablePixmapData::overlay() +{ + if (!m_rasterOverlay|| + m_rasterOverlay->size() != QSize(w,h)){ + m_rasterOverlay = new QImage(w,h,QImage::Format_ARGB32_Premultiplied); + m_rasterOverlay->fill(0x00000000); + uint color = (qrand() % 11)+7; + m_overlayColor = QColor(Qt::GlobalColor(color)); + m_overlayColor.setAlpha(0x88); + + } + return m_rasterOverlay; +} + +void QBlittablePixmapData::markRasterOverlayImpl(const QRectF &rect) +{ + if (!showRasterOverlay) + return; + QRectF transformationRect = clipAndTransformRect(rect); + if(!transformationRect.isEmpty()) { + QPainter p(overlay()); + p.setBrush(m_overlayColor); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(transformationRect,QBrush(m_overlayColor)); + } +} + +void QBlittablePixmapData::unmarkRasterOverlayImpl(const QRectF &rect) +{ + if (!showRasterOverlay) + return; + QRectF transformationRect = clipAndTransformRect(rect); + if (!transformationRect.isEmpty()) { + QPainter p(overlay()); + QColor color(0x00,0x00,0x00,0x00); + p.setBrush(color); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(transformationRect,QBrush(color)); + } +} + +QRectF QBlittablePixmapData::clipAndTransformRect(const QRectF &rect) const +{ + QRectF transformationRect = rect; + paintEngine(); + if (m_engine->state()) { + transformationRect = m_engine->state()->matrix.mapRect(rect); + const QClipData *clipData = m_engine->clip(); + if (clipData) { + if (clipData->hasRectClip) { + transformationRect &= clipData->clipRect; + } else if (clipData->hasRegionClip) { + const QVector rects = clipData->clipRegion.rects(); + for (int i = 0; i < rects.size(); i++) { + transformationRect &= rects.at(i); + } + } + } + } + return transformationRect; +} +#endif //QT_BLITTER_RASTEROVERLAY diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index ca834dc..73f80a8 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -23,10 +23,97 @@ public: void fromImage(const QImage &image, Qt::ImageConversionFlags flags); QPaintEngine *paintEngine() const; + + void markRasterOverlay(const QRectF &); + void markRasterOverlay(const QPointF &, const QTextItem &); + void markRasterOverlay(const QVectorPath &); + void markRasterOverlay(const QRect *rects, int rectCount); + void markRasterOverlay(const QRectF *rects, int rectCount); + void unmarkRasterOverlay(const QRectF &); + +#ifdef QT_BLITTER_RASTEROVERLAY + void mergeOverlay(); + void unmergeOverlay(); + QImage *overlay(); + +#endif //QT_BLITTER_RASTEROVERLAY protected: QBlitterPaintEngine *m_engine; QBlittable *m_blittable; +#ifdef QT_BLITTER_RASTEROVERLAY + QImage *m_rasterOverlay; + QImage *m_unmergedCopy; + QColor m_overlayColor; + + void markRasterOverlayImpl(const QRectF &); + void unmarkRasterOverlayImpl(const QRectF &); + QRectF clipAndTransformRect(const QRectF &) const; +#endif //QT_BLITTER_RASTEROVERLAY + }; +inline void QBlittablePixmapData::markRasterOverlay(const QRectF &rect) +{ +#ifdef QT_BLITTER_RASTEROVERLAY + markRasterOverlayImpl(rect); +#else + Q_UNUSED(rect) +#endif +} + +inline void QBlittablePixmapData::markRasterOverlay(const QVectorPath &path) +{ +#ifdef QT_BLITTER_RASTEROVERLAY + markRasterOverlayImpl(path.convertToPainterPath().boundingRect()); +#else + Q_UNUSED(path) +#endif +} + +inline void QBlittablePixmapData::markRasterOverlay(const QPointF &pos, const QTextItem &ti) +{ +#ifdef QT_BLITTER_RASTEROVERLAY + QFontMetricsF fm(ti.font()); + QRectF rect = fm.tightBoundingRect(ti.text()); + rect.moveBottomLeft(pos); + markRasterOverlay(rect); +#else + Q_UNUSED(pos) + Q_UNUSED(ti) +#endif +} + +inline void QBlittablePixmapData::markRasterOverlay(const QRect *rects, int rectCount) +{ +#ifdef QT_BLITTER_RASTEROVERLAY + for (int i = 0; i < rectCount; i++) { + markRasterOverlay(rects[i]); + } +#else + Q_UNUSED(rects) + Q_UNUSED(rectCount) +#endif +} +inline void QBlittablePixmapData::markRasterOverlay(const QRectF *rects, int rectCount) +{ +#ifdef QT_BLITTER_RASTEROVERLAY + for (int i = 0; i < rectCount; i++) { + markRasterOverlay(rects[i]); + } +#else + Q_UNUSED(rects) + Q_UNUSED(rectCount) +#endif +} + +inline void QBlittablePixmapData::unmarkRasterOverlay(const QRectF &rect) +{ +#ifdef QT_BLITTER_RASTEROVERLAY + unmarkRasterOverlayImpl(rect); +#else + Q_UNUSED(rect) +#endif +} + #endif // QPIXMAP_BLITTER_P_H diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 1a1d5e0..0e7c96a 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -19,12 +19,6 @@ #define STATE_CLIPSYS_COMPLEX 0x00010000 #define STATE_CLIP_COMPLEX 0x00020000 -//#define RASTEROVERLAY - -#ifdef RASTEROVERLAY -QColor rasterColor(255,0,0,100); -QBrush rasterBrush(rasterColor); -#endif static inline void updateStateBits(uint *state, uint mask, bool on) { @@ -107,9 +101,10 @@ public: updateStateBits(&fillRectMask, STATE_BRUSH_PATTERN, false); updateStateBits(&fillRectMask, STATE_BRUSH_ALPHA, false); - updateStateBits(&fillRectMask, STATE_PEN_ENABLED, false); + updateStateBits(&fillRectMask, STATE_PEN_ENABLED, true); - updateStateBits(&fillRectMask, STATE_ANTIALIASING, false); + //Sub-pixel aliasing should not be sent to the blitter + updateStateBits(&fillRectMask, STATE_ANTIALIASING, true); updateStateBits(&fillRectMask, STATE_ALPHA, false); updateStateBits(&fillRectMask, STATE_BLENDING_COMPLEX, false); @@ -152,30 +147,31 @@ class QBlitterPaintEnginePrivate : public QPaintEngineExPrivate public: QBlitterPaintEnginePrivate(QBlittablePixmapData *p) : QPaintEngineExPrivate(), + pmData(p), isBlitterLocked(false), hasXForm(false) { - blitter= p->blittable(); raster = new QRasterPaintEngine(p->buffer()); - capabillities = new CapabilitiesToStateMask(blitter->capabilities()); + capabillities = new CapabilitiesToStateMask(pmData->blittable()->capabilities()); } inline void lock() { if (!isBlitterLocked) { - raster->d_func()->rasterBuffer->prepare(blitter->lock()); + raster->d_func()->rasterBuffer->prepare(pmData->blittable()->lock()); isBlitterLocked = true; } } inline void unlock() { if (isBlitterLocked) { - blitter->unlock(); + pmData->blittable()->unlock(); isBlitterLocked = false; } } void fillRect(const QRectF &rect, const QColor &color) { + pmData->unmarkRasterOverlay(rect); QRectF targetRect = rect; if (hasXForm) { targetRect = state->matrix.mapRect(rect); @@ -184,14 +180,14 @@ public: if (clipData) { if (clipData->hasRectClip) { unlock(); - blitter->fillRect(targetRect & clipData->clipRect, color); + pmData->blittable()->fillRect(targetRect & clipData->clipRect, color); } else if (clipData->hasRegionClip) { QVector rects = clipData->clipRegion.rects(); for ( int i = 0; i < rects.size(); i++ ) { QRect intersectRect = rects.at(i).intersected(targetRect.toRect()); if (!intersectRect.isEmpty()) { unlock(); - blitter->fillRect(intersectRect,color); + pmData->blittable()->fillRect(intersectRect,color); } } } @@ -200,11 +196,11 @@ public: && targetRect.width() <= raster->paintDevice()->width() && targetRect.height() <= raster->paintDevice()->height()) { unlock(); - blitter->fillRect(targetRect,color); + pmData->blittable()->fillRect(targetRect,color); } else { QRectF deviceRect(0,0,raster->paintDevice()->width(), raster->paintDevice()->height()); unlock(); - blitter->fillRect(deviceRect&targetRect,color); + pmData->blittable()->fillRect(deviceRect&targetRect,color); } } } @@ -222,7 +218,8 @@ public: qreal deltaRight = target.right() - intersectedRect.right(); source.adjust(-deltaLeft,-deltaTop,deltaRight,deltaBottom); } - blitter->drawPixmap(intersectedRect, pm, source); + pmData->unmarkRasterOverlay(intersectedRect); + pmData->blittable()->drawPixmap(intersectedRect, pm, source); } void updateClip() { @@ -235,11 +232,10 @@ public: raster->d_func()->systemStateChanged(); } - QPixmap pixmap; QRasterPaintEngine *raster; QRasterPaintEngineState *state; - QBlittable *blitter; + QBlittablePixmapData *pmData; bool isBlitterLocked; CapabilitiesToStateMask *capabillities; @@ -268,8 +264,11 @@ bool QBlitterPaintEngine::begin(QPaintDevice *pdev) d->raster->setSystemRect(systemRect()); d->raster->setSystemClip(systemClip()); - + setActive(true); bool ok = d->raster->begin(pdev); +#ifdef QT_BLITTER_RASTEROVERLAY + d->pmData->unmergeOverlay(); +#endif return ok; } @@ -280,6 +279,10 @@ bool QBlitterPaintEngine::end() d->raster->setPaintDevice(0); d->raster->setActive(false); + setActive(false); +#ifdef QT_BLITTER_RASTEROVERLAY + d->pmData->mergeOverlay(); +#endif return d->raster->end(); } @@ -287,16 +290,13 @@ bool QBlitterPaintEngine::end() void QBlitterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) { Q_D(QBlitterPaintEngine); - if (path.shape() == QVectorPath::RectangleHint) { QRectF rect(((QPointF *) path.points())[0], ((QPointF *) path.points())[2]); fillRect(rect, brush); } else { d->lock(); + d->pmData->markRasterOverlay(path); d->raster->fill(path, brush); -#ifdef RASTEROVERLAY - d->raster->fill(path,rasterBrush); -#endif } } @@ -307,10 +307,8 @@ void QBlitterPaintEngine::fillRect(const QRectF &rect, const QColor &color) d->fillRect(rect, color); } else { d->lock(); + d->pmData->markRasterOverlay(rect); d->raster->fillRect(rect, color); -#ifdef RASTEROVERLAY - d->raster->fillRect(rect,rasterColor); -#endif } } @@ -354,7 +352,7 @@ void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) int tmpSrcX = srcX + (targetRect.x() - x); int tmpSrcY = srcY + (targetRect.y() - y); QRect srcRect(tmpSrcX,tmpSrcY,targetRect.width(),targetRect.height()); - d->blitter->drawPixmap(targetRect,pm,srcRect); + d->pmData->blittable()->drawPixmap(targetRect,pm,srcRect); } } else if (clipData->hasRegionClip) { QVector clipRects = clipData->clipRegion.rects(); @@ -368,9 +366,9 @@ void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) int tmpSrcX = srcX + (targetRect.x() - x); int tmpSrcY = srcY + (targetRect.y() - y); QRect srcRect(tmpSrcX,tmpSrcY,targetRect.width(),targetRect.height()); - d->blitter->drawPixmap(targetRect,pm,srcRect); + d->pmData->blittable()->drawPixmap(targetRect,pm,srcRect); } - } else Q_ASSERT(false);//should never happen + } x+=blitWidth; if (x>=transformedRect.right()) { x = transformedRect.x(); @@ -382,13 +380,10 @@ void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) } else srcX = 0; } - } else { d->lock(); + d->pmData->markRasterOverlay(rect); d->raster->fillRect(rect, brush); -#ifdef RASTEROVERLAY - d->raster->fillRect(rect,rasterBrush); -#endif } } @@ -397,10 +392,8 @@ void QBlitterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) { Q_D(QBlitterPaintEngine); d->lock(); + d->pmData->markRasterOverlay(path.convertToPainterPath().boundingRect()); d->raster->stroke(path, pen); -#ifdef RASTEROVERLAY - d->raster->stroke(path,QPen(rasterColor)); -#endif } void QBlitterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) @@ -509,10 +502,8 @@ void QBlitterPaintEngine::drawRects(const QRect *rects, int rectCount) d->fillRect(rects[i], qbrush_color(d->state->brush)); } } else { + d->pmData->markRasterOverlay(rects,rectCount); QPaintEngineEx::drawRects(rects, rectCount); -#ifdef RASTEROVERLAY - d->raster->drawRects(rects,rectCount); -#endif } } @@ -524,10 +515,8 @@ void QBlitterPaintEngine::drawRects(const QRectF *rects, int rectCount) d->fillRect(rects[i], qbrush_color(d->state->brush)); } } else { + d->pmData->markRasterOverlay(rects,rectCount); QPaintEngineEx::drawRects(rects, rectCount); -#ifdef RASTEROVERLAY - d->raster->drawRects(rects,rectCount); -#endif } } @@ -557,10 +546,8 @@ void QBlitterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const Q } }else { d->lock(); + d->pmData->markRasterOverlay(r); d->raster->drawPixmap(r, pm, sr); -#ifdef RASTEROVERLAY - d->raster->fillRect(r,rasterColor); -#endif } } @@ -569,10 +556,8 @@ void QBlitterPaintEngine::drawImage(const QRectF &r, const QImage &pm, const QRe { Q_D(QBlitterPaintEngine); d->lock(); + d->pmData->markRasterOverlay(r); d->raster->drawImage(r, pm, sr, flags); -#ifdef RASTEROVERLAY - d->raster->fillRect(r,rasterColor); -#endif } @@ -581,18 +566,14 @@ void QBlitterPaintEngine::drawTextItem(const QPointF &pos, const QTextItem &ti) Q_D(QBlitterPaintEngine); d->lock(); d->raster->drawTextItem(pos, ti); -#ifdef RASTEROVERLAY - QFontMetricsF fm(ti.font()); - QRectF rect = fm.tightBoundingRect(ti.text()); - rect.moveBottomLeft(pos); - d->raster->fillRect(rect, rasterColor); -#endif + d->pmData->markRasterOverlay(pos,ti); } void QBlitterPaintEngine::drawEllipse(const QRectF &r) { Q_D(QBlitterPaintEngine); d->lock(); + d->pmData->markRasterOverlay(r); d->raster->drawEllipse(r); } @@ -616,6 +597,12 @@ void QBlitterPaintEngine::setState(QPainterState *s) d->updateClip(); } +inline QRasterPaintEngine *QBlitterPaintEngine::raster() const +{ + Q_D(const QBlitterPaintEngine); + return d->raster; +} + class QBlittablePrivate { public: diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index cebaf21..2d9add9 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -2,8 +2,8 @@ #define QPAINTENGINE_BLITTER_P_H #include "private/qpaintengineex_p.h" +#include "private/qpaintengine_raster_p.h" -class QRasterPaintEngine; class QBlittablePrivate; class QBlitterPaintEnginePrivate; class QBlittablePixmapData; @@ -89,8 +89,12 @@ public: virtual void setState(QPainterState *s); - inline QPainterState *state() { return static_cast(QPaintEngine::state); } - inline const QPainterState *state() const { return static_cast(QPaintEngine::state); } + inline QPainterState *state() { return raster()->state(); } + inline const QPainterState *state() const { const QPainterState *state = raster()->state(); return state;} + inline const QClipData *clip(){return raster()->d_func()->clip();} + +private: + QRasterPaintEngine *raster() const; }; -- cgit v0.12 From b34f8552e08639cbaa8a3ce4551ae3b738764d25 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 9 Feb 2010 14:46:42 +0100 Subject: winId() for vnc and linuxfb --- src/plugins/graphicssystems/fb_base/fb_base.cpp | 3 +++ src/plugins/graphicssystems/fb_base/fb_base.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index bd8d407..eeaa220 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -221,7 +221,10 @@ QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFb mScreen(screen), visibleFlag(false) { + static QAtomicInt winIdGenerator(1); + mImage = QImage(window->size(), mScreen->format()); + windowId = winIdGenerator.fetchAndAddRelaxed(1); } QGraphicsSystemFbWindowSurface::~QGraphicsSystemFbWindowSurface() diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h index f21cd41..c46a99d 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -64,12 +64,15 @@ public: virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); virtual Qt::WindowFlags windowFlags() const; + WId winId() const { return windowId; } protected: QGraphicsSystemFbScreen *mScreen; QRect oldGeometry; QImage mImage; bool visibleFlag; Qt::WindowFlags flags; + + WId windowId; }; class QGraphicsSystemFbScreen : public QGraphicsSystemScreen -- cgit v0.12 From 5fbf7ba9657527a0cc5d732fa90ce4055ddb5eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 9 Feb 2010 16:23:36 +0100 Subject: Fix release build-error in qpaintengine_blitter.cpp --- src/gui/painting/qpaintengine_blitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 0e7c96a..04d3d5a 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -392,7 +392,7 @@ void QBlitterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) { Q_D(QBlitterPaintEngine); d->lock(); - d->pmData->markRasterOverlay(path.convertToPainterPath().boundingRect()); + d->pmData->markRasterOverlay(path); d->raster->stroke(path, pen); } -- cgit v0.12 From 5e2b09a3dfd09e6bd85754e181a0b9026145a9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 9 Feb 2010 17:24:50 +0100 Subject: Minimaldfb: fixed include error --- src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index cfe1807..c3b5522 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include InputSocketWaiter::InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent) : QThread(parent), m_eventBuffer(eventBuffer),m_shouldStop(false) -- cgit v0.12 From e2ea7ff8e1e7795a34981c17daa5bcff90786653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 10 Feb 2010 10:46:13 +0100 Subject: Added basic fps calculation in qbackingstore --- src/gui/painting/qbackingstore.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index e1f47b5..cb0ff55 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -98,6 +98,21 @@ static inline void qt_flush(QWidget *widget, const QRegion ®ion, QWindowSurfa QWidgetBackingStore::showYellowThing(widget, region, flushUpdate * 10, false); #endif + //The performance hit by doing this should be negligible. However, be aware that + //using this FPS when you have > 1 windowsurface can give you inaccurate FPS + static bool fpsDebug = qgetenv("QT_DEBUG_FPS").toInt(); + if (fpsDebug) { + static QTime time = QTime::currentTime(); + static int frames = 0; + + frames++; + + if(time.elapsed() > 5000) { + double fps = double(frames * 1000) /time.restart(); + fprintf(stderr,"FPS: %.1f\n",fps); + frames = 0; + } + } if (widget != tlw) windowSurface->flush(widget, region, tlwOffset + widget->mapTo(tlw, QPoint())); else -- cgit v0.12 From 175605f736ce76a9c0296aa607a6a82ea6675542 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 8 Feb 2010 12:56:46 +0100 Subject: Don't resize back buffer for every window resize; only do it when we're painting --- .../testlite/qwindowsurface_testlite.cpp | 3 ++- src/plugins/graphicssystems/testlite/x11util.cpp | 22 ++++++++++++++-------- src/plugins/graphicssystems/testlite/x11util.h | 2 ++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index d50a59e..e159106 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -86,7 +86,6 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const // qDebug() << "QTestLiteWindowSurface::flush:" << (long)this; - xw->painted = true; //there is content in the buffer xw->paintEvent(); } @@ -169,11 +168,13 @@ bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) void QTestLiteWindowSurface::beginPaint(const QRegion ®ion) { Q_UNUSED(region); + xw->resizeBuffer(geometry().size()); } void QTestLiteWindowSurface::endPaint(const QRegion ®ion) { Q_UNUSED(region); + xw->painted = true; //there is content in the buffer } diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp index 20d4241..6d2966f 100644 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ b/src/plugins/graphicssystems/testlite/x11util.cpp @@ -599,11 +599,23 @@ void MyWindow::resizeShmImage(int width, int height) Q_ASSERT(shm_attach_status == True); shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, QImage::Format_RGB32 ); - - painted = false; #endif + painted = false; +} + + +void MyWindow::resizeBuffer(QSize s) +{ + if (shm_img.size() != s) + resizeShmImage(s.width(), s.height()); } +QSize MyWindow::bufferSize() const +{ + return shm_img.size(); +} + + void MyWindow::resizeEvent(XConfigureEvent *e) { @@ -620,8 +632,6 @@ void MyWindow::resizeEvent(XConfigureEvent *e) #ifdef MYX11_DEBUG qDebug() << hex << window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height << "img:" << shm_img.size(); #endif - if (shm_img.size() != QSize(width, height)) - resizeShmImage(width, height); windowSurface->handleGeometryChange(xpos, ypos, width, height); } @@ -639,10 +649,6 @@ void MyWindow::setGeometry(int x, int y, int w, int h) qDebug() << "MyWindow::setGeometry" << hex << window << dec << x << y << w << h << "img:" << shm_img.size(); #endif XMoveResizeWindow(xd->display, window, x, y, w, h); - - if (shm_img.size() != QSize(w, h)) { - resizeShmImage(w, h); - } } diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h index 184c1ca..79e7461 100644 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ b/src/plugins/graphicssystems/testlite/x11util.h @@ -137,6 +137,8 @@ public: //### int currentCursor; bool painted; + void resizeBuffer(QSize); + QSize bufferSize() const; private: void resizeShmImage(int width, int height); -- cgit v0.12 From 5dcacb00fd68e6cc2bf3e6a467b603f387cb1a60 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 10 Feb 2010 16:31:13 +0100 Subject: Move user event handling into QWindowSystemInterface class This currently includes mouse, wheel, keyboard, enter, leave, geometry, and close events. Windowing system plugins should limit themselves to the QWindowSystemInterface::handle*Event() methods, as the other methods will likely become private. --- src/gui/embedded/qkbd_qws.cpp | 4 +- src/gui/kernel/kernel.pri | 6 +- src/gui/kernel/qapplication_lite.cpp | 71 +++--------- src/gui/kernel/qapplication_p.h | 104 +++-------------- src/gui/kernel/qeventdispatcher_glib_lite.cpp | 8 +- src/gui/kernel/qeventdispatcher_lite.cpp | 9 +- src/gui/kernel/qwindowsysteminterface.cpp | 112 ++++++++++++++++++ src/gui/kernel/qwindowsysteminterface.h | 129 +++++++++++++++++++++ src/plugins/generic/linuxinput/qlinuxinput.cpp | 10 +- src/plugins/graphicssystems/fb_base/fb_base.cpp | 4 +- .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 42 ++----- .../testlite/qwindowsurface_testlite.cpp | 18 +-- src/plugins/graphicssystems/vnc/qvncserver.cpp | 8 +- 13 files changed, 318 insertions(+), 207 deletions(-) create mode 100644 src/gui/kernel/qwindowsysteminterface.cpp create mode 100644 src/gui/kernel/qwindowsysteminterface.h diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp index 97fb7a0..c4dd6bd 100644 --- a/src/gui/embedded/qkbd_qws.cpp +++ b/src/gui/embedded/qkbd_qws.cpp @@ -54,7 +54,7 @@ #endif #ifdef Q_WS_LITE -#include +#include #include #endif @@ -367,7 +367,7 @@ void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardM QString str; if (unicode != 0xffff) str = QString(unicode); - QApplicationPrivate::handleKeyEvent(0, type, keycode, modifiers, str); + QWindowSystemInterface::handleKeyEvent(0, type, keycode, modifiers, str); #endif } diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index c32b84f..51167d4 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -201,7 +201,8 @@ embedded_lite { HEADERS += \ kernel/qgenericpluginfactory_lite.h \ kernel/qgenericplugin_lite.h \ - kernel/qeventdispatcher_lite_p.h + kernel/qeventdispatcher_lite_p.h \ + kernel/qwindowsysteminterface.h \ SOURCES += \ kernel/qapplication_lite.cpp \ @@ -214,7 +215,8 @@ embedded_lite { kernel/qkeymapper_qws.cpp \ kernel/qsound_lite.cpp \ kernel/qwidget_lite.cpp \ - kernel/qeventdispatcher_lite.cpp + kernel/qeventdispatcher_lite.cpp \ + kernel/qwindowsysteminterface.cpp contains(QT_CONFIG, glib) { SOURCES += \ diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 39cc29f..6142e15 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -59,9 +59,11 @@ #include "private/qgraphicssystem_p.h" #include "qgraphicssystemcursor.h" #include +#include QT_BEGIN_NAMESPACE +QList userEventQueue; static QString appName; static const char *appFont = 0; // application font @@ -75,7 +77,6 @@ int qt_last_x = 0; int qt_last_y = 0; QPointer qt_last_mouse_receiver = 0; -QList QApplicationPrivate::userEventQueue; static Qt::KeyboardModifiers modifiers = Qt::NoModifier; static Qt::MouseButtons buttons = Qt::NoButton; static ulong mousePressTime; @@ -83,23 +84,22 @@ static Qt::MouseButton mousePressButton = Qt::NoButton; static int mousePressX; static int mousePressY; static int mouse_double_click_distance = 5; -QTime QApplicationPrivate::time; -void QApplicationPrivate::processUserEvent(UserEvent *e) +void QApplicationPrivate::processUserEvent(QWindowSystemInterface::UserEvent *e) { switch(e->type) { case QEvent::MouseButtonDblClick: // if mouse event, calculate appropriate widget and local coordinates case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseMove: - QApplicationPrivate::processMouseEvent(static_cast(e)); + QApplicationPrivate::processMouseEvent(static_cast(e)); break; case QEvent::Wheel: - QApplicationPrivate::processWheelEvent(static_cast(e)); + QApplicationPrivate::processWheelEvent(static_cast(e)); break; case QEvent::KeyPress: case QEvent::KeyRelease: - QApplicationPrivate::processKeyEvent(static_cast(e)); + QApplicationPrivate::processKeyEvent(static_cast(e)); break; default: qWarning() << "Unknown user input event type:" << e->type; @@ -524,35 +524,7 @@ void QApplication::setMainWidget(QWidget *mainWidget) } #endif - -//------------------------------------------------------------ -// -// Callback functions for plugins: -// - -/*! - -\a tlw == 0 means that \a ev is in global coords only - - -*/ - - -void QApplicationPrivate::handleEnterEvent(QWidget *tlw) -{ - dispatchEnterLeave(tlw, 0); - qt_last_mouse_receiver = tlw; -} - -void QApplicationPrivate::handleLeaveEvent(QWidget *tlw) -{ - dispatchEnterLeave(0, qt_last_mouse_receiver); - if (!tlw->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen - dispatchEnterLeave(0, tlw); - qt_last_mouse_receiver = 0; -} - -void QApplicationPrivate::processMouseEvent(MouseEvent *e) +void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent *e) { // qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons(); static QWeakPointer implicit_mouse_grabber; @@ -561,16 +533,12 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e) // move first Qt::MouseButtons stateChange = e->buttons ^ buttons; if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) { - MouseEvent * newMouseEvent = new MouseEvent(e->id, e->timestamp, e->localPos, e->globalPos, e->buttons); + QWindowSystemInterface::MouseEvent * newMouseEvent = new QWindowSystemInterface::MouseEvent(e->widget.data(), e->timestamp, e->localPos, e->globalPos, e->buttons); userEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop stateChange = Qt::NoButton; } - QWidget * tlw; - if (e->id) - tlw = QWidget::find(e->id); - else - tlw = 0; + QWidget * tlw = e->widget.data(); QPoint localPoint = e->localPos; QPoint globalPoint = e->globalPos; @@ -701,7 +669,7 @@ void QApplicationPrivate::processMouseEvent(MouseEvent *e) //### there's a lot of duplicated logic here -- refactoring required! -void QApplicationPrivate::processWheelEvent(WheelEvent *e) +void QApplicationPrivate::processWheelEvent(QWindowSystemInterface::WheelEvent *e) { // QPoint localPoint = ev.pos(); QPoint globalPoint = e->globalPos; @@ -711,11 +679,7 @@ void QApplicationPrivate::processWheelEvent(WheelEvent *e) qt_last_x = globalPoint.x(); qt_last_y = globalPoint.y(); - QWidget *mouseWindow; - if (e->id) - mouseWindow = QWidget::find(e->id); - else - mouseWindow = 0; + QWidget *mouseWindow = e->widget.data(); // find the tlw if we didn't get it from the plugin if (!mouseWindow) { @@ -747,7 +711,7 @@ void QApplicationPrivate::processWheelEvent(WheelEvent *e) // Remember, Qt convention is: keyboard state is state *before* -void QApplicationPrivate::processKeyEvent(KeyEvent *e) +void QApplicationPrivate::processKeyEvent(QWindowSystemInterface::KeyEvent *e) { QWidget *focusW = 0; if (self->inPopupMode()) { @@ -756,8 +720,8 @@ void QApplicationPrivate::processKeyEvent(KeyEvent *e) } if (!focusW) focusW = QApplication::focusWidget(); - if (!focusW && e->id) { - focusW = QWidget::find(e->id); + if (!focusW) { + focusW = e->widget.data(); } if (!focusW) focusW = QApplication::activeWindow(); @@ -774,8 +738,7 @@ void QApplicationPrivate::processKeyEvent(KeyEvent *e) QApplication::sendSpontaneousEvent(focusW, &ev); } - -void QApplicationPrivate::handleGeometryChange(QWidget *tlw, const QRect &newRect) +void QApplicationPrivate::processGeometryChange(QWidget *tlw, const QRect &newRect) { QRect cr(tlw->geometry()); @@ -794,11 +757,9 @@ void QApplicationPrivate::handleGeometryChange(QWidget *tlw, const QRect &newRec } } - -void QApplicationPrivate::handleCloseEvent(QWidget *tlw) +void QApplicationPrivate::processCloseEvent(QWidget *tlw) { tlw->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent); } - QT_END_NAMESPACE diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index f6e91f7..273e9ea 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -76,6 +76,9 @@ #ifdef Q_OS_SYMBIAN #include #endif +#ifdef Q_WS_LITE +#include +#endif QT_BEGIN_NAMESPACE @@ -462,6 +465,18 @@ public: static bool qt_mac_apply_settings(); #endif +#ifdef Q_WS_LITE + static void processMouseEvent(QWindowSystemInterface::MouseEvent *e); + static void processKeyEvent(QWindowSystemInterface::KeyEvent *e); + static void processWheelEvent(QWindowSystemInterface::WheelEvent *e); + + static void processCloseEvent(QWidget *tlw); + static void processGeometryChange(QWidget *tlw, const QRect &newRect); + + static void processUserEvent(QWindowSystemInterface::UserEvent *e); + +#endif + #ifdef Q_WS_QWS QPointer last_manager; QWSServerCleaner qwsServerCleaner; @@ -565,91 +580,6 @@ public: void _q_readRX71MultiTouchEvents(); #endif -#ifdef Q_WS_LITE - static QTime time; - - class UserEvent { - public: - UserEvent(WId w, ulong time, QEvent::Type t) { id = w; type = t; timestamp = time; } - WId id; - QEvent::Type type; - unsigned long timestamp; - }; - - class MouseEvent : public UserEvent { - public: - MouseEvent(WId w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b) - : UserEvent(w, time, QEvent::MouseMove){ localPos = local; globalPos = global; buttons = b; } - QPoint localPos; - QPoint globalPos; - Qt::MouseButtons buttons; - }; - - class WheelEvent : public UserEvent { - public: - WheelEvent(WId w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) - : UserEvent(w, time, QEvent::Wheel) { localPos = local; globalPos = global; delta = d; orient = o; } - int delta; - QPoint localPos; - QPoint globalPos; - Qt::Orientation orient; - }; - - class KeyEvent : public UserEvent { - public: - KeyEvent(WId w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) - :UserEvent(w, time, t){ key = k; unicode = text; repeat = autorep; repeatCount = count; modifiers = mods; } - int key; - QString unicode; - bool repeat; - ushort repeatCount; - Qt::KeyboardModifiers modifiers; - }; - - static void handleMouseEvent(WId w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { - handleMouseEvent(w, time.elapsed(), local, global, b); - } - - static void handleMouseEvent(WId w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { - MouseEvent * e = new MouseEvent(w, timestamp, local, global, b); - queueUserEvent(e); - } - - static void handleKeyEvent(WId w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { - handleKeyEvent(w, time.elapsed(), t, k, mods, text, autorep, count); - } - - static void handleKeyEvent(WId w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { - KeyEvent * e = new KeyEvent(w, timestamp, t, k, mods, text, autorep, count); - queueUserEvent(e); - } - - static void handleWheelEvent(WId w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { - handleWheelEvent(w, time.elapsed(), local, global, d, o); - } - - static void handleWheelEvent(WId w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { - WheelEvent *e = new WheelEvent(w, timestamp, local, global, d, o); - queueUserEvent(e); - } - - static void queueUserEvent(UserEvent *ev) { userEventQueue.append(ev); } - static void processUserEvent(UserEvent *e); - static int userEventsQueued() { return userEventQueue.count(); } - static UserEvent * getUserEvent() { return userEventQueue.takeFirst(); } - - // could be private, should only be used by deliverUserEvents() - static void processMouseEvent(MouseEvent *e); - static void processKeyEvent(KeyEvent *e); - static void processWheelEvent(WheelEvent *e); - - // delivered directly by the plugin via spontaneous events - static void handleGeometryChange(QWidget *tlw, const QRect &newRect); - static void handleCloseEvent(QWidget *tlw); - static void handleEnterEvent(QWidget *tlw); - static void handleLeaveEvent(QWidget *tlw); -#endif - #if defined(Q_WS_S60) int maxTouchPressure; QList appAllTouchPoints; @@ -664,10 +594,6 @@ private: static QHash scanCodeCache; #endif -#ifdef Q_WS_LITE - static QList userEventQueue; -#endif - static QApplicationPrivate *self; static void giveFocusAccordingToFocusPolicy(QWidget *w, diff --git a/src/gui/kernel/qeventdispatcher_glib_lite.cpp b/src/gui/kernel/qeventdispatcher_glib_lite.cpp index 6d80823..757bb00 100644 --- a/src/gui/kernel/qeventdispatcher_glib_lite.cpp +++ b/src/gui/kernel/qeventdispatcher_glib_lite.cpp @@ -64,7 +64,7 @@ static gboolean userEventSourcePrepare(GSource *s, gint *timeout) Q_UNUSED(s) Q_UNUSED(timeout) - return QApplicationPrivate::userEventsQueued() > 0; + return QWindowSystemInterface::userEventsQueued() > 0; } static gboolean userEventSourceCheck(GSource *source) @@ -76,9 +76,9 @@ static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer) { GUserEventSource * source = reinterpret_cast(s); - QApplicationPrivate::UserEvent * event; - while (QApplicationPrivate::userEventsQueued()) { - event = QApplicationPrivate::getUserEvent(); + QWindowSystemInterface::UserEvent * event; + while (QWindowSystemInterface::userEventsQueued()) { + event = QWindowSystemInterface::getUserEvent(); // send through event filter if (source->q->filterEvent(event)) { diff --git a/src/gui/kernel/qeventdispatcher_lite.cpp b/src/gui/kernel/qeventdispatcher_lite.cpp index 39eef96..bd177cb 100644 --- a/src/gui/kernel/qeventdispatcher_lite.cpp +++ b/src/gui/kernel/qeventdispatcher_lite.cpp @@ -47,6 +47,7 @@ #ifndef QT_NO_THREAD # include "qmutex.h" #endif +#include #include QT_BEGIN_NAMESPACE @@ -83,11 +84,11 @@ bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags) QApplication::sendPostedEvents(); while (!d->interrupt) { // also flushes output buffer ###can be optimized - QApplicationPrivate::UserEvent *event; + QWindowSystemInterface::UserEvent *event; if (!(flags & QEventLoop::ExcludeUserInputEvents) - && QApplicationPrivate::userEventsQueued() > 0) { + && QWindowSystemInterface::userEventsQueued() > 0) { // process a pending user input event - event = QApplicationPrivate::getUserEvent(); + event = QWindowSystemInterface::getUserEvent(); } else { break; } @@ -112,7 +113,7 @@ bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags) bool QEventDispatcherLite::hasPendingEvents() { extern uint qGlobalPostedEventsCount(); // from qapplication.cpp - return qGlobalPostedEventsCount() || QApplicationPrivate::userEventsQueued();; + return qGlobalPostedEventsCount() || QWindowSystemInterface::userEventsQueued();; } void QEventDispatcherLite::startingUp() diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp new file mode 100644 index 0000000..e051533 --- /dev/null +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** 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 "qwindowsysteminterface.h" +#include "qapplication_p.h" + +QT_BEGIN_NAMESPACE + + +QTime QWindowSystemInterface::eventTime; + +//------------------------------------------------------------ +// +// Callback functions for plugins: +// + +QList QWindowSystemInterface::userEventQueue; + +extern QPointer qt_last_mouse_receiver; +/*! + +\a tlw == 0 means that \a ev is in global coords only + + +*/ + + +void QWindowSystemInterface::handleEnterEvent(QWidget *tlw) +{ + if (tlw) { + QApplicationPrivate::dispatchEnterLeave(tlw, 0); + qt_last_mouse_receiver = tlw; + } +} + +void QWindowSystemInterface::handleLeaveEvent(QWidget *tlw) +{ + QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver); + if (tlw && !tlw->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen + QApplicationPrivate::dispatchEnterLeave(0, tlw); + qt_last_mouse_receiver = 0; +} + +void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect) +{ + if (tlw) + QApplicationPrivate::processGeometryChange(tlw, newRect); +} + + +void QWindowSystemInterface::handleCloseEvent(QWidget *tlw) +{ + if (tlw) + QApplicationPrivate::processCloseEvent(tlw); +} + +void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) +{ + MouseEvent * e = new MouseEvent(tlw, timestamp, local, global, b); + queueUserEvent(e); +} + +void QWindowSystemInterface::handleKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) +{ + KeyEvent * e = new KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count); + queueUserEvent(e); +} + +void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) +{ + WheelEvent *e = new WheelEvent(tlw, timestamp, local, global, d, o); + queueUserEvent(e); +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h new file mode 100644 index 0000000..caeacd3 --- /dev/null +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** 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 QWINDOWSYSTEMINTERFACE_H +#define QWINDOWSYSTEMINTERFACE_H + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class Q_GUI_EXPORT QWindowSystemInterface +{ +public: + class UserEvent { + public: + UserEvent(QWidget * w, ulong time, QEvent::Type t) + { widget = QWeakPointer::QWeakPointer(w); type = t; timestamp = time; } + QWeakPointer widget; + QEvent::Type type; + unsigned long timestamp; + }; + + class MouseEvent : public UserEvent { + public: + MouseEvent(QWidget * w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b) + : UserEvent(w, time, QEvent::MouseMove){ localPos = local; globalPos = global; buttons = b; } + QPoint localPos; + QPoint globalPos; + Qt::MouseButtons buttons; + }; + + class WheelEvent : public UserEvent { + public: + WheelEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) + : UserEvent(w, time, QEvent::Wheel) { localPos = local; globalPos = global; delta = d; orient = o; } + int delta; + QPoint localPos; + QPoint globalPos; + Qt::Orientation orient; + }; + + class KeyEvent : public UserEvent { + 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, t){ key = k; unicode = text; repeat = autorep; repeatCount = count; modifiers = mods; } + int key; + QString unicode; + bool repeat; + ushort repeatCount; + Qt::KeyboardModifiers modifiers; + }; + + static QTime eventTime; + + static int userEventsQueued() { return userEventQueue.count(); } + static UserEvent * getUserEvent() { return userEventQueue.takeFirst(); } + static void queueUserEvent(UserEvent *ev) { userEventQueue.append(ev); } + + +public: + static QList userEventQueue; + + static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { + handleMouseEvent(w, eventTime.elapsed(), local, global, b); + } + + static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b); + + static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { + handleKeyEvent(w, eventTime.elapsed(), t, k, mods, text, autorep, count); + } + + 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 handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { + handleWheelEvent(w, eventTime.elapsed(), local, global, d, o); + } + + static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o); + + // delivered directly by the plugin via spontaneous events + static void handleGeometryChange(QWidget *w, const QRect &newRect); + static void handleCloseEvent(QWidget *w); + static void handleEnterEvent(QWidget *w); + static void handleLeaveEvent(QWidget *w); +}; + +QT_END_NAMESPACE +#endif // QWINDOWSYSTEMINTERFACE_H diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 363e91f..32137ee 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include @@ -141,13 +141,13 @@ void QLinuxInputMouseHandler::readMouseData() } else if (data->code == ABS_WHEEL) { // vertical scroll // data->value: 1 == up, -1 == down int delta = 120 * data->value; - QApplicationPrivate::handleWheelEvent(0, QPoint(m_x, m_y), + QWindowSystemInterface::handleWheelEvent(0, QPoint(m_x, m_y), QPoint(m_x, m_y), delta, Qt::Vertical); } else if (data->code == ABS_THROTTLE) { // horizontal scroll // data->value: 1 == right, -1 == left int delta = 120 * -data->value; - QApplicationPrivate::handleWheelEvent(0, QPoint(m_x, m_y), + QWindowSystemInterface::handleWheelEvent(0, QPoint(m_x, m_y), QPoint(m_x, m_y), delta, Qt::Horizontal); } else { @@ -167,7 +167,7 @@ void QLinuxInputMouseHandler::readMouseData() else m_buttons &= ~button; - QApplicationPrivate::handleMouseEvent(0, QPoint(m_x, m_y), + QWindowSystemInterface::handleMouseEvent(0, QPoint(m_x, m_y), QPoint(m_x, m_y), m_buttons); } else if (data->type == EV_SYN && data->code == SYN_REPORT) { if (!posChanged) @@ -175,7 +175,7 @@ void QLinuxInputMouseHandler::readMouseData() posChanged = false; QPoint pos(m_x, m_y); - QApplicationPrivate::handleMouseEvent(0, pos, pos, m_buttons); + QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons); // pos = m_handler->transform(pos); //m_handler->limitToScreen(pos); diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index eeaa220..6567e95 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -1,10 +1,10 @@ #include "fb_base.h" #include -#include #include #include #include +#include QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen *scr) : QGraphicsSystemCursor(scr), currentRect(QRect()), prevRect(QRect()) @@ -261,7 +261,7 @@ void QGraphicsSystemFbWindowSurface::setGeometry(const QRect &rect) if (mImage.size() != rect.size()) mImage = QImage(rect.size(), mScreen->format()); - QApplicationPrivate::handleGeometryChange(this->window(), rect); + QWindowSystemInterface::handleGeometryChange(window(), rect); QWindowSurface::setGeometry(rect); } diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index c3b5522..74a38a4 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -3,9 +3,10 @@ #include #include -#include +#include #include #include +#include #include @@ -65,7 +66,7 @@ QDirectFbInput::QDirectFbInput() m_inputHandler = new InputSocketWaiter(eventBuffer,this); connect(m_inputHandler,SIGNAL(newEvent()),this,SLOT(handleEvents())); - connect(qApp,SIGNAL(aboutToQuit()),SLOT(applicationEnd())); + connect(QApplication::instance(),SIGNAL(aboutToQuit()),SLOT(applicationEnd())); } void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) @@ -127,42 +128,23 @@ void QDirectFbInput::handleEvents() void QDirectFbInput::handleMouseEvents(const DFBEvent &event) { - QEvent::Type type = QDirectFbConvenience::eventType(event.window.type); QPoint p(event.window.x, event.window.y); QPoint globalPos = globalPoint(event); Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); - QWidget *tlw = tlwMap.value(event.window.window_id); IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); IDirectFBWindow *window; layer->GetWindow(layer,event.window.window_id,&window); long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); - timestamp /= 1000; if (event.window.type == DWET_BUTTONDOWN) { - static long prevTime = 0; - static QWidget *prevWindow; - static int prevX = -999; - static int prevY = -999; - - if (tlw == prevWindow && timestamp - prevTime < QApplication::doubleClickInterval() - && qAbs(event.window.cx - prevX) < 5 && qAbs(event.window.cy - prevY) < 5) { - type = QEvent::MouseButtonDblClick; - prevTime = timestamp - QApplication::doubleClickInterval(); //no double click next time - } else { - prevTime = timestamp; - } - prevWindow = tlw; - prevX = event.window.cx; - prevY = event.window.cy; - window->GrabPointer(window); } else if (event.window.type == DWET_BUTTONUP) { window->UngrabPointer(window); } - - QApplicationPrivate::handleMouseEvent(event.window.window_id, timestamp, p, globalPos, buttons); + QWidget *tlw = tlwMap.value(event.window.window_id); + QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons); } void QDirectFbInput::applicationEnd() @@ -176,9 +158,8 @@ void QDirectFbInput::handleWheelEvent(const DFBEvent &event) QPoint p(event.window.cx, event.window.cy); QPoint globalPos = globalPoint(event); long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); - timestamp /= 1000; - - QApplicationPrivate::handleWheelEvent(event.window.window_id, timestamp, p, globalPos, + QWidget *tlw = tlwMap.value(event.window.window_id); + QWindowSystemInterface::handleWheelEvent(tlw, timestamp, p, globalPos, event.window.step*120, Qt::Vertical); } @@ -190,13 +171,12 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event) Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers); long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); - timestamp /= 1000; QChar character; if (DFB_KEY_TYPE(event.window.key_symbol) == DIKT_UNICODE) character = QChar(event.window.key_symbol); - - QApplicationPrivate::handleKeyEvent(event.window.window_id, timestamp, type, key, modifiers, character); + QWidget *tlw = tlwMap.value(event.window.window_id); + QWindowSystemInterface::handleKeyEvent(tlw, timestamp, type, key, modifiers, character); } void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) @@ -204,10 +184,10 @@ void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) QWidget *tlw = tlwMap.value(event.window.window_id); switch (event.window.type) { case DWET_ENTER: - QApplicationPrivate::handleEnterEvent(tlw); + QWindowSystemInterface::handleEnterEvent(tlw); break; case DWET_LEAVE: - QApplicationPrivate::handleLeaveEvent(tlw); + QWindowSystemInterface::handleLeaveEvent(tlw); break; default: break; diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp index e159106..c54f6eb 100644 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp @@ -43,7 +43,7 @@ #include "qgraphicssystem_testlite.h" #include -#include +#include #include "x11util.h" @@ -245,7 +245,7 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) bool hor = (((e->button == Button4 || e->button == Button5) && (modifiers & Qt::AltModifier)) || (e->button == 6 || e->button == 7)); - QApplicationPrivate::handleWheelEvent(winId(), e->time, + QWindowSystemInterface::handleWheelEvent(window(), e->time, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), delta, hor ? Qt::Horizontal : Qt::Vertical); @@ -258,7 +258,7 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) buttons ^= button; // X event uses state *before*, Qt uses state *after* - QApplicationPrivate::handleMouseEvent(winId(), e->time, QPoint(e->x, e->y), + QWindowSystemInterface::handleMouseEvent(window(), e->time, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), buttons); @@ -267,24 +267,24 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) void QTestLiteWindowSurface::handleGeometryChange(int x, int y, int w, int h) { - QApplicationPrivate::handleGeometryChange(window(), QRect(x,y,w,h)); + QWindowSystemInterface::handleGeometryChange(window(), QRect(x,y,w,h)); } void QTestLiteWindowSurface::handleCloseEvent() { - QApplicationPrivate::handleCloseEvent(window()); + QWindowSystemInterface::handleCloseEvent(window()); } void QTestLiteWindowSurface::handleEnterEvent() { - QApplicationPrivate::handleEnterEvent(window()); + QWindowSystemInterface::handleEnterEvent(window()); } void QTestLiteWindowSurface::handleLeaveEvent() { - QApplicationPrivate::handleLeaveEvent(window()); + QWindowSystemInterface::handleLeaveEvent(window()); } @@ -592,12 +592,12 @@ void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) modifiers ^= modifierFromKeyCode(qtcode); if (qtcode) { - QApplicationPrivate::handleKeyEvent(winId(), e->time, type, qtcode, modifiers); + QWindowSystemInterface::handleKeyEvent(window(), e->time, type, qtcode, modifiers); } else if (chars[0]) { int qtcode = chars.toUpper()[0]; //Not exactly right... if (modifiers & Qt::ControlModifier && qtcode < ' ') qtcode = chars[0] + '@'; - QApplicationPrivate::handleKeyEvent(winId(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars)); + QWindowSystemInterface::handleKeyEvent(window(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars)); } else { qWarning() << "unknown X keycode" << hex << e->keycode << keySym; } diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp index 490ca02..ea576d4 100644 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ b/src/plugins/graphicssystems/vnc/qvncserver.cpp @@ -48,7 +48,7 @@ #include #include -#include +#include #include @@ -844,7 +844,7 @@ void QVNCServer::pointerEvent() bool isPress; if (buttonChange(buttons, ev.buttons, &button, &isPress)) type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - QApplicationPrivate::handleMouseEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), ev.buttons); + QWindowSystemInterface::handleMouseEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), ev.buttons); } else { // No buttons or motion reported at the same time as wheel events Qt::Orientation orientation; @@ -853,7 +853,7 @@ void QVNCServer::pointerEvent() else orientation = Qt::Vertical; int delta = 120 * ((ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelUp) ? 1 : -1); - QApplicationPrivate::handleWheelEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), delta, orientation); + QWindowSystemInterface::handleWheelEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), delta, orientation); } handleMsg = false; } @@ -879,7 +879,7 @@ void QVNCServer::keyEvent() QString str; if (ev.unicode && ev.unicode != 0xffff) str = QString(ev.unicode); - QApplicationPrivate::handleKeyEvent(0, type, ev.keycode, keymod, str); + QWindowSystemInterface::handleKeyEvent(0, type, ev.keycode, keymod, str); } handleMsg = false; } -- cgit v0.12 From e4ba2795e8650a2aeb27b20ddf6d386509247e41 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 12 Feb 2010 16:31:30 +0100 Subject: move methods that shouldn't be used by plugins out of QWindowSystemInterface --- src/gui/kernel/qapplication_lite.cpp | 3 +- src/gui/kernel/qeventdispatcher_glib_lite.cpp | 6 +-- src/gui/kernel/qeventdispatcher_lite.cpp | 6 +-- src/gui/kernel/qwindowsysteminterface.cpp | 8 ++-- src/gui/kernel/qwindowsysteminterface.h | 62 ++++++++++++++------------- 5 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 6142e15..5ca6717 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE -QList userEventQueue; static QString appName; static const char *appFont = 0; // application font @@ -534,7 +533,7 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent * Qt::MouseButtons stateChange = e->buttons ^ buttons; if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) { QWindowSystemInterface::MouseEvent * newMouseEvent = new QWindowSystemInterface::MouseEvent(e->widget.data(), e->timestamp, e->localPos, e->globalPos, e->buttons); - userEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop + QWindowSystemInterfacePrivate::userEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop stateChange = Qt::NoButton; } diff --git a/src/gui/kernel/qeventdispatcher_glib_lite.cpp b/src/gui/kernel/qeventdispatcher_glib_lite.cpp index 757bb00..0cfea8a 100644 --- a/src/gui/kernel/qeventdispatcher_glib_lite.cpp +++ b/src/gui/kernel/qeventdispatcher_glib_lite.cpp @@ -64,7 +64,7 @@ static gboolean userEventSourcePrepare(GSource *s, gint *timeout) Q_UNUSED(s) Q_UNUSED(timeout) - return QWindowSystemInterface::userEventsQueued() > 0; + return QWindowSystemInterfacePrivate::userEventsQueued() > 0; } static gboolean userEventSourceCheck(GSource *source) @@ -77,8 +77,8 @@ static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer) GUserEventSource * source = reinterpret_cast(s); QWindowSystemInterface::UserEvent * event; - while (QWindowSystemInterface::userEventsQueued()) { - event = QWindowSystemInterface::getUserEvent(); + while (QWindowSystemInterfacePrivate::userEventsQueued()) { + event = QWindowSystemInterfacePrivate::getUserEvent(); // send through event filter if (source->q->filterEvent(event)) { diff --git a/src/gui/kernel/qeventdispatcher_lite.cpp b/src/gui/kernel/qeventdispatcher_lite.cpp index bd177cb..d500ad6 100644 --- a/src/gui/kernel/qeventdispatcher_lite.cpp +++ b/src/gui/kernel/qeventdispatcher_lite.cpp @@ -86,9 +86,9 @@ bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags) while (!d->interrupt) { // also flushes output buffer ###can be optimized QWindowSystemInterface::UserEvent *event; if (!(flags & QEventLoop::ExcludeUserInputEvents) - && QWindowSystemInterface::userEventsQueued() > 0) { + && QWindowSystemInterfacePrivate::userEventsQueued() > 0) { // process a pending user input event - event = QWindowSystemInterface::getUserEvent(); + event = QWindowSystemInterfacePrivate::getUserEvent(); } else { break; } @@ -113,7 +113,7 @@ bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags) bool QEventDispatcherLite::hasPendingEvents() { extern uint qGlobalPostedEventsCount(); // from qapplication.cpp - return qGlobalPostedEventsCount() || QWindowSystemInterface::userEventsQueued();; + return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::userEventsQueued();; } void QEventDispatcherLite::startingUp() diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index e051533..d7b5eef 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -51,7 +51,7 @@ QTime QWindowSystemInterface::eventTime; // Callback functions for plugins: // -QList QWindowSystemInterface::userEventQueue; +QList QWindowSystemInterfacePrivate::userEventQueue; extern QPointer qt_last_mouse_receiver; /*! @@ -94,19 +94,19 @@ void QWindowSystemInterface::handleCloseEvent(QWidget *tlw) void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { MouseEvent * e = new MouseEvent(tlw, timestamp, local, global, b); - queueUserEvent(e); + QWindowSystemInterfacePrivate::queueUserEvent(e); } void QWindowSystemInterface::handleKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) { KeyEvent * e = new KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count); - queueUserEvent(e); + QWindowSystemInterfacePrivate::queueUserEvent(e); } void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { WheelEvent *e = new WheelEvent(tlw, timestamp, local, global, d, o); - queueUserEvent(e); + QWindowSystemInterfacePrivate::queueUserEvent(e); } QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index caeacd3..fee7e75 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -48,9 +48,35 @@ #include QT_BEGIN_NAMESPACE + class Q_GUI_EXPORT QWindowSystemInterface { public: + static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { + handleMouseEvent(w, eventTime.elapsed(), local, global, b); + } + + static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b); + + static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { + handleKeyEvent(w, eventTime.elapsed(), t, k, mods, text, autorep, count); + } + + 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 handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { + handleWheelEvent(w, eventTime.elapsed(), local, global, d, o); + } + + static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o); + + // delivered directly by the plugin via spontaneous events + static void handleGeometryChange(QWidget *w, const QRect &newRect); + static void handleCloseEvent(QWidget *w); + static void handleEnterEvent(QWidget *w); + static void handleLeaveEvent(QWidget *w); + + class UserEvent { public: UserEvent(QWidget * w, ulong time, QEvent::Type t) @@ -90,40 +116,18 @@ public: Qt::KeyboardModifiers modifiers; }; +private: static QTime eventTime; - static int userEventsQueued() { return userEventQueue.count(); } - static UserEvent * getUserEvent() { return userEventQueue.takeFirst(); } - static void queueUserEvent(UserEvent *ev) { userEventQueue.append(ev); } - +}; +class QWindowSystemInterfacePrivate { public: - static QList userEventQueue; - - static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { - handleMouseEvent(w, eventTime.elapsed(), local, global, b); - } - - static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b); - - static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { - handleKeyEvent(w, eventTime.elapsed(), t, k, mods, text, autorep, count); - } - - 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 QList userEventQueue; - static void handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { - handleWheelEvent(w, eventTime.elapsed(), local, global, d, o); - } - - static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o); - - // delivered directly by the plugin via spontaneous events - static void handleGeometryChange(QWidget *w, const QRect &newRect); - static void handleCloseEvent(QWidget *w); - static void handleEnterEvent(QWidget *w); - static void handleLeaveEvent(QWidget *w); + static int userEventsQueued() { return userEventQueue.count(); } + static QWindowSystemInterface::UserEvent * getUserEvent() { return userEventQueue.takeFirst(); } + static void queueUserEvent(QWindowSystemInterface::UserEvent *ev) { userEventQueue.append(ev); } }; - QT_END_NAMESPACE #endif // QWINDOWSYSTEMINTERFACE_H -- cgit v0.12 From 939a869b5856d05e8340e64edb66b1f07ba609cd Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 12 Feb 2010 16:32:20 +0100 Subject: make qvfb plugin compile - QApplicationPrivate -> QWindowSystemInterface --- src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp | 10 ++++------ src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp b/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp index 77942c9..19058a6 100644 --- a/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp +++ b/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp @@ -59,7 +59,8 @@ #include #include -#include +#include +#include QT_BEGIN_NAMESPACE @@ -147,8 +148,7 @@ void QVFbGraphicsSystemScreenKeyboardHandler::readKeyboardData() // qDebug() << "readKeyboardData" << type << hex << kd->keycode << kd->modifiers << text; - QKeyEvent ke(type, kd->keycode, kd->modifiers, text, kd->repeat, int(text.length())); - QApplicationPrivate::handleKeyEvent(0, &ke); + QWindowSystemInterface::handleKeyEvent(0, type, kd->keycode, kd->modifiers, text, kd->repeat, int(text.length())); idx += sizeof(QVFbKeyData); } @@ -237,9 +237,7 @@ void QVFbGraphicsSystemScreenMouseHandler::readMouseData() if (button) { type = (button & bstate) ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; } - QMouseEvent me(type, mousePos, mousePos, - Qt::MouseButton(button), Qt::MouseButtons(bstate), Qt::NoModifier); - QApplicationPrivate::handleMouseEvent(0, me); + QWindowSystemInterface::handleMouseEvent(0, mousePos, mousePos, Qt::MouseButtons(bstate)); // qDebug() << "readMouseData" << mousePos << button << bstate << oldButtonState << type; diff --git a/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp b/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp index c49f082..0aafe28 100644 --- a/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp +++ b/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp @@ -81,7 +81,7 @@ void QVFbWindowSurface::setGeometry(const QRect &) // any size you like as long as it's full-screen... QRect rect(mScreen->availableGeometry()); - QApplicationPrivate::handleGeometryChange(this->window(), rect); + QWindowSystemInterface::handleGeometryChange(this->window(), rect); QWindowSurface::setGeometry(rect); } -- cgit v0.12 From 53b0fc5d7fc7ad431cf91e41a75a9f6b740c830e Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 17 Feb 2010 11:34:30 +0100 Subject: added some documentation --- src/gui/painting/qgraphicssystemcursor.cpp | 76 +++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp index 9a0e135..f8d24b1 100644 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ b/src/gui/painting/qgraphicssystemcursor.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -495,6 +495,17 @@ void QGraphicsSystemCursorImage::createSystemCursor(int id) } } +/*! + \fn void set(Qt::CursorShape id) + + \brief Calling this method sets the cursor image to the specified shape + + \a id is one of the defined Qt::CursorShape values. + + If id is invalid, Qt::BitmapCursor, or unknown by the implementation, + Qt::ArrowCursor is used instead. +*/ + void QGraphicsSystemCursorImage::set(Qt::CursorShape id) { QGraphicsSystemCursorImage *cursor = 0; @@ -513,6 +524,18 @@ void QGraphicsSystemCursorImage::set(Qt::CursorShape id) hot = cursor->hot; } +/*! + \fn void set(const QImage * image, int hx, int hy) + + \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy) + + \a image A pointer to a QImage + + \a hx The x coordinate of the cursor's hotspot + + \a hy the y coordinate of the cursor's hotspot +*/ + void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) { hot.setX(hx); @@ -520,6 +543,24 @@ void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) cursorImage = *image; } +/*! + \fn set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) + + \brief set the cursor image to the graphic represented by the combination of data, mask, + width, and height + + \a data The pixel data of the graphic + + \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn + + \a width The width of the graphic in pixels + + \a height The height of the graphic in pixels + + \a hx The X hotspot of the cursor graphic + + \a hy The Y hotspot of the cursor graphic +*/ void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) { @@ -577,4 +618,37 @@ void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, } +/*! + \fn QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + + \brief set the cursor image to the graphic represented by the combination of data, mask, + width, and height + + \a data The pixel data of the graphic + + \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn + + \a width The width of the graphic in pixels + + \a height The height of the graphic in pixels + + \a hotX The X hotspot of the cursor graphic + + \a hotY The Y hotspot of the cursor graphic + + \sa set +*/ + +/*! + \fn QImage *image() + + \brief Return the cursor graphic as a pointer to a QImage +*/ + +/*! + \fn QPoint hotspot + + \brief Return the cursor's hotspot +*/ + QT_END_NAMESPACE -- cgit v0.12 From 196e1484c22f6347061fa433987a86d90e178a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 22 Feb 2010 14:13:35 +0100 Subject: Minimaldfb: try to make pixelformat of window the same as the layer --- src/gui/image/qpixmap_blitter.cpp | 5 +++++ src/gui/image/qpixmap_blitter_p.h | 2 ++ src/gui/kernel/qeventdispatcher_qws_p.h | 2 +- src/gui/painting/qpaintengine_blitter.cpp | 4 ++++ src/gui/painting/qpaintengine_blitter_p.h | 3 +++ .../graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp | 10 +++++++++- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index f82a67d..a22bd8f 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -8,6 +8,7 @@ #include +#ifndef QT_NO_BLITTABLE static int global_ser_no = 0; QBlittablePixmapData::QBlittablePixmapData(QPixmapData::PixelType type) @@ -52,7 +53,9 @@ void QBlittablePixmapData::resize(int width, int height) m_blittable = 0; delete m_engine; m_engine = 0; +#ifdef Q_WS_LITE d = QApplicationPrivate::graphicsSystem()->screens().at(0)->depth(); +#endif w = width; h = height; is_null = (w <= 0 || h <= 0); @@ -257,3 +260,5 @@ QRectF QBlittablePixmapData::clipAndTransformRect(const QRectF &rect) const return transformationRect; } #endif //QT_BLITTER_RASTEROVERLAY + +#endif //QT_NO_BLITTABLE diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index 73f80a8..1d85cd3 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -4,6 +4,7 @@ #include #include +#ifndef QT_NO_BLITTABLE class Q_GUI_EXPORT QBlittablePixmapData : public QPixmapData { // Q_DECLARE_PRIVATE(QBlittablePixmapData); @@ -116,4 +117,5 @@ inline void QBlittablePixmapData::unmarkRasterOverlay(const QRectF &rect) #endif } +#endif // QT_NO_BLITTABLE #endif // QPIXMAP_BLITTER_P_H diff --git a/src/gui/kernel/qeventdispatcher_qws_p.h b/src/gui/kernel/qeventdispatcher_qws_p.h index 5a2b016..8d8d61c 100644 --- a/src/gui/kernel/qeventdispatcher_qws_p.h +++ b/src/gui/kernel/qeventdispatcher_qws_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -class QEventDispatcherLitePrivate; +class QEventDispatcherQWSPrivate; class QEventDispatcherQWS : public QEventDispatcherUNIX { diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 04d3d5a..af76926 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -4,6 +4,8 @@ #include "private/qapplication_p.h" #include "private/qpixmap_blitter_p.h" +#ifndef QT_NO_BLITTABLE + #define STATE_XFORM_SCALE 0x00000001 #define STATE_XFORM_COMPLEX 0x00000002 @@ -658,3 +660,5 @@ void QBlittable::unlock() d->locked = false; } } + +#endif //QT_NO_BLITTABLE diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index 2d9add9..ecc29ba 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -4,6 +4,8 @@ #include "private/qpaintengineex_p.h" #include "private/qpaintengine_raster_p.h" +#ifndef QT_NO_BLITTABLE + class QBlittablePrivate; class QBlitterPaintEnginePrivate; class QBlittablePixmapData; @@ -98,4 +100,5 @@ private: }; +#endif //QT_NO_BLITTABLE #endif // QPAINTENGINE_BLITTER_P_H diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp index d51498f..07a9b8a 100644 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -55,6 +55,10 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window) { window->setWindowSurface(this); + IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); + DFBDisplayLayerConfig layerConfig; + layer->GetConfiguration(layer,&layerConfig); + DFBWindowDescription description; memset(&description,0,sizeof(DFBWindowDescription)); description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS @@ -66,13 +70,17 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window) description.height = window->rect().height(); description.posx = window->rect().x(); description.posy = window->rect().y(); + + if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED) + description.surface_caps = DSCAPS_PREMULTIPLIED; + description.pixelformat = layerConfig.pixelformat; + #if DIRECTFB_MINOR_VERSION >= 1 description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); #endif description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL); description.surface_caps = DSCAPS_PREMULTIPLIED; - IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); DFBResult result = layer->CreateWindow(layer,&description,&m_dfbWindow); if (result != DFB_OK) { DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); -- cgit v0.12 From cf7fe6c1c7bd1189d37b603b38a7fc7feb4b5f41 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 1 Mar 2010 14:18:05 +0100 Subject: Compile after QStaticText introduction --- src/gui/painting/qpaintengine_blitter.cpp | 12 ++++++++++++ src/gui/painting/qpaintengine_blitter_p.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index af76926..1032852 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -571,6 +571,18 @@ void QBlitterPaintEngine::drawTextItem(const QPointF &pos, const QTextItem &ti) d->pmData->markRasterOverlay(pos,ti); } +void QBlitterPaintEngine::drawStaticTextItem(QStaticTextItem *sti) +{ + Q_D(QBlitterPaintEngine); + d->lock(); + d->raster->drawStaticTextItem(sti); + +//#### d->pmData->markRasterOverlay(sti); + qWarning("not implemented: markRasterOverlay for QStaticTextItem"); + +} + + void QBlitterPaintEngine::drawEllipse(const QRectF &r) { Q_D(QBlitterPaintEngine); diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index ecc29ba..1a2ad9e 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -86,6 +86,7 @@ public: virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags); virtual void drawTextItem(const QPointF &pos, const QTextItem &ti); + virtual void drawStaticTextItem(QStaticTextItem *); virtual void drawEllipse(const QRectF &r); -- cgit v0.12 From 19231680666727a07270c44153aeb4a68d67de47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 5 Mar 2010 16:23:03 +0100 Subject: install fonts for lighthouse --- src/qt_install.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt_install.pri b/src/qt_install.pri index f906e92..3cea79c 100644 --- a/src/qt_install.pri +++ b/src/qt_install.pri @@ -38,7 +38,7 @@ qt_install_headers { } } -embedded:equals(TARGET, QtGui) { +embedded|embedded_lite: equals(TARGET, QtGui) { # install fonts for embedded INSTALLS += fonts fonts.path = $$[QT_INSTALL_LIBS]/fonts -- cgit v0.12 From 3eb3527db4cfe86ab51506636376d1b59878f42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 8 Mar 2010 14:26:44 +0100 Subject: QGraphcissystemCursor is now in a file with a _ in it So that syncqt does not generate an entry for it in QtGui --- src/gui/kernel/qapplication_lite.cpp | 2 +- src/gui/kernel/qwidget_lite.cpp | 2 +- src/gui/painting/painting.pri | 4 +- src/gui/painting/qgraphicssystemcursor.cpp | 654 --------------------- src/gui/painting/qgraphicssystemcursor.h | 87 --- src/gui/painting/qgraphicssystemcursor_lite.cpp | 654 +++++++++++++++++++++ src/gui/painting/qgraphicssystemcursor_lite.h | 87 +++ src/plugins/graphicssystems/fb_base/fb_base.cpp | 2 +- src/plugins/graphicssystems/fb_base/fb_base.h | 2 +- .../testlite/qgraphicssystem_testlite.cpp | 2 +- 10 files changed, 748 insertions(+), 748 deletions(-) delete mode 100644 src/gui/painting/qgraphicssystemcursor.cpp delete mode 100644 src/gui/painting/qgraphicssystemcursor.h create mode 100644 src/gui/painting/qgraphicssystemcursor_lite.cpp create mode 100644 src/gui/painting/qgraphicssystemcursor_lite.h diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 5ca6717..5d7ab5a 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -57,7 +57,7 @@ #include #include "private/qgraphicssystem_p.h" -#include "qgraphicssystemcursor.h" +#include #include #include diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 3913708..bcbcd82 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -48,7 +48,7 @@ #include "private/qapplication_p.h" #include "qdesktopwidget.h" -#include "qgraphicssystemcursor.h" +#include QT_BEGIN_NAMESPACE static QGraphicsSystemScreen *qt_screenForWidget(const QWidget *w); diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 8fea4e6..8e7bba7 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -183,9 +183,9 @@ embedded_lite { SOURCES += \ painting/qcolormap_lite.cpp \ painting/qpaintdevice_lite.cpp \ - painting/qgraphicssystemcursor.cpp + painting/qgraphicssystemcursor_lite.cpp HEADERS += \ - painting/qgraphicssystemcursor.h + painting/qgraphicssystemcursor_lite.h } symbian { diff --git a/src/gui/painting/qgraphicssystemcursor.cpp b/src/gui/painting/qgraphicssystemcursor.cpp deleted file mode 100644 index f8d24b1..0000000 --- a/src/gui/painting/qgraphicssystemcursor.cpp +++ /dev/null @@ -1,654 +0,0 @@ -/**************************************************************************** -** -** 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 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 "qgraphicssystemcursor.h" - -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -QPointer QGraphicsSystemCursor::instance = 0; - -/*! - \class QGraphicsSystemCursor - - \brief The QGraphicsSystemCursor class provides information about - pointer device events (movement, buttons), and requests to change - the currently displayed cursor. - - Note that QGraphicsSystemCursor does not include any graphics for - display. An application that sets a QCursor may provide its own - graphics. - - \sa QGraphicsSystemCursorImage -*/ - -/*! - \fn virtual void pointerEvent(const QMouseEvent & event) - - This method is called by Qt whenever a QMouseEvent is generated by the - underlying pointer input. \a event is a reference to the QMouseEvent in - question. A default do-nothing implementation is provided. - - \sa QApplicationPrivate::handleMouseEvent() -*/ - -/*! - \fn virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) - - \brief This method is called by Qt whenever the cursor graphic should be changed. - - Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor. - - \a widgetCursor is a pointer to the QCursor that should be displayed. - - \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note - that this may be 0 if the current position is not occupied by a displayed widget. - - \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos() -*/ - -/*! - Constructs a QGraphicsSystemCursor - -*/ -QGraphicsSystemCursor::QGraphicsSystemCursor(QGraphicsSystemScreen *scr ) - : screen(scr) -{ - instance = this; -} - -// End of display and pointer event handling code -// Beginning of built-in cursor graphics -// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp - -static QGraphicsSystemCursorImage *systemCursorTable[Qt::LastCursor+1]; -static bool systemCursorTableInit = false; - -// 16 x 16 -static const uchar cur_arrow_bits[] = { - 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08, - 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22, - 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 }; -static const uchar mcur_arrow_bits[] = { - 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f, - 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e, - 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 }; - -static const unsigned char cur_up_arrow_bits[] = { - 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, - 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01}; -static const unsigned char mcur_up_arrow_bits[] = { - 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07, - 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01}; - -static const unsigned char cur_cross_bits[] = { - 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00}; -static const unsigned char mcur_cross_bits[] = { - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; - -static const uchar cur_ibeam_bits[] = { - 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, - 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, - 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_ibeam_bits[] = { - 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 }; - -static const uchar cur_ver_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, - 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, - 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; -static const uchar mcur_ver_bits[] = { - 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, - 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, - 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; - -static const uchar cur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, - 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, - 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, - 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; -static const uchar cur_bdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, - 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, - 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_bdiag_bits[] = { - 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, - 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, - 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; -static const uchar cur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, - 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, - 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, - 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, - 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; -static const uchar cur_blank_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -// 20 x 20 -static const uchar forbidden_bits[] = { - 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, - 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, - 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, - 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; - -static const uchar forbiddenm_bits[] = { - 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, - 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, - 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, - 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; - -// 32 x 32 -static const uchar wait_data_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00, - 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, - 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00, - 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, - 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00, - 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar wait_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, - 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00, - 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar hsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, - 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar hsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, - 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, - 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, - 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar vsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar vsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar phand_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, - 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00, - 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, - 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar phandm_bits[] = { - 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, - 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, - 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, - 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, - 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar size_all_data_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00, - 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar size_all_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00, - 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01, - 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00, - 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar whatsthis_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, - 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, - 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, - 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, - 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, - 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -static const uchar whatsthism_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, - 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, - 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, - 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, - 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, - 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - -static const uchar busy_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, - 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, - 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, - 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, - 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static const uchar busym_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, - 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, - 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, - 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, - 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, - 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -// 16 x 16 -static const uchar openhand_bits[] = { - 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, - 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, - 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; -static const uchar openhandm_bits[] = { - 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, - 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, - 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; -static const uchar closedhand_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, - 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, - 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; -static const uchar closedhandm_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, - 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, - 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; - -void QGraphicsSystemCursorImage::createSystemCursor(int id) -{ - if (!systemCursorTableInit) { - for (int i = 0; i <= Qt::LastCursor; i++) - systemCursorTable[i] = 0; - systemCursorTableInit = true; - } - switch (id) { - // 16x16 cursors - case Qt::ArrowCursor: - systemCursorTable[Qt::ArrowCursor] = - new QGraphicsSystemCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0); - break; - - case Qt::UpArrowCursor: - systemCursorTable[Qt::UpArrowCursor] = - new QGraphicsSystemCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0); - break; - - case Qt::CrossCursor: - systemCursorTable[Qt::CrossCursor] = - new QGraphicsSystemCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7); - break; - - case Qt::IBeamCursor: - systemCursorTable[Qt::IBeamCursor] = - new QGraphicsSystemCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7); - break; - - case Qt::SizeVerCursor: - systemCursorTable[Qt::SizeVerCursor] = - new QGraphicsSystemCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7); - break; - - case Qt::SizeHorCursor: - systemCursorTable[Qt::SizeHorCursor] = - new QGraphicsSystemCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7); - break; - - case Qt::SizeBDiagCursor: - systemCursorTable[Qt::SizeBDiagCursor] = - new QGraphicsSystemCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7); - break; - - case Qt::SizeFDiagCursor: - systemCursorTable[Qt::SizeFDiagCursor] = - new QGraphicsSystemCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7); - break; - - case Qt::BlankCursor: - systemCursorTable[Qt::BlankCursor] = - new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); - break; - - // 20x20 cursors - case Qt::ForbiddenCursor: - systemCursorTable[Qt::ForbiddenCursor] = - new QGraphicsSystemCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10); - break; - - // 32x32 cursors - case Qt::WaitCursor: - systemCursorTable[Qt::WaitCursor] = - new QGraphicsSystemCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15); - break; - - case Qt::SplitVCursor: - systemCursorTable[Qt::SplitVCursor] = - new QGraphicsSystemCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15); - break; - - case Qt::SplitHCursor: - systemCursorTable[Qt::SplitHCursor] = - new QGraphicsSystemCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15); - break; - - case Qt::SizeAllCursor: - systemCursorTable[Qt::SizeAllCursor] = - new QGraphicsSystemCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15); - break; - - case Qt::PointingHandCursor: - systemCursorTable[Qt::PointingHandCursor] = - new QGraphicsSystemCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0); - break; - - case Qt::WhatsThisCursor: - systemCursorTable[Qt::WhatsThisCursor] = - new QGraphicsSystemCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0); - break; - case Qt::BusyCursor: - systemCursorTable[Qt::BusyCursor] = - new QGraphicsSystemCursorImage(busy_bits, busym_bits, 32, 32, 0, 0); - break; - - case Qt::OpenHandCursor: - systemCursorTable[Qt::OpenHandCursor] = - new QGraphicsSystemCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8); - break; - case Qt::ClosedHandCursor: - systemCursorTable[Qt::ClosedHandCursor] = - new QGraphicsSystemCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8); - break; - default: - qWarning("Unknown system cursor %d", id); - } -} - -/*! - \fn void set(Qt::CursorShape id) - - \brief Calling this method sets the cursor image to the specified shape - - \a id is one of the defined Qt::CursorShape values. - - If id is invalid, Qt::BitmapCursor, or unknown by the implementation, - Qt::ArrowCursor is used instead. -*/ - -void QGraphicsSystemCursorImage::set(Qt::CursorShape id) -{ - QGraphicsSystemCursorImage *cursor = 0; - if (id >= 0 && id <= Qt::LastCursor) { - if (!systemCursorTable[id]) - createSystemCursor(id); - cursor = systemCursorTable[id]; - } - - if (cursor == 0) { - if (!systemCursorTable[Qt::ArrowCursor]) - createSystemCursor(Qt::ArrowCursor); - cursor = systemCursorTable[Qt::ArrowCursor]; - } - cursorImage = cursor->cursorImage; - hot = cursor->hot; -} - -/*! - \fn void set(const QImage * image, int hx, int hy) - - \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy) - - \a image A pointer to a QImage - - \a hx The x coordinate of the cursor's hotspot - - \a hy the y coordinate of the cursor's hotspot -*/ - -void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) -{ - hot.setX(hx); - hot.setY(hy); - cursorImage = *image; -} - -/*! - \fn set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) - - \brief set the cursor image to the graphic represented by the combination of data, mask, - width, and height - - \a data The pixel data of the graphic - - \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn - - \a width The width of the graphic in pixels - - \a height The height of the graphic in pixels - - \a hx The X hotspot of the cursor graphic - - \a hy The Y hotspot of the cursor graphic -*/ -void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, - int width, int height, int hx, int hy) -{ - hot.setX(hx); - hot.setY(hy); - - cursorImage = QImage(width,height, QImage::Format_Indexed8); - - if (!width || !height || !data || !mask || cursorImage.isNull()) - return; - - cursorImage.setNumColors(3); - cursorImage.setColor(0, 0xff000000); - cursorImage.setColor(1, 0xffffffff); - cursorImage.setColor(2, 0x00000000); - - int bytesPerLine = (width + 7) / 8; - int p = 0; - int d, m; - - int x = -1, w = 0; - - uchar *cursor_data = cursorImage.bits(); - int bpl = cursorImage.bytesPerLine(); - for (int i = 0; i < height; i++) - { - for (int j = 0; j < bytesPerLine; j++, data++, mask++) - { - for (int b = 0; b < 8 && j*8+b < width; b++) - { - d = *data & (1 << b); - m = *mask & (1 << b); - if (d && m) p = 0; - else if (!d && m) p = 1; - else p = 2; - cursor_data[j*8+b] = p; - - // calc region - if (x < 0 && m) - x = j*8+b; - else if (x >= 0 && !m) { - x = -1; - w = 0; - } - if (m) - w++; - } - } - if (x >= 0) { - x = -1; - w = 0; - } - cursor_data += bpl; - } - -} - -/*! - \fn QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) - - \brief set the cursor image to the graphic represented by the combination of data, mask, - width, and height - - \a data The pixel data of the graphic - - \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn - - \a width The width of the graphic in pixels - - \a height The height of the graphic in pixels - - \a hotX The X hotspot of the cursor graphic - - \a hotY The Y hotspot of the cursor graphic - - \sa set -*/ - -/*! - \fn QImage *image() - - \brief Return the cursor graphic as a pointer to a QImage -*/ - -/*! - \fn QPoint hotspot - - \brief Return the cursor's hotspot -*/ - -QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystemcursor.h b/src/gui/painting/qgraphicssystemcursor.h deleted file mode 100644 index 0d57d52..0000000 --- a/src/gui/painting/qgraphicssystemcursor.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QGRAPHICSSYSTEMCURSOR_H -#define QGRAPHICSSYSTEMCURSOR_H - -#include -#include -#include -#include -#include -#include "qgraphicssystem_p.h" - -QT_BEGIN_NAMESPACE - -// Cursor graphics management -class Q_GUI_EXPORT QGraphicsSystemCursorImage { -public: - QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) - { set(data, mask, width, height, hotX, hotY); } - QImage * image() { return &cursorImage; } - QPoint hotspot() { return hot; } - void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); - void set(const QImage * image, int hx, int hy); - void set(Qt::CursorShape); -private: - static void createSystemCursor(int id); - QImage cursorImage; - QPoint hot; -}; - -class Q_GUI_EXPORT QGraphicsSystemCursor : public QObject { -public: - QGraphicsSystemCursor(QGraphicsSystemScreen *); - - // input methods - virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } - virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0; - - static QPointer getInstance() { return instance; } - -protected: - static QPointer instance; // limit 1 cursor at a time - - QGraphicsSystemScreen * screen; // Where to request an update -}; - -QT_END_NAMESPACE - -#endif // QGRAPHICSSYSTEMCURSOR_H diff --git a/src/gui/painting/qgraphicssystemcursor_lite.cpp b/src/gui/painting/qgraphicssystemcursor_lite.cpp new file mode 100644 index 0000000..76b7d97 --- /dev/null +++ b/src/gui/painting/qgraphicssystemcursor_lite.cpp @@ -0,0 +1,654 @@ +/**************************************************************************** +** +** 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 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 "qgraphicssystemcursor_lite.h" + +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +QPointer QGraphicsSystemCursor::instance = 0; + +/*! + \class QGraphicsSystemCursor + + \brief The QGraphicsSystemCursor class provides information about + pointer device events (movement, buttons), and requests to change + the currently displayed cursor. + + Note that QGraphicsSystemCursor does not include any graphics for + display. An application that sets a QCursor may provide its own + graphics. + + \sa QGraphicsSystemCursorImage +*/ + +/*! + \fn virtual void pointerEvent(const QMouseEvent & event) + + This method is called by Qt whenever a QMouseEvent is generated by the + underlying pointer input. \a event is a reference to the QMouseEvent in + question. A default do-nothing implementation is provided. + + \sa QApplicationPrivate::handleMouseEvent() +*/ + +/*! + \fn virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) + + \brief This method is called by Qt whenever the cursor graphic should be changed. + + Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor. + + \a widgetCursor is a pointer to the QCursor that should be displayed. + + \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note + that this may be 0 if the current position is not occupied by a displayed widget. + + \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos() +*/ + +/*! + Constructs a QGraphicsSystemCursor + +*/ +QGraphicsSystemCursor::QGraphicsSystemCursor(QGraphicsSystemScreen *scr ) + : screen(scr) +{ + instance = this; +} + +// End of display and pointer event handling code +// Beginning of built-in cursor graphics +// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp + +static QGraphicsSystemCursorImage *systemCursorTable[Qt::LastCursor+1]; +static bool systemCursorTableInit = false; + +// 16 x 16 +static const uchar cur_arrow_bits[] = { + 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08, + 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22, + 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 }; +static const uchar mcur_arrow_bits[] = { + 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f, + 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e, + 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 }; + +static const unsigned char cur_up_arrow_bits[] = { + 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, + 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01}; +static const unsigned char mcur_up_arrow_bits[] = { + 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07, + 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01}; + +static const unsigned char cur_cross_bits[] = { + 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00}; +static const unsigned char mcur_cross_bits[] = { + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; + +static const uchar cur_ibeam_bits[] = { + 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, + 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, + 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_ibeam_bits[] = { + 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 }; + +static const uchar cur_ver_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, + 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, + 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; +static const uchar mcur_ver_bits[] = { + 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, + 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, + 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; + +static const uchar cur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, + 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, + 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, + 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; +static const uchar cur_bdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, + 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, + 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_bdiag_bits[] = { + 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, + 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, + 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; +static const uchar cur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, + 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, + 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, + 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, + 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; +static const uchar cur_blank_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +// 20 x 20 +static const uchar forbidden_bits[] = { + 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, + 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, + 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, + 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; + +static const uchar forbiddenm_bits[] = { + 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, + 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, + 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, + 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; + +// 32 x 32 +static const uchar wait_data_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00, + 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, + 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00, + 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, + 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00, + 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar wait_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, + 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00, + 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar hsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, + 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar hsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, + 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, + 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, + 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar vsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar vsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar phand_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, + 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00, + 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, + 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar phandm_bits[] = { + 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, + 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, + 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, + 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, + 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar size_all_data_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00, + 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar size_all_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00, + 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01, + 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00, + 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar whatsthis_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, + 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, + 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, + 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, + 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, + 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; +static const uchar whatsthism_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, + 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, + 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, + 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, + 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, + 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + +static const uchar busy_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, + 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, + 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, + 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, + 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static const uchar busym_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, + 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, + 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, + 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, + 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +// 16 x 16 +static const uchar openhand_bits[] = { + 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, + 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, + 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; +static const uchar openhandm_bits[] = { + 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, + 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, + 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; +static const uchar closedhand_bits[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, + 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, + 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; +static const uchar closedhandm_bits[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, + 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, + 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; + +void QGraphicsSystemCursorImage::createSystemCursor(int id) +{ + if (!systemCursorTableInit) { + for (int i = 0; i <= Qt::LastCursor; i++) + systemCursorTable[i] = 0; + systemCursorTableInit = true; + } + switch (id) { + // 16x16 cursors + case Qt::ArrowCursor: + systemCursorTable[Qt::ArrowCursor] = + new QGraphicsSystemCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0); + break; + + case Qt::UpArrowCursor: + systemCursorTable[Qt::UpArrowCursor] = + new QGraphicsSystemCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0); + break; + + case Qt::CrossCursor: + systemCursorTable[Qt::CrossCursor] = + new QGraphicsSystemCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7); + break; + + case Qt::IBeamCursor: + systemCursorTable[Qt::IBeamCursor] = + new QGraphicsSystemCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7); + break; + + case Qt::SizeVerCursor: + systemCursorTable[Qt::SizeVerCursor] = + new QGraphicsSystemCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7); + break; + + case Qt::SizeHorCursor: + systemCursorTable[Qt::SizeHorCursor] = + new QGraphicsSystemCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7); + break; + + case Qt::SizeBDiagCursor: + systemCursorTable[Qt::SizeBDiagCursor] = + new QGraphicsSystemCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7); + break; + + case Qt::SizeFDiagCursor: + systemCursorTable[Qt::SizeFDiagCursor] = + new QGraphicsSystemCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7); + break; + + case Qt::BlankCursor: + systemCursorTable[Qt::BlankCursor] = + new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); + break; + + // 20x20 cursors + case Qt::ForbiddenCursor: + systemCursorTable[Qt::ForbiddenCursor] = + new QGraphicsSystemCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10); + break; + + // 32x32 cursors + case Qt::WaitCursor: + systemCursorTable[Qt::WaitCursor] = + new QGraphicsSystemCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15); + break; + + case Qt::SplitVCursor: + systemCursorTable[Qt::SplitVCursor] = + new QGraphicsSystemCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15); + break; + + case Qt::SplitHCursor: + systemCursorTable[Qt::SplitHCursor] = + new QGraphicsSystemCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15); + break; + + case Qt::SizeAllCursor: + systemCursorTable[Qt::SizeAllCursor] = + new QGraphicsSystemCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15); + break; + + case Qt::PointingHandCursor: + systemCursorTable[Qt::PointingHandCursor] = + new QGraphicsSystemCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0); + break; + + case Qt::WhatsThisCursor: + systemCursorTable[Qt::WhatsThisCursor] = + new QGraphicsSystemCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0); + break; + case Qt::BusyCursor: + systemCursorTable[Qt::BusyCursor] = + new QGraphicsSystemCursorImage(busy_bits, busym_bits, 32, 32, 0, 0); + break; + + case Qt::OpenHandCursor: + systemCursorTable[Qt::OpenHandCursor] = + new QGraphicsSystemCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8); + break; + case Qt::ClosedHandCursor: + systemCursorTable[Qt::ClosedHandCursor] = + new QGraphicsSystemCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8); + break; + default: + qWarning("Unknown system cursor %d", id); + } +} + +/*! + \fn void set(Qt::CursorShape id) + + \brief Calling this method sets the cursor image to the specified shape + + \a id is one of the defined Qt::CursorShape values. + + If id is invalid, Qt::BitmapCursor, or unknown by the implementation, + Qt::ArrowCursor is used instead. +*/ + +void QGraphicsSystemCursorImage::set(Qt::CursorShape id) +{ + QGraphicsSystemCursorImage *cursor = 0; + if (id >= 0 && id <= Qt::LastCursor) { + if (!systemCursorTable[id]) + createSystemCursor(id); + cursor = systemCursorTable[id]; + } + + if (cursor == 0) { + if (!systemCursorTable[Qt::ArrowCursor]) + createSystemCursor(Qt::ArrowCursor); + cursor = systemCursorTable[Qt::ArrowCursor]; + } + cursorImage = cursor->cursorImage; + hot = cursor->hot; +} + +/*! + \fn void set(const QImage * image, int hx, int hy) + + \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy) + + \a image A pointer to a QImage + + \a hx The x coordinate of the cursor's hotspot + + \a hy the y coordinate of the cursor's hotspot +*/ + +void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) +{ + hot.setX(hx); + hot.setY(hy); + cursorImage = *image; +} + +/*! + \fn set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) + + \brief set the cursor image to the graphic represented by the combination of data, mask, + width, and height + + \a data The pixel data of the graphic + + \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn + + \a width The width of the graphic in pixels + + \a height The height of the graphic in pixels + + \a hx The X hotspot of the cursor graphic + + \a hy The Y hotspot of the cursor graphic +*/ +void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, + int width, int height, int hx, int hy) +{ + hot.setX(hx); + hot.setY(hy); + + cursorImage = QImage(width,height, QImage::Format_Indexed8); + + if (!width || !height || !data || !mask || cursorImage.isNull()) + return; + + cursorImage.setNumColors(3); + cursorImage.setColor(0, 0xff000000); + cursorImage.setColor(1, 0xffffffff); + cursorImage.setColor(2, 0x00000000); + + int bytesPerLine = (width + 7) / 8; + int p = 0; + int d, m; + + int x = -1, w = 0; + + uchar *cursor_data = cursorImage.bits(); + int bpl = cursorImage.bytesPerLine(); + for (int i = 0; i < height; i++) + { + for (int j = 0; j < bytesPerLine; j++, data++, mask++) + { + for (int b = 0; b < 8 && j*8+b < width; b++) + { + d = *data & (1 << b); + m = *mask & (1 << b); + if (d && m) p = 0; + else if (!d && m) p = 1; + else p = 2; + cursor_data[j*8+b] = p; + + // calc region + if (x < 0 && m) + x = j*8+b; + else if (x >= 0 && !m) { + x = -1; + w = 0; + } + if (m) + w++; + } + } + if (x >= 0) { + x = -1; + w = 0; + } + cursor_data += bpl; + } + +} + +/*! + \fn QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + + \brief set the cursor image to the graphic represented by the combination of data, mask, + width, and height + + \a data The pixel data of the graphic + + \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn + + \a width The width of the graphic in pixels + + \a height The height of the graphic in pixels + + \a hotX The X hotspot of the cursor graphic + + \a hotY The Y hotspot of the cursor graphic + + \sa set +*/ + +/*! + \fn QImage *image() + + \brief Return the cursor graphic as a pointer to a QImage +*/ + +/*! + \fn QPoint hotspot + + \brief Return the cursor's hotspot +*/ + +QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystemcursor_lite.h b/src/gui/painting/qgraphicssystemcursor_lite.h new file mode 100644 index 0000000..0d57d52 --- /dev/null +++ b/src/gui/painting/qgraphicssystemcursor_lite.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QGRAPHICSSYSTEMCURSOR_H +#define QGRAPHICSSYSTEMCURSOR_H + +#include +#include +#include +#include +#include +#include "qgraphicssystem_p.h" + +QT_BEGIN_NAMESPACE + +// Cursor graphics management +class Q_GUI_EXPORT QGraphicsSystemCursorImage { +public: + QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + { set(data, mask, width, height, hotX, hotY); } + QImage * image() { return &cursorImage; } + QPoint hotspot() { return hot; } + void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + void set(const QImage * image, int hx, int hy); + void set(Qt::CursorShape); +private: + static void createSystemCursor(int id); + QImage cursorImage; + QPoint hot; +}; + +class Q_GUI_EXPORT QGraphicsSystemCursor : public QObject { +public: + QGraphicsSystemCursor(QGraphicsSystemScreen *); + + // input methods + virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } + virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0; + + static QPointer getInstance() { return instance; } + +protected: + static QPointer instance; // limit 1 cursor at a time + + QGraphicsSystemScreen * screen; // Where to request an update +}; + +QT_END_NAMESPACE + +#endif // QGRAPHICSSYSTEMCURSOR_H diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index 6567e95..da7ddb8 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen *scr) diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h index c46a99d..8b130d2 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include class QMouseEvent; class QSize; diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp index ed8f883..92e0ebc 100644 --- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp +++ b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include #include "x11util.h" -- cgit v0.12 From e6b9bc4c4269be040c947a464acf2b5c65ba38cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 8 Mar 2010 16:55:29 +0100 Subject: Minimaldfb: cleanup how to compile Add variables DIRECTFB_LIBS and DIRECTFB_INCLUDEPATH to your mkspec --- src/plugins/graphicssystems/minimaldfb/minimaldfb.pro | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro index f5d2406..b6c2ea8 100644 --- a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro +++ b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro @@ -2,18 +2,14 @@ TARGET = qminimaldfb include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems -system(pkg-config --exists directfb) { - DIRECTFB_CFLAGS = $$system(pkg-config --cflags directfb) - DIRECTFB_LIBS = $$system(pkg-config --libs directfb) -} else { - directfb_config = $$SYSTEM(which directfb-config) - !isEmpty(directfb_config) { - DIRECTFB_CFLAGS = $$system(directfb-config --cflags) - DIRECTFB_LIBS = $$system(directfb-config --libs) - } +isEmpty(DIRECTFB_LIBS) { + DIRECTFB_LIBS = -ldirectfb -lfusion -ldirect -lpthread +} +isEmpty(DIRECTFB_INCLUDEPATH) { + DIRECTFB_INCLUDEPATH = /usr/include/directfb } -QMAKE_CXXFLAGS += $$DIRECTFB_CFLAGS +INCLUDEPATH += $$DIRECTFB_INCLUDEPATH LIBS += $$DIRECTFB_LIBS SOURCES = main.cpp \ -- cgit v0.12 From b9f8c1491550fe671d1809481ad7f70737034a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 8 Mar 2010 16:57:54 +0100 Subject: LinuxFb: call initDevice So you turn off the cursor blinking and remove redundant forward class declaration --- src/plugins/graphicssystems/fb_base/fb_base.h | 1 - src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h index 8b130d2..91b6d12 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -12,7 +12,6 @@ class QMouseEvent; class QSize; class QPainter; -class QGraphicsSystemFbWindowSurface; class QGraphicsSystemFbScreen; class QGraphicsSystemSoftwareCursor : public QGraphicsSystemCursor diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp index f5ca6e7..a373ba8 100644 --- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp +++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp @@ -164,6 +164,7 @@ QLinuxFbGraphicsSystem::QLinuxFbGraphicsSystem() if (!connect(displaySpec)) qFatal("QLinuxFbGraphicsSystem: could not initialize screen"); + initDevice(); // Create a QImage directly on the screen's framebuffer. // This is the blit target for copying windows to the screen. -- cgit v0.12 From cf841986a5941047a37548c83810c96bcd600539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 11 Mar 2010 14:41:28 +0100 Subject: Make QNativeImage use the screen format --- src/gui/image/qnativeimage.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp index 8446387..3420778 100644 --- a/src/gui/image/qnativeimage.cpp +++ b/src/gui/image/qnativeimage.cpp @@ -45,6 +45,9 @@ #include "private/qpaintengine_raster_p.h" +#include "private/qapplication_p.h" +#include "private/qgraphicssystem_p.h" + #if defined(Q_WS_X11) && !defined(QT_NO_MITSHM) #include #include @@ -284,7 +287,11 @@ QNativeImage::~QNativeImage() QImage::Format QNativeImage::systemFormat() { +#ifdef Q_WS_LITE + return QApplicationPrivate::graphicsSystem()->screens().at(0)->format(); +#else return QImage::Format_RGB32; +#endif } #endif // platforms -- cgit v0.12 From a029628b5e626f4213031427aec0f62ffbef4cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 15 Mar 2010 15:12:37 +0100 Subject: Add blendfunctions for "all" depths on all platforms and not only QWS --- src/gui/painting/qdrawhelper.cpp | 90 ++++++++++++++++++++-------------------- src/gui/painting/qdrawhelper_p.h | 2 - 2 files changed, 45 insertions(+), 47 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 581b538..fd1ac00 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -4676,7 +4676,7 @@ void QT_FASTCALL blendUntransformed(int count, const QSpan *spans, void *userDat static void blend_untransformed_rgb888(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_24) +#if defined(QT_QWS_DEPTH_24) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_RGB888) @@ -4689,7 +4689,7 @@ static void blend_untransformed_rgb888(int count, const QSpan *spans, static void blend_untransformed_argb6666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) +#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -4704,7 +4704,7 @@ static void blend_untransformed_argb6666(int count, const QSpan *spans, static void blend_untransformed_rgb666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) +#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -4719,7 +4719,7 @@ static void blend_untransformed_rgb666(int count, const QSpan *spans, static void blend_untransformed_argb8565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) +#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -4734,7 +4734,7 @@ static void blend_untransformed_argb8565(int count, const QSpan *spans, static void blend_untransformed_rgb565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) +#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -4749,7 +4749,7 @@ static void blend_untransformed_rgb565(int count, const QSpan *spans, static void blend_untransformed_argb8555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) +#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -4764,7 +4764,7 @@ static void blend_untransformed_argb8555(int count, const QSpan *spans, static void blend_untransformed_rgb555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) +#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -4779,7 +4779,7 @@ static void blend_untransformed_rgb555(int count, const QSpan *spans, static void blend_untransformed_argb4444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) +#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -4794,7 +4794,7 @@ static void blend_untransformed_argb4444(int count, const QSpan *spans, static void blend_untransformed_rgb444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) +#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -5018,7 +5018,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTiled(int count, const QSpan *spans, void * static void blend_tiled_rgb888(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_24) +#if defined(QT_QWS_DEPTH_24) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_RGB888) @@ -5030,7 +5030,7 @@ static void blend_tiled_rgb888(int count, const QSpan *spans, void *userData) static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) +#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -5044,7 +5044,7 @@ static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData) static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) +#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -5058,7 +5058,7 @@ static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData) static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) +#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -5072,7 +5072,7 @@ static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData) static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData) { -#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) +#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -5086,7 +5086,7 @@ static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData) static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) +#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -5100,7 +5100,7 @@ static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData) static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) +#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -5114,7 +5114,7 @@ static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData) static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) +#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -5128,7 +5128,7 @@ static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData) static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) +#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -5522,7 +5522,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan static void blend_transformed_bilinear_rgb888(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_24) +#if defined(QT_QWS_DEPTH_24) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_RGB888) @@ -5534,7 +5534,7 @@ static void blend_transformed_bilinear_rgb888(int count, const QSpan *spans, voi static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) +#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -5548,7 +5548,7 @@ static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, v static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) +#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -5562,7 +5562,7 @@ static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, voi static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) +#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -5577,7 +5577,7 @@ static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, v static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) +#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_RGB16) @@ -5591,7 +5591,7 @@ static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans, static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) +#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -5605,7 +5605,7 @@ static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, v static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) +#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -5619,7 +5619,7 @@ static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, voi static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) +#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -5633,7 +5633,7 @@ static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, v static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) +#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -6106,7 +6106,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformed(int count, const QSpan *spans, static void blend_transformed_rgb888(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_24) +#if defined(QT_QWS_DEPTH_24) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_RGB888) @@ -6119,7 +6119,7 @@ static void blend_transformed_rgb888(int count, const QSpan *spans, static void blend_transformed_argb6666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) +#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -6134,7 +6134,7 @@ static void blend_transformed_argb6666(int count, const QSpan *spans, static void blend_transformed_rgb666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) +#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -6149,7 +6149,7 @@ static void blend_transformed_rgb666(int count, const QSpan *spans, static void blend_transformed_argb8565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) +#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -6164,7 +6164,7 @@ static void blend_transformed_argb8565(int count, const QSpan *spans, static void blend_transformed_rgb565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) +#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -6179,7 +6179,7 @@ static void blend_transformed_rgb565(int count, const QSpan *spans, static void blend_transformed_argb8555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) +#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -6194,7 +6194,7 @@ static void blend_transformed_argb8555(int count, const QSpan *spans, static void blend_transformed_rgb555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) +#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -6209,7 +6209,7 @@ static void blend_transformed_rgb555(int count, const QSpan *spans, static void blend_transformed_argb4444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) +#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -6224,7 +6224,7 @@ static void blend_transformed_argb4444(int count, const QSpan *spans, static void blend_transformed_rgb444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) +#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -6519,7 +6519,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedTiled(int count, const QSpan *sp static void blend_transformed_tiled_rgb888(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_24) +#if defined(QT_QWS_DEPTH_24) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_RGB888) @@ -6532,7 +6532,7 @@ static void blend_transformed_tiled_rgb888(int count, const QSpan *spans, static void blend_transformed_tiled_argb6666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) +#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -6547,7 +6547,7 @@ static void blend_transformed_tiled_argb6666(int count, const QSpan *spans, static void blend_transformed_tiled_rgb666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) +#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -6562,7 +6562,7 @@ static void blend_transformed_tiled_rgb666(int count, const QSpan *spans, static void blend_transformed_tiled_argb8565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) +#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -6577,7 +6577,7 @@ static void blend_transformed_tiled_argb8565(int count, const QSpan *spans, static void blend_transformed_tiled_rgb565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) +#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -6592,7 +6592,7 @@ static void blend_transformed_tiled_rgb565(int count, const QSpan *spans, static void blend_transformed_tiled_argb8555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) +#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -6607,7 +6607,7 @@ static void blend_transformed_tiled_argb8555(int count, const QSpan *spans, static void blend_transformed_tiled_rgb555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) +#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -6622,7 +6622,7 @@ static void blend_transformed_tiled_rgb555(int count, const QSpan *spans, static void blend_transformed_tiled_argb4444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) +#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -6637,7 +6637,7 @@ static void blend_transformed_tiled_argb4444(int count, const QSpan *spans, static void blend_transformed_tiled_rgb444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) +#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index f5b17ea..a582793 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -1618,9 +1618,7 @@ QT_TRIVIAL_MEMCONVERT_IMPL(qrgb888) QT_TRIVIAL_MEMCONVERT_IMPL(qargb6666) QT_TRIVIAL_MEMCONVERT_IMPL(qrgb666) QT_TRIVIAL_MEMCONVERT_IMPL(quint16) -#ifdef Q_WS_QWS QT_TRIVIAL_MEMCONVERT_IMPL(qrgb565) -#endif QT_TRIVIAL_MEMCONVERT_IMPL(qargb8565) QT_TRIVIAL_MEMCONVERT_IMPL(qargb8555) QT_TRIVIAL_MEMCONVERT_IMPL(qrgb555) -- cgit v0.12 From fd3688cc931b7ea69027fa98847901c8212cf3da Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 16 Mar 2010 10:56:50 +0100 Subject: Don't use the QWS install target for Lighthouse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jørgen Lind --- configure | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 337c59a..461a6d9 100755 --- a/configure +++ b/configure @@ -3196,7 +3196,11 @@ if [ -z "$QT_INSTALL_PREFIX" ]; then if [ "$CFG_DEV" = "yes" ]; then QT_INSTALL_PREFIX="$outpath" # In Development, we use sandboxed builds by default elif [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then - QT_INSTALL_PREFIX="/usr/local/Trolltech/QtEmbedded-${QT_VERSION}" + if [ "$PLATFORM_EMBLITE" = "yes" ]; then + QT_INSTALL_PREFIX="/usr/local/Trolltech/QtLighthouse-${QT_VERSION}" + else + QT_INSTALL_PREFIX="/usr/local/Trolltech/QtEmbedded-${QT_VERSION}" + fi if [ "$PLATFORM" != "$XPLATFORM" ]; then QT_INSTALL_PREFIX="${QT_INSTALL_PREFIX}-${CFG_ARCH}" fi -- cgit v0.12 From 349d2dd29cd6f4c90c1890e3f56850883f5ac07d Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 18 Mar 2010 14:23:04 +0100 Subject: Revert "Add blendfunctions for "all" depths on all platforms" Details: It turns out that the original code is more accurate and in most cases faster as well. This reverts commit a029628b5e626f4213031427aec0f62ffbef4cab. --- src/gui/painting/qdrawhelper.cpp | 90 ++++++++++++++++++++-------------------- src/gui/painting/qdrawhelper_p.h | 2 + 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index fd1ac00..581b538 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -4676,7 +4676,7 @@ void QT_FASTCALL blendUntransformed(int count, const QSpan *spans, void *userDat static void blend_untransformed_rgb888(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_24) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_24) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_RGB888) @@ -4689,7 +4689,7 @@ static void blend_untransformed_rgb888(int count, const QSpan *spans, static void blend_untransformed_argb6666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_18) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -4704,7 +4704,7 @@ static void blend_untransformed_argb6666(int count, const QSpan *spans, static void blend_untransformed_rgb666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_18) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -4719,7 +4719,7 @@ static void blend_untransformed_rgb666(int count, const QSpan *spans, static void blend_untransformed_argb8565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_16) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -4734,7 +4734,7 @@ static void blend_untransformed_argb8565(int count, const QSpan *spans, static void blend_untransformed_rgb565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_16) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -4749,7 +4749,7 @@ static void blend_untransformed_rgb565(int count, const QSpan *spans, static void blend_untransformed_argb8555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_15) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -4764,7 +4764,7 @@ static void blend_untransformed_argb8555(int count, const QSpan *spans, static void blend_untransformed_rgb555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_15) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -4779,7 +4779,7 @@ static void blend_untransformed_rgb555(int count, const QSpan *spans, static void blend_untransformed_argb4444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_12) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -4794,7 +4794,7 @@ static void blend_untransformed_argb4444(int count, const QSpan *spans, static void blend_untransformed_rgb444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_12) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -5018,7 +5018,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTiled(int count, const QSpan *spans, void * static void blend_tiled_rgb888(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_24) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_24) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_RGB888) @@ -5030,7 +5030,7 @@ static void blend_tiled_rgb888(int count, const QSpan *spans, void *userData) static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_18) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -5044,7 +5044,7 @@ static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData) static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_18) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -5058,7 +5058,7 @@ static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData) static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_16) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -5072,7 +5072,7 @@ static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData) static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) +#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -5086,7 +5086,7 @@ static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData) static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_15) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -5100,7 +5100,7 @@ static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData) static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_15) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -5114,7 +5114,7 @@ static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData) static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_12) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -5128,7 +5128,7 @@ static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData) static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_12) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -5522,7 +5522,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan static void blend_transformed_bilinear_rgb888(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_24) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_24) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_RGB888) @@ -5534,7 +5534,7 @@ static void blend_transformed_bilinear_rgb888(int count, const QSpan *spans, voi static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_18) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -5548,7 +5548,7 @@ static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, v static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_18) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -5562,7 +5562,7 @@ static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, voi static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_16) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -5577,7 +5577,7 @@ static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, v static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_16) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_RGB16) @@ -5591,7 +5591,7 @@ static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans, static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_15) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -5605,7 +5605,7 @@ static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, v static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_15) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -5619,7 +5619,7 @@ static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, voi static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_12) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -5633,7 +5633,7 @@ static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, v static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_12) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -6106,7 +6106,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformed(int count, const QSpan *spans, static void blend_transformed_rgb888(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_24) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_24) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_RGB888) @@ -6119,7 +6119,7 @@ static void blend_transformed_rgb888(int count, const QSpan *spans, static void blend_transformed_argb6666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_18) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -6134,7 +6134,7 @@ static void blend_transformed_argb6666(int count, const QSpan *spans, static void blend_transformed_rgb666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_18) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -6149,7 +6149,7 @@ static void blend_transformed_rgb666(int count, const QSpan *spans, static void blend_transformed_argb8565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_16) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -6164,7 +6164,7 @@ static void blend_transformed_argb8565(int count, const QSpan *spans, static void blend_transformed_rgb565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_16) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -6179,7 +6179,7 @@ static void blend_transformed_rgb565(int count, const QSpan *spans, static void blend_transformed_argb8555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_15) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -6194,7 +6194,7 @@ static void blend_transformed_argb8555(int count, const QSpan *spans, static void blend_transformed_rgb555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_15) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -6209,7 +6209,7 @@ static void blend_transformed_rgb555(int count, const QSpan *spans, static void blend_transformed_argb4444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_12) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -6224,7 +6224,7 @@ static void blend_transformed_argb4444(int count, const QSpan *spans, static void blend_transformed_rgb444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_12) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -6519,7 +6519,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedTiled(int count, const QSpan *sp static void blend_transformed_tiled_rgb888(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_24) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_24) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_RGB888) @@ -6532,7 +6532,7 @@ static void blend_transformed_tiled_rgb888(int count, const QSpan *spans, static void blend_transformed_tiled_argb6666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_18) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -6547,7 +6547,7 @@ static void blend_transformed_tiled_argb6666(int count, const QSpan *spans, static void blend_transformed_tiled_rgb666(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_18) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_18) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB6666_Premultiplied) @@ -6562,7 +6562,7 @@ static void blend_transformed_tiled_rgb666(int count, const QSpan *spans, static void blend_transformed_tiled_argb8565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_16) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -6577,7 +6577,7 @@ static void blend_transformed_tiled_argb8565(int count, const QSpan *spans, static void blend_transformed_tiled_rgb565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_16) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) @@ -6592,7 +6592,7 @@ static void blend_transformed_tiled_rgb565(int count, const QSpan *spans, static void blend_transformed_tiled_argb8555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_15) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -6607,7 +6607,7 @@ static void blend_transformed_tiled_argb8555(int count, const QSpan *spans, static void blend_transformed_tiled_rgb555(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_15) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_15) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8555_Premultiplied) @@ -6622,7 +6622,7 @@ static void blend_transformed_tiled_rgb555(int count, const QSpan *spans, static void blend_transformed_tiled_argb4444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_12) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) @@ -6637,7 +6637,7 @@ static void blend_transformed_tiled_argb4444(int count, const QSpan *spans, static void blend_transformed_tiled_rgb444(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_12) || !defined(Q_WS_QWS) +#if defined(QT_QWS_DEPTH_12) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB4444_Premultiplied) diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index a582793..f5b17ea 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -1618,7 +1618,9 @@ QT_TRIVIAL_MEMCONVERT_IMPL(qrgb888) QT_TRIVIAL_MEMCONVERT_IMPL(qargb6666) QT_TRIVIAL_MEMCONVERT_IMPL(qrgb666) QT_TRIVIAL_MEMCONVERT_IMPL(quint16) +#ifdef Q_WS_QWS QT_TRIVIAL_MEMCONVERT_IMPL(qrgb565) +#endif QT_TRIVIAL_MEMCONVERT_IMPL(qargb8565) QT_TRIVIAL_MEMCONVERT_IMPL(qargb8555) QT_TRIVIAL_MEMCONVERT_IMPL(qrgb555) -- cgit v0.12 From 1bbe84eb729b9b692910720cbf0805c9e485bad0 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 24 Mar 2010 15:50:41 +0100 Subject: don't draw changes under opaque windows --- src/plugins/graphicssystems/fb_base/fb_base.cpp | 106 +++++++++++++++++---- src/plugins/graphicssystems/fb_base/fb_base.h | 12 ++- .../linuxfb/qgraphicssystem_linuxfb.cpp | 16 +++- .../linuxfb/qgraphicssystem_linuxfb.h | 2 + 4 files changed, 114 insertions(+), 22 deletions(-) diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index da7ddb8..c1ce817 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -81,7 +81,7 @@ void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget screen->setDirty(currentRect); } -QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0) +QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false) { mScreenImage = new QImage(mGeometry.size(), mFormat); redrawTimer.setSingleShot(true); @@ -94,6 +94,9 @@ void QGraphicsSystemFbScreen::setGeometry(QRect rect) delete mScreenImage; mGeometry = rect; mScreenImage = new QImage(mGeometry.size(), mFormat); + delete compositePainter; + compositePainter = 0; + invalidateRectCache(); } void QGraphicsSystemFbScreen::setDepth(int depth) @@ -111,10 +114,13 @@ void QGraphicsSystemFbScreen::setFormat(QImage::Format format) mFormat = format; delete mScreenImage; mScreenImage = new QImage(mGeometry.size(), mFormat); + delete compositePainter; + compositePainter = 0; } QGraphicsSystemFbScreen::~QGraphicsSystemFbScreen() { + delete compositePainter; delete mScreenImage; } @@ -126,6 +132,31 @@ void QGraphicsSystemFbScreen::setDirty(const QRect &rect) } } +void QGraphicsSystemFbScreen::generateRects() +{ + cachedRects.clear(); + QRegion remainingScreen(mGeometry); + + for (int i = 0; i < windowStack.length(); i++) { + if (remainingScreen.isEmpty()) + break; + if (!windowStack[i]->window()->testAttribute(Qt::WA_TranslucentBackground)) { + remainingScreen -= windowStack[i]->geometry(); + QRegion windowRegion(windowStack[i]->geometry()); + windowRegion -= remainingScreen; + foreach(QRect rect, windowRegion.rects()) { + cachedRects += QPair(rect, i); + } + } + } + foreach (QRect rect, remainingScreen.rects()) + cachedRects += QPair(rect, -1); + isUpToDate = true; + return; +} + + + QRegion QGraphicsSystemFbScreen::doRedraw() { QRegion touchedRegion; @@ -134,32 +165,65 @@ QRegion QGraphicsSystemFbScreen::doRedraw() if (repaintRegion.isEmpty()) return touchedRegion; - QPainter compositePainter(mScreenImage); QVector rects = repaintRegion.rects(); + if (!isUpToDate) + generateRects(); + + if (!compositePainter) + compositePainter = new QPainter(mScreenImage); for (int rectIndex = 0; rectIndex < repaintRegion.numRects(); rectIndex++) { - QRect rect = rects[rectIndex]; - // Blank the affected area, just in case there's nothing to display - compositePainter.fillRect(rect, Qt::black); - for (int i = windowStack.length() - 1; i >= 0; i--) { - if (!windowStack[i]->visible()) - continue; - if (windowStack[i]->window()->isMinimized()) - continue; - QRect windowRect = windowStack[i]->geometry(); - QRect intersect = windowRect.intersected(rect); - QRect windowIntersect = intersect.translated(-windowRect.left(), - -windowRect.top()); - if (intersect.isNull()) + QRegion rectRegion = rects[rectIndex]; + + for(int i = 0; i < cachedRects.length(); i++) { + QRect screenSubRect = cachedRects[i].first; + int layer = cachedRects[i].second; + QRegion intersect = rectRegion.intersected(screenSubRect); + + if (intersect.isEmpty()) continue; - compositePainter.drawImage(intersect, windowStack[i]->image(), - windowIntersect); + + rectRegion -= intersect; + + // we only expect one rectangle, but defensive coding... + foreach (QRect rect, intersect.rects()) { + bool firstLayer = true; + if (layer == -1) { + compositePainter->setCompositionMode(QPainter::CompositionMode_Source); + compositePainter->fillRect(rect, Qt::black); + compositePainter->setCompositionMode(QPainter::CompositionMode_SourceOver); + firstLayer = false; + layer = windowStack.size() - 1; + } + + for (int layerIndex = layer; layerIndex != -1; layerIndex--) { + if (!windowStack[layerIndex]->visible()) + continue; + if (windowStack[layerIndex]->window()->isMinimized()) + continue; + QRect windowRect = windowStack[layerIndex]->geometry(); + QRect windowIntersect = rect.translated(-windowRect.left(), + -windowRect.top()); + if (firstLayer) + compositePainter->setCompositionMode(QPainter::CompositionMode_Source); + compositePainter->drawImage(rect, windowStack[layerIndex]->image(), + windowIntersect); + if (firstLayer) { + compositePainter->setCompositionMode(QPainter::CompositionMode_SourceOver); + firstLayer = false; + } + } + } } + if (!rectRegion.isEmpty()) + qWarning() << "non-empty region!" << rectRegion; + // Everything on screen should be mapped to a sub-rectangle + // unless it's off the screen... } QRect cursorRect; if (cursor) { - cursorRect = cursor->drawCursor(compositePainter); + cursorRect = cursor->drawCursor(*compositePainter); touchedRegion += cursorRect; } touchedRegion += repaintRegion; @@ -171,6 +235,7 @@ QRegion QGraphicsSystemFbScreen::doRedraw() void QGraphicsSystemFbScreen::removeWindowSurface(QGraphicsSystemFbWindowSurface * surface) { windowStack.removeOne(surface); + invalidateRectCache(); setDirty(surface->geometry()); } @@ -186,6 +251,7 @@ void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) if (index <= 0) return; windowStack.move(index, 0); + invalidateRectCache(); setDirty(s->geometry()); } @@ -201,6 +267,7 @@ void QGraphicsSystemFbScreen::lower(QWindowSurface * surface) if (index == -1 || index == (windowStack.size() - 1)) return; windowStack.move(index, windowStack.size() - 1); + invalidateRectCache(); setDirty(s->geometry()); } @@ -261,6 +328,7 @@ void QGraphicsSystemFbWindowSurface::setGeometry(const QRect &rect) if (mImage.size() != rect.size()) mImage = QImage(rect.size(), mScreen->format()); + mScreen->invalidateRectCache(); QWindowSystemInterface::handleGeometryChange(window(), rect); QWindowSurface::setGeometry(rect); @@ -284,12 +352,14 @@ void QGraphicsSystemFbWindowSurface::endPaint(const QRegion ®ion) void QGraphicsSystemFbWindowSurface::setVisible(bool visible) { visibleFlag = visible; + mScreen->invalidateRectCache(); mScreen->setDirty(geometry()); } Qt::WindowFlags QGraphicsSystemFbWindowSurface::setWindowFlags(Qt::WindowFlags type) { flags = type; + mScreen->invalidateRectCache(); return flags; } diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h index 91b6d12..7f9b005 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ b/src/plugins/graphicssystems/fb_base/fb_base.h @@ -94,7 +94,8 @@ public: virtual void setDirty(const QRect &rect); virtual void removeWindowSurface(QGraphicsSystemFbWindowSurface * surface); - virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { windowStack.prepend(surface); } + virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { + windowStack.prepend(surface); invalidateRectCache(); } virtual void raise(QWindowSurface * surface); virtual void lower(QWindowSurface * surface); virtual QWidget * topLevelAt(const QPoint & p) const; @@ -117,6 +118,15 @@ protected: QImage::Format mFormat; QSize mPhysicalSize; QImage *mScreenImage; + +private: + QPainter * compositePainter; + void generateRects(); + QList > cachedRects; + + void invalidateRectCache() { isUpToDate = false; } + friend class QGraphicsSystemFbWindowSurface; + bool isUpToDate; }; #endif // QLIGHTHOUSEGRAPHICSSCREEN_H diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp index a373ba8..21a5da3 100644 --- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp +++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp @@ -797,7 +797,7 @@ QWindowSurface *QLinuxFbGraphicsSystem::createWindowSurface(QWidget *widget) con } QLinuxFbGraphicsSystemScreen::QLinuxFbGraphicsSystemScreen(uchar * d, int w, - int h, int lstep, QImage::Format screenFormat) + int h, int lstep, QImage::Format screenFormat) : compositePainter(0) { data = d; mGeometry = QRect(0,0,w,h); @@ -817,6 +817,9 @@ void QLinuxFbGraphicsSystemScreen::setGeometry(QRect rect) delete mFbScreenImage; mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), bytesPerLine, mFormat); + delete compositePainter; + compositePainter = 0; + delete mScreenImage; mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), mFormat); @@ -828,6 +831,9 @@ void QLinuxFbGraphicsSystemScreen::setFormat(QImage::Format format) delete mFbScreenImage; mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), bytesPerLine, mFormat); + delete compositePainter; + compositePainter = 0; + delete mScreenImage; mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), mFormat); @@ -838,10 +844,14 @@ QRegion QLinuxFbGraphicsSystemScreen::doRedraw() QRegion touched; touched = QGraphicsSystemFbScreen::doRedraw(); - QPainter compositePainter(mFbScreenImage); + if (!compositePainter) { + compositePainter = new QPainter(mFbScreenImage); + compositePainter->setCompositionMode(QPainter::CompositionMode_Source); + } + QVector rects = touched.rects(); for (int i = 0; i < rects.size(); i++) - compositePainter.drawImage(rects[i], *mScreenImage, rects[i]); + compositePainter->drawImage(rects[i], *mScreenImage, rects[i]); return touched; } QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h index f85718a..cc8ce7e 100644 --- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h +++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h @@ -61,6 +61,8 @@ private: QImage * mFbScreenImage; uchar * data; int bytesPerLine; + + QPainter *compositePainter; }; class QLinuxFbGraphicsSystemPrivate; -- cgit v0.12 From 2c38550ddb064215f827f856110128f2bb4fd631 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 25 Mar 2010 15:00:44 +0100 Subject: don't set composition mode to source when painting the bottow layer Doing so kills performance on the painting benchmark --- src/plugins/graphicssystems/fb_base/fb_base.cpp | 5 ----- src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp | 1 - 2 files changed, 6 deletions(-) diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp index c1ce817..d30746a 100644 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ b/src/plugins/graphicssystems/fb_base/fb_base.cpp @@ -189,9 +189,7 @@ QRegion QGraphicsSystemFbScreen::doRedraw() foreach (QRect rect, intersect.rects()) { bool firstLayer = true; if (layer == -1) { - compositePainter->setCompositionMode(QPainter::CompositionMode_Source); compositePainter->fillRect(rect, Qt::black); - compositePainter->setCompositionMode(QPainter::CompositionMode_SourceOver); firstLayer = false; layer = windowStack.size() - 1; } @@ -204,12 +202,9 @@ QRegion QGraphicsSystemFbScreen::doRedraw() QRect windowRect = windowStack[layerIndex]->geometry(); QRect windowIntersect = rect.translated(-windowRect.left(), -windowRect.top()); - if (firstLayer) - compositePainter->setCompositionMode(QPainter::CompositionMode_Source); compositePainter->drawImage(rect, windowStack[layerIndex]->image(), windowIntersect); if (firstLayer) { - compositePainter->setCompositionMode(QPainter::CompositionMode_SourceOver); firstLayer = false; } } diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp index 21a5da3..44960bb 100644 --- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp +++ b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp @@ -846,7 +846,6 @@ QRegion QLinuxFbGraphicsSystemScreen::doRedraw() if (!compositePainter) { compositePainter = new QPainter(mFbScreenImage); - compositePainter->setCompositionMode(QPainter::CompositionMode_Source); } QVector rects = touched.rects(); -- cgit v0.12 From 9e12625b31e1d95f023fe67deb50e8bf97903994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 29 Mar 2010 09:37:55 +0200 Subject: Compile fix the openkode graphicssystem Does not work well yet though :( --- src/gui/egl/qegl_lite.cpp | 23 ++++++---- src/plugins/graphicssystems/openkode/openkode.pro | 2 +- .../openkode/qgraphicssystem_openkode.cpp | 13 +++--- .../openkode/qgraphicssystem_openkode.h | 2 +- .../openkode/qwindowsurface_openkode.cpp | 51 +++++++++++++--------- .../openkode/qwindowsurface_openkode.h | 3 +- 6 files changed, 55 insertions(+), 39 deletions(-) diff --git a/src/gui/egl/qegl_lite.cpp b/src/gui/egl/qegl_lite.cpp index 60b862b..2bbf22b 100644 --- a/src/gui/egl/qegl_lite.cpp +++ b/src/gui/egl/qegl_lite.cpp @@ -42,7 +42,7 @@ #include #include #include -#include "qegl_p.h" +#include "qeglcontext_p.h" #if !defined(QT_NO_EGL) @@ -52,19 +52,26 @@ QT_BEGIN_NAMESPACE -EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties *properties) +EGLNativeDisplayType QEgl::nativeDisplay() { - Q_UNUSED(device); - Q_UNUSED(properties); - return 0; + return EGLNativeDisplayType(EGL_DEFAULT_DISPLAY); +} + +EGLNativeWindowType QEgl::nativeWindow(QWidget* widget) +{ + return (EGLNativeWindowType)(widget->winId()); } -EGLDisplay QEglContext::getDisplay(QPaintDevice *device) +EGLNativePixmapType QEgl::nativePixmap(QPixmap* pixmap) { - Q_UNUSED(device); - return eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY)); + return 0; } +//EGLDisplay QEglContext::display() +//{ +// return eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY)); +//} + static QGraphicsSystemScreen *screenForDevice(QPaintDevice *device) { QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); diff --git a/src/plugins/graphicssystems/openkode/openkode.pro b/src/plugins/graphicssystems/openkode/openkode.pro index f8f0bcb..055048d 100644 --- a/src/plugins/graphicssystems/openkode/openkode.pro +++ b/src/plugins/graphicssystems/openkode/openkode.pro @@ -11,4 +11,4 @@ INSTALLS += target # openkode specific stuff INCLUDEPATH += $(OPENKODE_DIR)/include -LIBS += $${QMAKE_RPATH}/$(OPENKODE_DIR)/lib-target -L$(OPENKODE_DIR)/lib-target -lKD -lEGL -lGLESv2_CM +LIBS += $${QMAKE_RPATH}/$(OPENKODE_DIR)/lib-target -L$(OPENKODE_DIR)/lib-target -lKD -lEGL -lGLESv2 diff --git a/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.cpp b/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.cpp index 51364e4..7a07776 100644 --- a/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.cpp +++ b/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.cpp @@ -92,7 +92,7 @@ QOpenKODEGraphicsSystemScreen::QOpenKODEGraphicsSystemScreen() } // Once we've set up the desktop and display we don't need them anymore -// kdReleaseDisplayNV(kdDisplay); TODO!!! + kdReleaseDisplayNV(kdDisplay); kdReleaseDesktopNV(kdDesktop); const int defaultDpi = 72; @@ -102,12 +102,6 @@ QOpenKODEGraphicsSystemScreen::QOpenKODEGraphicsSystemScreen() mDepth = 24; mFormat = QImage::Format_RGB888; - if (!mContext.openDisplay(0)) { - qWarning("qEglContext: Unable to open display!"); - return; - } - - qDebug() << " - QEglContext::openDisplay OK"; QEglProperties properties; properties.setPixelFormat(QImage::Format_RGB888); @@ -119,6 +113,11 @@ QOpenKODEGraphicsSystemScreen::QOpenKODEGraphicsSystemScreen() return; } + if (!mContext.display()) { + qWarning("qEglContext: Unable to open display!"); + return; + } + qDebug() << " - QEglContext::openDisplay OK"; } diff --git a/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.h b/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.h index 972c42e..7d73ae0 100644 --- a/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.h +++ b/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.h @@ -45,7 +45,7 @@ #include #include -#include +#include # include diff --git a/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.cpp b/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.cpp index 33c76e4..b3f3965 100644 --- a/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.cpp +++ b/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.cpp @@ -51,12 +51,13 @@ QT_BEGIN_NAMESPACE QOpenKODEWindowSurface::QOpenKODEWindowSurface (QOpenKODEGraphicsSystemScreen *screen, QWidget *window) : QWindowSurface(window), - mScreen(screen) + mScreen(screen), + mSurface(0) { qDebug() << "QOpenKODEWindowSurface::QOpenKODEWindowSurface:" << window << window->width() << "x" << window->height() << "pos" << window->x() << "x" << window->y(); - if (!mContext.openDisplay(0)) { + if (!mContext.display()) { qWarning("qEglContext: Unable to open display!"); return; } @@ -76,6 +77,7 @@ QOpenKODEWindowSurface::QOpenKODEWindowSurface void QOpenKODEWindowSurface::createWindow(QWidget *window) { + qDebug() << "createWindow"; kdWindow = kdCreateWindow(mContext.display(), mContext.config(), KD_NULL); if (!kdWindow) { @@ -89,17 +91,17 @@ void QOpenKODEWindowSurface::createWindow(QWidget *window) return; } - const KDboolean windowExclusive[] = { false }; - if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, windowExclusive)) { - qErrnoWarning(kdGetError(), "Could not set exclusive bit"); - return; - } + //const KDboolean windowExclusive[] = { false }; + //if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, windowExclusive)) { + // qErrnoWarning(kdGetError(), "Could not set exclusive bit"); + // //return; + //} - const KDint windowPos[2] = { window->x(), window->y() }; - if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { - qErrnoWarning(kdGetError(), "Could not set native window position"); - return; - } + //const KDint windowPos[2] = { window->x(), window->y() }; + //if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { + // qErrnoWarning(kdGetError(), "Could not set native window position"); + // //return; + //} EGLNativeWindowType nativeWindow; @@ -107,24 +109,29 @@ void QOpenKODEWindowSurface::createWindow(QWidget *window) qErrnoWarning(kdGetError(), "Could not realize native window"); return; } + qDebug() << "kdRealizeWindow" << nativeWindow; // Create an EGL window surface for the native window EGLint windowAttrs[3] = { EGL_NONE }; - EGLSurface eglSurface = eglCreateWindowSurface(mContext.display(), + qDebug() << "doing createwindowsurface"; + *mSurface = eglCreateWindowSurface(mContext.display(), mContext.config(), nativeWindow, windowAttrs); - if (!eglSurface) { + qDebug() << "create windowsurface"; + if (!mSurface) { qWarning("EGL couldn't create window surface: 0x%x", eglGetError()); return; } - mContext.setSurface(eglSurface); - + qDebug() << "making context"; if (!mContext.createContext()) { qDebug() << "Unable to create context!"; return; } + + qDebug() << "about to make current"; + mContext.makeCurrent(mSurface); } QOpenKODEWindowSurface::~QOpenKODEWindowSurface() @@ -133,19 +140,20 @@ QOpenKODEWindowSurface::~QOpenKODEWindowSurface() QPaintDevice *QOpenKODEWindowSurface::paintDevice() { - //qDebug() << "QOpenKODEWindowSurface::paintDevice"; + qDebug() << "QOpenKODEWindowSurface::paintDevice"; return &mImage; } // ### TODO - this updates the entire toplevel, should only update the region -void QOpenKODEWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +void QOpenKODEWindowSurface::flush(QWidget *, const QRegion ®ion, const QPoint &offset) { + qDebug() << "in flush"; if (!offset.isNull()) { qWarning("Offset flushing not supported yet"); return; } - if (!mContext.makeCurrent()) { + if (!mContext.makeCurrent(mSurface)) { qWarning("EGL couldn't make context/surface current: 0x%x", eglGetError()); return; } @@ -222,8 +230,8 @@ void QOpenKODEWindowSurface::flush(QWidget *widget, const QRegion ®ion, const if (texId) glDeleteTextures(1, &texId); - mContext.swapBuffers(); mContext.doneCurrent(); + mContext.swapBuffers(mSurface); } void QOpenKODEWindowSurface::setGeometry(const QRect &rect) @@ -233,9 +241,10 @@ void QOpenKODEWindowSurface::setGeometry(const QRect &rect) if (mImage.size() != rect.size()) mImage = QImage(rect.size(), mScreen->format()); - mContext.destroySurface(); + mContext.destroySurface(mSurface); kdDestroyWindow(kdWindow); createWindow(window()); + qDebug() << "set geometry workded"; } bool QOpenKODEWindowSurface::scroll(const QRegion &area, int dx, int dy) diff --git a/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.h b/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.h index 1c70f55..bee94a5 100644 --- a/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.h +++ b/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.h @@ -43,7 +43,7 @@ #define QWINDOWSURFACE_OPENKODE_H #include -#include +#include QT_BEGIN_NAMESPACE @@ -68,6 +68,7 @@ private: QOpenKODEGraphicsSystemScreen *mScreen; QImage mImage; struct KDWindow *kdWindow; + EGLSurface *mSurface; QEglContext mContext; void createWindow(QWidget *window); -- cgit v0.12 From a5e1442d8960d3a9f363a8101d02e6fae804b6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 29 Mar 2010 10:06:52 +0200 Subject: Make sure the blitter api works with Raster GS(x11 and win) and QWS --- src/gui/image/qpixmap_blitter.cpp | 9 ++- src/gui/image/qpixmap_blitter_p.h | 3 + src/gui/painting/painting.pri | 10 ++- src/gui/painting/qblittable.cpp | 64 +++++++++++++++++ src/gui/painting/qblittable_p.h | 48 +++++++++++++ src/gui/painting/qgraphicssystem_p.h | 4 +- src/gui/painting/qpaintengine_blitter.cpp | 61 ++-------------- src/gui/painting/qpaintengine_blitter_p.h | 40 ++--------- .../painting/qwindowsurface_rasterblittable.cpp | 26 +++++++ .../painting/qwindowsurface_rasterblittable_p.h | 21 ++++++ .../gfxdrivers/blittableqvfb/blittableqvfb.pro | 28 ++++++++ src/plugins/gfxdrivers/blittableqvfb/main.cpp | 81 ++++++++++++++++++++++ .../gfxdrivers/blittableqvfb/qblittable_image.h | 48 +++++++++++++ .../blittableqvfb/qgraphicssystem_blittableqvfb.h | 47 +++++++++++++ .../blittableqvfb/qscreen_blittableqvfb.h | 14 ++++ .../blittableqvfb/qwindowsurface_qwsblittable.cpp | 0 .../blittableqvfb/qwindowsurface_qwsblittable.h | 36 ++++++++++ .../graphicssystems/blittable/blittable.pro | 12 ++++ src/plugins/graphicssystems/blittable/main.cpp | 73 +++++++++++++++++++ .../graphicssystems/blittable/qblittable_image.h | 48 +++++++++++++ .../blittable/qgraphicssystem_blittable.h | 47 +++++++++++++ 21 files changed, 623 insertions(+), 97 deletions(-) create mode 100644 src/gui/painting/qblittable.cpp create mode 100644 src/gui/painting/qblittable_p.h create mode 100644 src/gui/painting/qwindowsurface_rasterblittable.cpp create mode 100644 src/gui/painting/qwindowsurface_rasterblittable_p.h create mode 100644 src/plugins/gfxdrivers/blittableqvfb/blittableqvfb.pro create mode 100644 src/plugins/gfxdrivers/blittableqvfb/main.cpp create mode 100644 src/plugins/gfxdrivers/blittableqvfb/qblittable_image.h create mode 100644 src/plugins/gfxdrivers/blittableqvfb/qgraphicssystem_blittableqvfb.h create mode 100644 src/plugins/gfxdrivers/blittableqvfb/qscreen_blittableqvfb.h create mode 100644 src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.cpp create mode 100644 src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.h create mode 100644 src/plugins/graphicssystems/blittable/blittable.pro create mode 100644 src/plugins/graphicssystems/blittable/main.cpp create mode 100644 src/plugins/graphicssystems/blittable/qblittable_image.h create mode 100644 src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index a22bd8f..6dcf7c7 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -5,10 +5,13 @@ #include #include +#include #include #ifndef QT_NO_BLITTABLE +QT_BEGIN_NAMESPACE + static int global_ser_no = 0; QBlittablePixmapData::QBlittablePixmapData(QPixmapData::PixelType type) @@ -34,7 +37,7 @@ QBlittable *QBlittablePixmapData::blittable() const { if (!m_blittable) { QBlittablePixmapData *that = const_cast(this); - that->m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QRect(0,0,w,h)); + that->m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QSize(w,h)); } return m_blittable; @@ -42,7 +45,7 @@ QBlittable *QBlittablePixmapData::blittable() const void QBlittablePixmapData::setBlittable(QBlittable *blittable) { - resize(blittable->rect().width(),blittable->rect().height()); + resize(blittable->size().width(),blittable->size().height()); m_blittable = blittable; } @@ -259,6 +262,8 @@ QRectF QBlittablePixmapData::clipAndTransformRect(const QRectF &rect) const } return transformationRect; } + +QT_END_NAMESPACE #endif //QT_BLITTER_RASTEROVERLAY #endif //QT_NO_BLITTABLE diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index 1d85cd3..b9f7630 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -5,6 +5,8 @@ #include #ifndef QT_NO_BLITTABLE +QT_BEGIN_NAMESPACE + class Q_GUI_EXPORT QBlittablePixmapData : public QPixmapData { // Q_DECLARE_PRIVATE(QBlittablePixmapData); @@ -117,5 +119,6 @@ inline void QBlittablePixmapData::unmarkRasterOverlay(const QRectF &rect) #endif } +QT_END_NAMESPACE #endif // QT_NO_BLITTABLE #endif // QPIXMAP_BLITTER_P_H diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 8e7bba7..a3fe2e1 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -89,12 +89,16 @@ SOURCES += \ painting/qpaintengine_raster.cpp \ painting/qdrawhelper.cpp \ painting/qimagescale.cpp \ - painting/qgrayraster.c + painting/qgrayraster.c \ + painting/qpaintengine_blitter.cpp \ + painting/qblittable.cpp \ HEADERS += \ painting/qpaintengine_raster_p.h \ painting/qrasterdefs_p.h \ - painting/qgrayraster_p.h + painting/qgrayraster_p.h \ + painting/qpaintengine_blitter_p.h \ + painting/qblittable_p.h \ win32 { HEADERS += painting/qprintengine_win_p.h @@ -121,12 +125,14 @@ embedded { painting/qgraphicssystemfactory_p.h \ painting/qgraphicssystemplugin_p.h \ painting/qwindowsurface_raster_p.h \ + painting/qwindowsurface_rasterblittable_p.h \ SOURCES += \ painting/qgraphicssystem_raster.cpp \ painting/qgraphicssystemfactory.cpp \ painting/qgraphicssystemplugin.cpp \ painting/qwindowsurface_raster.cpp \ + painting/qwindowsurface_rasterblittable.cpp \ } unix:x11 { diff --git a/src/gui/painting/qblittable.cpp b/src/gui/painting/qblittable.cpp new file mode 100644 index 0000000..0b2bd64 --- /dev/null +++ b/src/gui/painting/qblittable.cpp @@ -0,0 +1,64 @@ +#include "qblittable_p.h" + +#ifndef QT_NO_BLITTABLE +QT_BEGIN_NAMESPACE + +class QBlittablePrivate +{ +public: + QBlittablePrivate(const QSize &size, QBlittable::Capabilities caps) + : caps(caps), m_size(size), locked(false), cachedImg(0) + {} + QBlittable::Capabilities caps; + QSize m_size; + bool locked; + QImage *cachedImg; +}; + + +QBlittable::QBlittable(const QSize &size, Capabilities caps) + : d_ptr(new QBlittablePrivate(size,caps)) +{ +} + +QBlittable::~QBlittable() +{ + delete d_ptr; +} + + +QBlittable::Capabilities QBlittable::capabilities() const +{ + Q_D(const QBlittable); + return d->caps; +} + +QSize QBlittable::size() const +{ + Q_D(const QBlittable); + return d->m_size; +} + +QImage *QBlittable::lock() +{ + Q_D(QBlittable); + if (!d->locked) { + d->cachedImg = doLock(); + d->locked = true; + } + + return d->cachedImg; +} + +void QBlittable::unlock() +{ + Q_D(QBlittable); + if (d->locked) { + doUnlock(); + d->locked = false; + } +} + +QT_END_NAMESPACE +#endif //QT_NO_BLITTABLE + diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h new file mode 100644 index 0000000..98caab7d --- /dev/null +++ b/src/gui/painting/qblittable_p.h @@ -0,0 +1,48 @@ +#ifndef QBLITTABLE_P_H +#define QBLITTABLE_P_H + +#include + +#ifndef QT_NO_BLITTABLE +QT_BEGIN_NAMESPACE + +class QImage; +class QBlittablePrivate; + +class Q_GUI_EXPORT QBlittable +{ + Q_DECLARE_PRIVATE(QBlittable); +public: + enum Capability { + + SolidRectCapability = 0x0001, + SourcePixmapCapability = 0x0002, + SourceOverPixmapCapability = 0x0004, + SourceOverScaledPixmapCapability = 0x0008, + + // Internal ones + OutlineCapability = 0x0001000, + }; + Q_DECLARE_FLAGS (Capabilities, Capability); + + QBlittable(const QSize &size, Capabilities caps); + virtual ~QBlittable(); + + Capabilities capabilities() const; + QSize size() const; + + virtual void fillRect(const QRectF &rect, const QColor &color) = 0; + virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect) = 0; + + QImage *lock(); + void unlock(); + +protected: + virtual QImage *doLock() = 0; + virtual void doUnlock() = 0; + QBlittablePrivate *d_ptr; +}; + +QT_END_NAMESPACE +#endif //QT_NO_BLITTABLE +#endif //QBLITTABLE_P_H diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index 8e35f9f..03b0f48 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -62,6 +62,7 @@ QT_BEGIN_NAMESPACE class QPixmapFilter; +class QBlittable; #ifdef Q_WS_LITE class Q_GUI_EXPORT QGraphicsSystemScreen : public QObject @@ -86,7 +87,7 @@ class Q_GUI_EXPORT QGraphicsSystem public: virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0; - virtual QBlittable *createBlittable(const QRect &) const { return 0; } + virtual QBlittable *createBlittable(const QSize &) const { return 0; } virtual ~QGraphicsSystem() = 0; @@ -94,6 +95,7 @@ public: virtual QList screens() const; virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; #endif + //### Remove this & change qpixmap.cpp & qbitmap.cpp once every platform is gaurenteed // to have a graphics system. static QPixmapData *createDefaultPixmapData(QPixmapData::PixelType type); diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 1032852..0b74a4d 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -1,10 +1,13 @@ #include "private/qpaintengine_blitter_p.h" + +#include "private/qblittable_p.h" #include "private/qpaintengine_raster_p.h" #include "private/qpainter_p.h" #include "private/qapplication_p.h" #include "private/qpixmap_blitter_p.h" #ifndef QT_NO_BLITTABLE +QT_BEGIN_NAMESPACE #define STATE_XFORM_SCALE 0x00000001 #define STATE_XFORM_COMPLEX 0x00000002 @@ -617,60 +620,6 @@ inline QRasterPaintEngine *QBlitterPaintEngine::raster() const return d->raster; } -class QBlittablePrivate -{ -public: - QBlittablePrivate(const QRect &rect, QBlittable::Capabilities caps) - : caps(caps), m_rect(rect), locked(false), cachedImg(0) - {} - QBlittable::Capabilities caps; - QRect m_rect; - bool locked; - QImage *cachedImg; -}; - - -QBlittable::QBlittable(const QRect &rect, Capabilities caps) - : d_ptr(new QBlittablePrivate(rect,caps)) -{ -} - -QBlittable::~QBlittable() -{ - delete d_ptr; -} - - -QBlittable::Capabilities QBlittable::capabilities() const -{ - Q_D(const QBlittable); - return d->caps; -} - -QRect QBlittable::rect() const -{ - Q_D(const QBlittable); - return d->m_rect; -} - -QImage *QBlittable::lock() -{ - Q_D(QBlittable); - if (!d->locked) { - d->cachedImg = doLock(); - d->locked = true; - } - - return d->cachedImg; -} - -void QBlittable::unlock() -{ - Q_D(QBlittable); - if (d->locked) { - doUnlock(); - d->locked = false; - } -} - +QT_END_NAMESPACE #endif //QT_NO_BLITTABLE + diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index 1a2ad9e..d436993 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -5,45 +5,11 @@ #include "private/qpaintengine_raster_p.h" #ifndef QT_NO_BLITTABLE +QT_BEGIN_NAMESPACE -class QBlittablePrivate; class QBlitterPaintEnginePrivate; class QBlittablePixmapData; - -class Q_GUI_EXPORT QBlittable -{ - Q_DECLARE_PRIVATE(QBlittable); -public: - enum Capability { - - SolidRectCapability = 0x0001, - SourcePixmapCapability = 0x0002, - SourceOverPixmapCapability = 0x0004, - SourceOverScaledPixmapCapability = 0x0008, - - // Internal ones - OutlineCapability = 0x0001000, - }; - Q_DECLARE_FLAGS (Capabilities, Capability); - - QBlittable(const QRect &rect, Capabilities caps); - virtual ~QBlittable(); - - Capabilities capabilities() const; - QRect rect() const; - - virtual void fillRect(const QRectF &rect, const QColor &color) = 0; - virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect) = 0; - - QImage *lock(); - void unlock(); - -protected: - virtual QImage *doLock() = 0; - virtual void doUnlock() = 0; - QBlittablePrivate *d_ptr; -}; - +class QBlittable; class Q_GUI_EXPORT QBlitterPaintEngine : public QPaintEngineEx { @@ -101,5 +67,7 @@ private: }; +QT_END_NAMESPACE #endif //QT_NO_BLITTABLE #endif // QPAINTENGINE_BLITTER_P_H + diff --git a/src/gui/painting/qwindowsurface_rasterblittable.cpp b/src/gui/painting/qwindowsurface_rasterblittable.cpp new file mode 100644 index 0000000..56a79ba --- /dev/null +++ b/src/gui/painting/qwindowsurface_rasterblittable.cpp @@ -0,0 +1,26 @@ +#include "qwindowsurface_rasterblittable_p.h" + +#include +#include + +QRasterBlittableWindowSurface::QRasterBlittableWindowSurface(QWidget *widget) + : QRasterWindowSurface(widget), + m_currentImage(0), + m_blittable(0), + m_pmData(new QBlittablePixmapData(QPixmapData::PixmapType)), + m_pixmap(new QPixmap(m_pmData)) +{ +} + +QPaintDevice *QRasterBlittableWindowSurface::paintDevice() +{ + QPaintDevice *device = QRasterWindowSurface::paintDevice(); + if (m_currentImage != device) { + if (device->devType() == QInternal::Image) { + m_currentImage = static_cast(device); + m_blittable = createBlittable(m_currentImage); + m_pmData->setBlittable(m_blittable); + } + } + return m_pixmap; +} diff --git a/src/gui/painting/qwindowsurface_rasterblittable_p.h b/src/gui/painting/qwindowsurface_rasterblittable_p.h new file mode 100644 index 0000000..1e697c7 --- /dev/null +++ b/src/gui/painting/qwindowsurface_rasterblittable_p.h @@ -0,0 +1,21 @@ +#include +#include + +class QBlittable; +class QBlittablePixmapData; + +class Q_GUI_EXPORT QRasterBlittableWindowSurface : public QRasterWindowSurface +{ +public: + QRasterBlittableWindowSurface(QWidget *widget); + + virtual QBlittable *createBlittable(QImage *rasterSurface) = 0; + + QPaintDevice *paintDevice(); + +private: + QImage *m_currentImage; + QBlittable *m_blittable; + QBlittablePixmapData *m_pmData; + QPixmap *m_pixmap; +}; diff --git a/src/plugins/gfxdrivers/blittableqvfb/blittableqvfb.pro b/src/plugins/gfxdrivers/blittableqvfb/blittableqvfb.pro new file mode 100644 index 0000000..d6a2018 --- /dev/null +++ b/src/plugins/gfxdrivers/blittableqvfb/blittableqvfb.pro @@ -0,0 +1,28 @@ +TARGET = qscreenblittablevfb +include(../../qpluginbase.pri) + +DEFINES += QT_QWS_QVFB QT_QWS_MOUSE_QVFB QT_QWS_KBD_QVFB + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers + +HEADERS = qgraphicssystem_blittableqvfb.h \ + qscreen_blittableqvfb.h \ + qwindowsurface_qwsblittable.h \ + qblittable_image.h + +SOURCES = main.cpp \ + qwindowsurface_qwsblittable.cpp + +#include qvfb sources +HEADERS += \ + $$QT_SOURCE_TREE/src/gui/embedded/qscreenvfb_qws.h \ + $$QT_SOURCE_TREE/src/gui/embedded/qkbdvfb_qws.h \ + $$QT_SOURCE_TREE/src/gui/embedded/qmousevfb_qws.h + +SOURCES += \ + $$QT_SOURCE_TREE/src/gui/embedded/qscreenvfb_qws.cpp \ + $$QT_SOURCE_TREE/src/gui/embedded/qkbdvfb_qws.cpp \ + $$QT_SOURCE_TREE/src/gui/embedded/qmousevfb_qws.cpp + +target.path += $$[QT_INSTALL_PLUGINS]/gfxdrivers +INSTALLS += target diff --git a/src/plugins/gfxdrivers/blittableqvfb/main.cpp b/src/plugins/gfxdrivers/blittableqvfb/main.cpp new file mode 100644 index 0000000..b6d2603 --- /dev/null +++ b/src/plugins/gfxdrivers/blittableqvfb/main.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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 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 +#include +#include "qscreen_blittableqvfb.h" + +#ifndef QT_NO_LIBRARY +QT_BEGIN_NAMESPACE + +class ScreenBlittableVfbDriver : public QScreenDriverPlugin +{ +public: + ScreenBlittableVfbDriver(); + + QStringList keys() const; + QScreen *create(const QString&, int displayId); +}; + +ScreenBlittableVfbDriver::ScreenBlittableVfbDriver() +: QScreenDriverPlugin() +{ +} + +QStringList ScreenBlittableVfbDriver::keys() const +{ + QStringList list; + list << "BlittableQVFb"; + return list; +} + +QScreen* ScreenBlittableVfbDriver::create(const QString& driver, int displayId) +{ + if (driver.toLower() == "blittableqvfb") + return new QBlittableVFbScreen(displayId); + + return 0; +} + +Q_EXPORT_PLUGIN2(qscreenblittablevfb, ScreenBlittableVfbDriver) + +QT_END_NAMESPACE +#endif //QT_NO_LIBRARY diff --git a/src/plugins/gfxdrivers/blittableqvfb/qblittable_image.h b/src/plugins/gfxdrivers/blittableqvfb/qblittable_image.h new file mode 100644 index 0000000..3f8dc69 --- /dev/null +++ b/src/plugins/gfxdrivers/blittableqvfb/qblittable_image.h @@ -0,0 +1,48 @@ +#include + +#include + + +class QImageBlittable : public QBlittable +{ +public: + QImageBlittable(QImage *image, bool deleteImage) + : QBlittable(image->size(), QBlittable::Capabilities(QBlittable::SolidRectCapability + |QBlittable::SourcePixmapCapability + |QBlittable::SourceOverPixmapCapability + |QBlittable::SourceOverScaledPixmapCapability)), + m_image(image), m_deleteImage(deleteImage) + { + + } + + ~QImageBlittable() { + if (m_deleteImage) + delete m_image; + } + + void fillRect(const QRectF &rect, const QColor &color) + { + QPainter p(lock()); + p.fillRect(rect,color); + } + void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &source) + { + //here it is possible to do a pixmap.pixmapData()->buffer() + //but is like this to show how to get the the blitter + QPixmapData *data = pixmap.pixmapData(); + Q_ASSERT(data->width() && data->height()); + Q_ASSERT(data->classId() == QPixmapData::BlitterClass); + QBlittablePixmapData *blittableData = static_cast(data); + + QPainter p(lock()); + p.drawImage(rect, *blittableData->blittable()->lock(),source); + } + +protected: + QImage *doLock() { return m_image; } + void doUnlock() { } +private: + QImage *m_image; + bool m_deleteImage; +}; diff --git a/src/plugins/gfxdrivers/blittableqvfb/qgraphicssystem_blittableqvfb.h b/src/plugins/gfxdrivers/blittableqvfb/qgraphicssystem_blittableqvfb.h new file mode 100644 index 0000000..89940d0 --- /dev/null +++ b/src/plugins/gfxdrivers/blittableqvfb/qgraphicssystem_blittableqvfb.h @@ -0,0 +1,47 @@ +#include +#include +#include +#include + +#include "qwindowsurface_qwsblittable.h" +#include "qblittable_image.h" +#include + +class QBlittableVFbGraphicsSystem : public QGraphicsSystem +{ +public: + QPixmapData *createPixmapData(QPixmapData::PixelType type) const + { + if (type == QPixmapData::PixmapType) { + return new QBlittablePixmapData(type); + } else { + return new QRasterPixmapData(type); + } + } + + QWindowSurface *createWindowSurface(QWidget *widget) const + { + if (QApplication::type() == QApplication::GuiServer) + return new QWSBlittableMemSurface(widget); + else + return QScreen::instance()->createSurface(widget); + } + + QBlittable *createBlittable(const QSize &size) const + { + QImage *image = new QImage(size,QImage::Format_ARGB32); + return new QImageBlittable(image,true); + } + + static QGraphicsSystem *instance() + { + static QGraphicsSystem *system = 0; + if (!system) { + system = new QBlittableVFbGraphicsSystem; + } + return system; + } + +private: + QBlittableVFbGraphicsSystem() { } +}; diff --git a/src/plugins/gfxdrivers/blittableqvfb/qscreen_blittableqvfb.h b/src/plugins/gfxdrivers/blittableqvfb/qscreen_blittableqvfb.h new file mode 100644 index 0000000..645aeec --- /dev/null +++ b/src/plugins/gfxdrivers/blittableqvfb/qscreen_blittableqvfb.h @@ -0,0 +1,14 @@ +#include +#include "qgraphicssystem_blittableqvfb.h" + +class QBlittableVFbScreen : public QVFbScreen +{ +public: + explicit QBlittableVFbScreen(int display_id) + : QVFbScreen(display_id) + { + setGraphicsSystem(QBlittableVFbGraphicsSystem::instance()); + + } + +}; diff --git a/src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.cpp b/src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.h b/src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.h new file mode 100644 index 0000000..b955322 --- /dev/null +++ b/src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.h @@ -0,0 +1,36 @@ +#include "qblittable_image.h" + +#include +#include + +class QBlittablePixmapData; + +class Q_GUI_EXPORT QWSBlittableMemSurface : public QWSLocalMemSurface +{ +public: + QWSBlittableMemSurface( QWidget *window ) + : QWSLocalMemSurface(window), + m_currentPaintDevice(0), + pmData(new QBlittablePixmapData(QPixmapData::PixmapType)), + pm(pmData) + { + } + + QPaintDevice *paintDevice() + { + if (QWSLocalMemSurface::paintDevice() != m_currentPaintDevice) { + QPaintDevice *device = QWSLocalMemSurface::paintDevice(); + if (device->devType() == QInternal::Image) { + img = *static_cast(device); + pmData->setBlittable(new QImageBlittable(&img,false)); + } + } + return ± + } + +private: + QPaintDevice *m_currentPaintDevice; + QBlittablePixmapData *pmData; + QPixmap pm; +}; + diff --git a/src/plugins/graphicssystems/blittable/blittable.pro b/src/plugins/graphicssystems/blittable/blittable.pro new file mode 100644 index 0000000..596e92f --- /dev/null +++ b/src/plugins/graphicssystems/blittable/blittable.pro @@ -0,0 +1,12 @@ +TARGET = qblittablegraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp +HEADERS = qblittable_image.h \ + qgraphicssystem_blittable.h \ + qwindowsurface_imageblittable.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/graphicssystems/blittable/main.cpp b/src/plugins/graphicssystems/blittable/main.cpp new file mode 100644 index 0000000..06c3189 --- /dev/null +++ b/src/plugins/graphicssystems/blittable/main.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 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 + +#include "qgraphicssystem_blittable.h" + +QT_BEGIN_NAMESPACE + +class QBlittableGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QBlittableGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << QLatin1String("Blittable"); + return list; +} + +QGraphicsSystem* QBlittableGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == QLatin1String("blittable")) { + return new QBlittableGraphicsSystem; + } + + return 0; +} + +Q_EXPORT_PLUGIN2(blittable, QBlittableGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/blittable/qblittable_image.h b/src/plugins/graphicssystems/blittable/qblittable_image.h new file mode 100644 index 0000000..8ca86b7 --- /dev/null +++ b/src/plugins/graphicssystems/blittable/qblittable_image.h @@ -0,0 +1,48 @@ +#include + +#include + + +class QImageBlittable : public QBlittable +{ +public: + QImageBlittable(QImage *image, bool deleteImage) + : QBlittable(image->size(), QBlittable::Capabilities(QBlittable::SolidRectCapability + |QBlittable::SourcePixmapCapability + |QBlittable::SourceOverPixmapCapability + |QBlittable::SourceOverScaledPixmapCapability)), + m_image(image), m_deleteImage(deleteImage) + { + + } + + ~QImageBlittable() { + if (m_deleteImage) + delete m_image; + } + + void fillRect(const QRectF &rect, const QColor &color) + { + QPainter p(lock()); + p.fillRect(rect,color); + } + void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &source) + { + //here it is possible to do a pixmap.pixmapData()->buffer() + //but is like this to show how to get the the blitter + QPixmapData *data = pixmap.pixmapData(); + Q_ASSERT(data->width() && data->height()); + Q_ASSERT(data->classId() == QPixmapData::BlitterClass); + QBlittablePixmapData *blittableData = static_cast(data); + + QPainter p(lock()); + p.drawImage(rect, *blittableData->blittable()->lock(),source); + } + +protected: + QImage *doLock() { return m_image; } + void doUnlock() { } +private: + QImage *m_image; + bool m_deleteImage; +}; diff --git a/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h b/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h new file mode 100644 index 0000000..b42021e --- /dev/null +++ b/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h @@ -0,0 +1,47 @@ +#include +#include +#include +#include +#include + +#include "qblittable_image.h" + +class QImageBlittableWindowSurface : public QRasterBlittableWindowSurface +{ +public: + QImageBlittableWindowSurface(QWidget *widget) + : QRasterBlittableWindowSurface(widget) + {} + + QBlittable *createBlittable(QImage *rasterSurface) + { + return new QImageBlittable(rasterSurface,false); + } + +}; + +class QBlittableGraphicsSystem : public QGraphicsSystem +{ +public: + ~QBlittableGraphicsSystem() { } + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const + { + if (type == QPixmapData::PixmapType) + return new QBlittablePixmapData(type); + else + return new QRasterPixmapData(type); + } + + QWindowSurface *createWindowSurface(QWidget *widget) const + { + return new QImageBlittableWindowSurface(widget); + } + + QBlittable *createBlittable(const QSize &size) const + { + QImage *image = new QImage(size, QImage::Format_ARGB32_Premultiplied); + return new QImageBlittable(image,true); + } +}; + -- cgit v0.12 From a31270b5fc88460d6923ac1f2b5b6e90da59c9c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 29 Mar 2010 13:21:47 +0200 Subject: Compile fix from merging blitter examples. --- src/gui/painting/painting.pri | 2 -- src/plugins/graphicssystems/blittable/qblittable_image.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index a3fe2e1..3273cb3 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -17,7 +17,6 @@ HEADERS += \ painting/qpaintengine_p.h \ painting/qpaintengine_alpha_p.h \ painting/qpaintengine_preview_p.h \ - painting/qpaintengine_blitter_p.h \ painting/qpaintengineex_p.h \ painting/qpainter.h \ painting/qpainter_p.h \ @@ -64,7 +63,6 @@ SOURCES += \ painting/qpaintengine.cpp \ painting/qpaintengine_alpha.cpp \ painting/qpaintengine_preview.cpp \ - painting/qpaintengine_blitter.cpp \ painting/qpaintengineex.cpp \ painting/qpainter.cpp \ painting/qpainterpath.cpp \ diff --git a/src/plugins/graphicssystems/blittable/qblittable_image.h b/src/plugins/graphicssystems/blittable/qblittable_image.h index 8ca86b7..3f8dc69 100644 --- a/src/plugins/graphicssystems/blittable/qblittable_image.h +++ b/src/plugins/graphicssystems/blittable/qblittable_image.h @@ -1,6 +1,6 @@ #include -#include +#include class QImageBlittable : public QBlittable -- cgit v0.12 From a93f6b21f636df4840f86099c76d287afb978001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 31 Mar 2010 09:41:39 +0200 Subject: Refactoring GraphicsSystem to QPlatformIntegration QPlatformIntegration is the "main" integration class which needs to be subclassed. This is done so that we don't pollute GraphicsSystem with functionality that really does not belong there. In lighthouse applications needs now to be started with -platform some_platform --- src/gui/image/qnativeimage.cpp | 2 +- src/gui/image/qpixmap_blitter.cpp | 2 +- src/gui/image/qpixmap_lite.cpp | 2 +- src/gui/kernel/kernel.pri | 10 +- src/gui/kernel/qapplication.cpp | 12 +- src/gui/kernel/qapplication_lite.cpp | 36 +- src/gui/kernel/qapplication_p.h | 15 +- src/gui/kernel/qdesktopwidget_lite.cpp | 24 +- src/gui/kernel/qplatformintegration_lite.cpp | 18 + src/gui/kernel/qplatformintegration_lite.h | 73 + .../kernel/qplatformintegrationfactory_lite.cpp | 88 + .../kernel/qplatformintegrationfactory_lite_p.h | 78 + src/gui/kernel/qplatformintegrationplugin_lite.cpp | 55 + src/gui/kernel/qplatformintegrationplugin_lite.h | 92 + src/gui/kernel/qplatformscreen_lite.cpp | 15 + src/gui/kernel/qplatformscreen_lite.h | 31 + src/gui/kernel/qwidget_lite.cpp | 14 +- src/gui/kernel/qwindowsysteminterface.h | 16 +- src/gui/painting/painting.pri | 6 +- src/gui/painting/qcolormap_lite.cpp | 8 +- src/gui/painting/qgraphicssystem.cpp | 54 +- src/gui/painting/qgraphicssystem_lite.cpp | 62 + src/gui/painting/qgraphicssystem_lite_p.h | 70 + src/gui/painting/qgraphicssystem_p.h | 27 +- src/gui/painting/qgraphicssystemcursor_lite.cpp | 2 +- src/gui/painting/qgraphicssystemcursor_lite.h | 5 +- .../graphicssystems/blittable/blittable.pro | 3 +- .../blittable/qgraphicssystem_blittable.h | 6 + src/plugins/graphicssystems/fb_base/fb_base.cpp | 364 ---- src/plugins/graphicssystems/fb_base/fb_base.h | 132 -- src/plugins/graphicssystems/fb_base/fb_base.pri | 2 - src/plugins/graphicssystems/fb_base/fb_base.pro | 23 - src/plugins/graphicssystems/graphicssystems.pro | 8 - src/plugins/graphicssystems/linuxfb/linuxfb.pro | 12 - src/plugins/graphicssystems/linuxfb/main.cpp | 71 - .../linuxfb/qgraphicssystem_linuxfb.cpp | 856 --------- .../linuxfb/qgraphicssystem_linuxfb.h | 128 -- src/plugins/graphicssystems/minimal/main.cpp | 71 - src/plugins/graphicssystems/minimal/minimal.pro | 10 - .../minimal/qgraphicssystem_minimal.cpp | 70 - .../minimal/qgraphicssystem_minimal.h | 85 - .../minimal/qwindowsurface_minimal.cpp | 101 - .../minimal/qwindowsurface_minimal.h | 73 - src/plugins/graphicssystems/minimaldfb/main.cpp | 71 - .../graphicssystems/minimaldfb/minimaldfb.pro | 29 - .../minimaldfb/qblitter_directfb.cpp | 110 -- .../graphicssystems/minimaldfb/qblitter_directfb.h | 29 - .../minimaldfb/qdirectfbconvenience.cpp | 335 ---- .../minimaldfb/qdirectfbconvenience.h | 43 - .../graphicssystems/minimaldfb/qdirectfbcursor.cpp | 42 - .../graphicssystems/minimaldfb/qdirectfbcursor.h | 22 - .../graphicssystems/minimaldfb/qdirectfbinput.cpp | 205 --- .../graphicssystems/minimaldfb/qdirectfbinput.h | 63 - .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 118 -- .../minimaldfb/qgraphicssystem_minimaldfb.h | 99 - .../minimaldfb/qwindowsurface_minimaldfb.cpp | 231 --- .../minimaldfb/qwindowsurface_minimaldfb.h | 88 - src/plugins/graphicssystems/openkode/frag.glslf | 8 - src/plugins/graphicssystems/openkode/frag.h | 37 - src/plugins/graphicssystems/openkode/main.cpp | 71 - src/plugins/graphicssystems/openkode/openkode.pro | 14 - .../openkode/qgraphicssystem_openkode.cpp | 236 --- .../openkode/qgraphicssystem_openkode.h | 95 - .../openkode/qwindowsurface_openkode.cpp | 265 --- .../openkode/qwindowsurface_openkode.h | 79 - src/plugins/graphicssystems/openkode/vert.glslv | 14 - src/plugins/graphicssystems/openkode/vert.h | 63 - src/plugins/graphicssystems/openvglite/main.cpp | 71 - .../graphicssystems/openvglite/openvglite.pro | 12 - .../openvglite/qgraphicssystem_vglite.cpp | 193 -- .../openvglite/qgraphicssystem_vglite.h | 93 - .../openvglite/qwindowsurface_vglite.cpp | 131 -- .../openvglite/qwindowsurface_vglite.h | 91 - src/plugins/graphicssystems/qvfb/main.cpp | 72 - .../graphicssystems/qvfb/qgraphicssystem_qvfb.cpp | 434 ----- .../graphicssystems/qvfb/qgraphicssystem_qvfb.h | 95 - src/plugins/graphicssystems/qvfb/qvfb.pro | 12 - .../graphicssystems/qvfb/qwindowsurface_qvfb.cpp | 104 -- .../graphicssystems/qvfb/qwindowsurface_qvfb.h | 74 - src/plugins/graphicssystems/testlite/main.cpp | 71 - .../testlite/qgraphicssystem_testlite.cpp | 121 -- .../testlite/qgraphicssystem_testlite.h | 91 - .../testlite/qwindowsurface_testlite.cpp | 661 ------- .../testlite/qwindowsurface_testlite.h | 96 - src/plugins/graphicssystems/testlite/testlite.pro | 17 - src/plugins/graphicssystems/testlite/x11util.cpp | 1215 ------------ src/plugins/graphicssystems/testlite/x11util.h | 204 --- src/plugins/graphicssystems/vnc/main.cpp | 72 - .../graphicssystems/vnc/qgraphicssystem_vnc.cpp | 115 -- .../graphicssystems/vnc/qgraphicssystem_vnc.h | 97 - src/plugins/graphicssystems/vnc/qvnccursor.cpp | 156 -- src/plugins/graphicssystems/vnc/qvnccursor.h | 76 - src/plugins/graphicssystems/vnc/qvncserver.cpp | 1935 -------------------- src/plugins/graphicssystems/vnc/qvncserver.h | 534 ------ src/plugins/graphicssystems/vnc/vnc.pro | 19 - src/plugins/platforms/fb_base/fb_base.cpp | 364 ++++ src/plugins/platforms/fb_base/fb_base.h | 132 ++ src/plugins/platforms/fb_base/fb_base.pri | 2 + src/plugins/platforms/fb_base/fb_base.pro | 23 + src/plugins/platforms/linuxfb/linuxfb.pro | 12 + src/plugins/platforms/linuxfb/main.cpp | 71 + .../platforms/linuxfb/qgraphicssystem_linuxfb.cpp | 856 +++++++++ .../platforms/linuxfb/qgraphicssystem_linuxfb.h | 128 ++ src/plugins/platforms/minimal/main.cpp | 71 + src/plugins/platforms/minimal/minimal.pro | 13 + .../minimal/qplatformintegration_minimal.cpp | 25 + .../minimal/qplatformintegration_minimal.h | 85 + .../platforms/minimal/qwindowsurface_minimal.cpp | 85 + .../platforms/minimal/qwindowsurface_minimal.h | 65 + src/plugins/platforms/minimaldfb/main.cpp | 71 + src/plugins/platforms/minimaldfb/minimaldfb.pro | 29 + .../platforms/minimaldfb/qblitter_directfb.cpp | 110 ++ .../platforms/minimaldfb/qblitter_directfb.h | 29 + .../platforms/minimaldfb/qdirectfbconvenience.cpp | 335 ++++ .../platforms/minimaldfb/qdirectfbconvenience.h | 43 + .../platforms/minimaldfb/qdirectfbcursor.cpp | 42 + src/plugins/platforms/minimaldfb/qdirectfbcursor.h | 22 + .../platforms/minimaldfb/qdirectfbinput.cpp | 205 +++ src/plugins/platforms/minimaldfb/qdirectfbinput.h | 63 + .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 118 ++ .../minimaldfb/qgraphicssystem_minimaldfb.h | 99 + .../minimaldfb/qwindowsurface_minimaldfb.cpp | 231 +++ .../minimaldfb/qwindowsurface_minimaldfb.h | 88 + src/plugins/platforms/openkode/frag.glslf | 8 + src/plugins/platforms/openkode/frag.h | 37 + src/plugins/platforms/openkode/main.cpp | 71 + src/plugins/platforms/openkode/openkode.pro | 14 + .../openkode/qgraphicssystem_openkode.cpp | 236 +++ .../platforms/openkode/qgraphicssystem_openkode.h | 95 + .../platforms/openkode/qwindowsurface_openkode.cpp | 265 +++ .../platforms/openkode/qwindowsurface_openkode.h | 79 + src/plugins/platforms/openkode/vert.glslv | 14 + src/plugins/platforms/openkode/vert.h | 63 + src/plugins/platforms/openvglite/main.cpp | 71 + src/plugins/platforms/openvglite/openvglite.pro | 12 + .../openvglite/qgraphicssystem_vglite.cpp | 193 ++ .../platforms/openvglite/qgraphicssystem_vglite.h | 93 + .../platforms/openvglite/qwindowsurface_vglite.cpp | 131 ++ .../platforms/openvglite/qwindowsurface_vglite.h | 91 + src/plugins/platforms/platforms.pro | 14 + src/plugins/platforms/qvfb/main.cpp | 72 + .../platforms/qvfb/qgraphicssystem_qvfb.cpp | 434 +++++ src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h | 95 + src/plugins/platforms/qvfb/qvfb.pro | 12 + src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp | 104 ++ src/plugins/platforms/qvfb/qwindowsurface_qvfb.h | 74 + src/plugins/platforms/testlite/main.cpp | 71 + .../testlite/qgraphicssystem_testlite.cpp | 121 ++ .../platforms/testlite/qgraphicssystem_testlite.h | 91 + .../platforms/testlite/qwindowsurface_testlite.cpp | 661 +++++++ .../platforms/testlite/qwindowsurface_testlite.h | 96 + src/plugins/platforms/testlite/testlite.pro | 17 + src/plugins/platforms/testlite/x11util.cpp | 1215 ++++++++++++ src/plugins/platforms/testlite/x11util.h | 204 +++ src/plugins/platforms/vnc/main.cpp | 72 + src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp | 115 ++ src/plugins/platforms/vnc/qgraphicssystem_vnc.h | 97 + src/plugins/platforms/vnc/qvnccursor.cpp | 156 ++ src/plugins/platforms/vnc/qvnccursor.h | 76 + src/plugins/platforms/vnc/qvncserver.cpp | 1935 ++++++++++++++++++++ src/plugins/platforms/vnc/qvncserver.h | 534 ++++++ src/plugins/platforms/vnc/vnc.pro | 19 + 162 files changed, 11867 insertions(+), 11369 deletions(-) create mode 100644 src/gui/kernel/qplatformintegration_lite.cpp create mode 100644 src/gui/kernel/qplatformintegration_lite.h create mode 100644 src/gui/kernel/qplatformintegrationfactory_lite.cpp create mode 100644 src/gui/kernel/qplatformintegrationfactory_lite_p.h create mode 100644 src/gui/kernel/qplatformintegrationplugin_lite.cpp create mode 100644 src/gui/kernel/qplatformintegrationplugin_lite.h create mode 100644 src/gui/kernel/qplatformscreen_lite.cpp create mode 100644 src/gui/kernel/qplatformscreen_lite.h create mode 100644 src/gui/painting/qgraphicssystem_lite.cpp create mode 100644 src/gui/painting/qgraphicssystem_lite_p.h delete mode 100644 src/plugins/graphicssystems/fb_base/fb_base.cpp delete mode 100644 src/plugins/graphicssystems/fb_base/fb_base.h delete mode 100644 src/plugins/graphicssystems/fb_base/fb_base.pri delete mode 100644 src/plugins/graphicssystems/fb_base/fb_base.pro delete mode 100644 src/plugins/graphicssystems/linuxfb/linuxfb.pro delete mode 100644 src/plugins/graphicssystems/linuxfb/main.cpp delete mode 100644 src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp delete mode 100644 src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h delete mode 100644 src/plugins/graphicssystems/minimal/main.cpp delete mode 100644 src/plugins/graphicssystems/minimal/minimal.pro delete mode 100644 src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp delete mode 100644 src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h delete mode 100644 src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp delete mode 100644 src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h delete mode 100644 src/plugins/graphicssystems/minimaldfb/main.cpp delete mode 100644 src/plugins/graphicssystems/minimaldfb/minimaldfb.pro delete mode 100644 src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp delete mode 100644 src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h delete mode 100644 src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp delete mode 100644 src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h delete mode 100644 src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp delete mode 100644 src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.h delete mode 100644 src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp delete mode 100644 src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h delete mode 100644 src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp delete mode 100644 src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h delete mode 100644 src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp delete mode 100644 src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h delete mode 100644 src/plugins/graphicssystems/openkode/frag.glslf delete mode 100644 src/plugins/graphicssystems/openkode/frag.h delete mode 100644 src/plugins/graphicssystems/openkode/main.cpp delete mode 100644 src/plugins/graphicssystems/openkode/openkode.pro delete mode 100644 src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.cpp delete mode 100644 src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.h delete mode 100644 src/plugins/graphicssystems/openkode/qwindowsurface_openkode.cpp delete mode 100644 src/plugins/graphicssystems/openkode/qwindowsurface_openkode.h delete mode 100644 src/plugins/graphicssystems/openkode/vert.glslv delete mode 100644 src/plugins/graphicssystems/openkode/vert.h delete mode 100644 src/plugins/graphicssystems/openvglite/main.cpp delete mode 100644 src/plugins/graphicssystems/openvglite/openvglite.pro delete mode 100644 src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp delete mode 100644 src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h delete mode 100644 src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp delete mode 100644 src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h delete mode 100644 src/plugins/graphicssystems/qvfb/main.cpp delete mode 100644 src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp delete mode 100644 src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.h delete mode 100644 src/plugins/graphicssystems/qvfb/qvfb.pro delete mode 100644 src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp delete mode 100644 src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.h delete mode 100644 src/plugins/graphicssystems/testlite/main.cpp delete mode 100644 src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp delete mode 100644 src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h delete mode 100644 src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp delete mode 100644 src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h delete mode 100644 src/plugins/graphicssystems/testlite/testlite.pro delete mode 100644 src/plugins/graphicssystems/testlite/x11util.cpp delete mode 100644 src/plugins/graphicssystems/testlite/x11util.h delete mode 100644 src/plugins/graphicssystems/vnc/main.cpp delete mode 100644 src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp delete mode 100644 src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h delete mode 100644 src/plugins/graphicssystems/vnc/qvnccursor.cpp delete mode 100644 src/plugins/graphicssystems/vnc/qvnccursor.h delete mode 100644 src/plugins/graphicssystems/vnc/qvncserver.cpp delete mode 100644 src/plugins/graphicssystems/vnc/qvncserver.h delete mode 100644 src/plugins/graphicssystems/vnc/vnc.pro create mode 100644 src/plugins/platforms/fb_base/fb_base.cpp create mode 100644 src/plugins/platforms/fb_base/fb_base.h create mode 100644 src/plugins/platforms/fb_base/fb_base.pri create mode 100644 src/plugins/platforms/fb_base/fb_base.pro create mode 100644 src/plugins/platforms/linuxfb/linuxfb.pro create mode 100644 src/plugins/platforms/linuxfb/main.cpp create mode 100644 src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp create mode 100644 src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h create mode 100644 src/plugins/platforms/minimal/main.cpp create mode 100644 src/plugins/platforms/minimal/minimal.pro create mode 100644 src/plugins/platforms/minimal/qplatformintegration_minimal.cpp create mode 100644 src/plugins/platforms/minimal/qplatformintegration_minimal.h create mode 100644 src/plugins/platforms/minimal/qwindowsurface_minimal.cpp create mode 100644 src/plugins/platforms/minimal/qwindowsurface_minimal.h create mode 100644 src/plugins/platforms/minimaldfb/main.cpp create mode 100644 src/plugins/platforms/minimaldfb/minimaldfb.pro create mode 100644 src/plugins/platforms/minimaldfb/qblitter_directfb.cpp create mode 100644 src/plugins/platforms/minimaldfb/qblitter_directfb.h create mode 100644 src/plugins/platforms/minimaldfb/qdirectfbconvenience.cpp create mode 100644 src/plugins/platforms/minimaldfb/qdirectfbconvenience.h create mode 100644 src/plugins/platforms/minimaldfb/qdirectfbcursor.cpp create mode 100644 src/plugins/platforms/minimaldfb/qdirectfbcursor.h create mode 100644 src/plugins/platforms/minimaldfb/qdirectfbinput.cpp create mode 100644 src/plugins/platforms/minimaldfb/qdirectfbinput.h create mode 100644 src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.cpp create mode 100644 src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.h create mode 100644 src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.cpp create mode 100644 src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.h create mode 100644 src/plugins/platforms/openkode/frag.glslf create mode 100644 src/plugins/platforms/openkode/frag.h create mode 100644 src/plugins/platforms/openkode/main.cpp create mode 100644 src/plugins/platforms/openkode/openkode.pro create mode 100644 src/plugins/platforms/openkode/qgraphicssystem_openkode.cpp create mode 100644 src/plugins/platforms/openkode/qgraphicssystem_openkode.h create mode 100644 src/plugins/platforms/openkode/qwindowsurface_openkode.cpp create mode 100644 src/plugins/platforms/openkode/qwindowsurface_openkode.h create mode 100644 src/plugins/platforms/openkode/vert.glslv create mode 100644 src/plugins/platforms/openkode/vert.h create mode 100644 src/plugins/platforms/openvglite/main.cpp create mode 100644 src/plugins/platforms/openvglite/openvglite.pro create mode 100644 src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp create mode 100644 src/plugins/platforms/openvglite/qgraphicssystem_vglite.h create mode 100644 src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp create mode 100644 src/plugins/platforms/openvglite/qwindowsurface_vglite.h create mode 100644 src/plugins/platforms/platforms.pro create mode 100644 src/plugins/platforms/qvfb/main.cpp create mode 100644 src/plugins/platforms/qvfb/qgraphicssystem_qvfb.cpp create mode 100644 src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h create mode 100644 src/plugins/platforms/qvfb/qvfb.pro create mode 100644 src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp create mode 100644 src/plugins/platforms/qvfb/qwindowsurface_qvfb.h create mode 100644 src/plugins/platforms/testlite/main.cpp create mode 100644 src/plugins/platforms/testlite/qgraphicssystem_testlite.cpp create mode 100644 src/plugins/platforms/testlite/qgraphicssystem_testlite.h create mode 100644 src/plugins/platforms/testlite/qwindowsurface_testlite.cpp create mode 100644 src/plugins/platforms/testlite/qwindowsurface_testlite.h create mode 100644 src/plugins/platforms/testlite/testlite.pro create mode 100644 src/plugins/platforms/testlite/x11util.cpp create mode 100644 src/plugins/platforms/testlite/x11util.h create mode 100644 src/plugins/platforms/vnc/main.cpp create mode 100644 src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp create mode 100644 src/plugins/platforms/vnc/qgraphicssystem_vnc.h create mode 100644 src/plugins/platforms/vnc/qvnccursor.cpp create mode 100644 src/plugins/platforms/vnc/qvnccursor.h create mode 100644 src/plugins/platforms/vnc/qvncserver.cpp create mode 100644 src/plugins/platforms/vnc/qvncserver.h create mode 100644 src/plugins/platforms/vnc/vnc.pro diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp index 3420778..d4cbdc6 100644 --- a/src/gui/image/qnativeimage.cpp +++ b/src/gui/image/qnativeimage.cpp @@ -288,7 +288,7 @@ QNativeImage::~QNativeImage() QImage::Format QNativeImage::systemFormat() { #ifdef Q_WS_LITE - return QApplicationPrivate::graphicsSystem()->screens().at(0)->format(); + return QApplicationPrivate::platformIntegration()->screens().at(0)->format(); #else return QImage::Format_RGB32; #endif diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 6dcf7c7..38a2f81 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -57,7 +57,7 @@ void QBlittablePixmapData::resize(int width, int height) delete m_engine; m_engine = 0; #ifdef Q_WS_LITE - d = QApplicationPrivate::graphicsSystem()->screens().at(0)->depth(); + d = QApplicationPrivate::platformIntegration()->screens().at(0)->depth(); #endif w = width; h = height; diff --git a/src/gui/image/qpixmap_lite.cpp b/src/gui/image/qpixmap_lite.cpp index d263855..61be216 100644 --- a/src/gui/image/qpixmap_lite.cpp +++ b/src/gui/image/qpixmap_lite.cpp @@ -45,5 +45,5 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) { - return QApplicationPrivate::graphicsSystem()->grabWindow(window, x, y, w, h); + return QApplicationPrivate::platformIntegration()->grabWindow(window, x, y, w, h); } diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 96892d2..cf5ec92 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -203,6 +203,10 @@ embedded_lite { kernel/qgenericplugin_lite.h \ kernel/qeventdispatcher_lite_p.h \ kernel/qwindowsysteminterface.h \ + kernel/qplatformintegration_lite.h \ + kernel/qplatformscreen_lite.h \ + kernel/qplatformintegrationfactory_lite_p.h \ + kernel/qplatformintegrationplugin_lite.h \ SOURCES += \ kernel/qapplication_lite.cpp \ @@ -216,7 +220,11 @@ embedded_lite { kernel/qsound_lite.cpp \ kernel/qwidget_lite.cpp \ kernel/qeventdispatcher_lite.cpp \ - kernel/qwindowsysteminterface.cpp + kernel/qwindowsysteminterface.cpp \ + kernel/qplatformintegration_lite.cpp \ + kernel/qplatformscreen_lite.cpp \ + kernel/qplatformintegrationfactory_lite.cpp \ + kernel/qplatformintegrationplugin_lite.cpp contains(QT_CONFIG, glib) { SOURCES += \ diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 4782d7c..a188276 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -441,6 +441,9 @@ QPalette *QApplicationPrivate::sys_pal = 0; // default system palette QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system +#if defined(Q_WS_LITE) +QPlatformIntegration *QApplicationPrivate::platform_integration = 0; +#endif QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization Q_GLOBAL_STATIC(QMutex, applicationFontMutex) @@ -771,7 +774,6 @@ void QApplicationPrivate::construct( ) { initResources(); - graphics_system_name = QLatin1String(qgetenv("QT_DEFAULT_GRAPHICS_SYSTEM")); qt_is_gui_used = (qt_appType != QApplication::Tty); @@ -939,10 +941,12 @@ void QApplicationPrivate::initialize() // Set up which span functions should be used in raster engine... qInitDrawhelperAsm(); -#if !defined(Q_WS_X11) && !defined(Q_WS_QWS) +#if !defined(Q_WS_X11) && !defined(Q_WS_QWS) && !defined(Q_WS_LITE) // initialize the graphics system - on X11 this is initialized inside // qt_init() in qapplication_x11.cpp because of several reasons. // On QWS, the graphics system is set by the QScreen plugin. + // For lighthouse it will be initialized to QLiteGraphicsSystem + // when the platformIntegration plugin is instansiated in qt_init( graphics_system = QGraphicsSystemFactory::create(graphics_system_name); #endif #ifndef QT_NO_WHEELEVENT @@ -1561,7 +1565,11 @@ QStyle* QApplication::setStyle(const QString& style) void QApplication::setGraphicsSystem(const QString &system) { +#if !defined(Q_WS_LITE) QApplicationPrivate::graphics_system_name = system; +#else + Q_UNUSED(system) +#endif } /*! diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 5d7ab5a..c8d65ff 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -53,13 +53,15 @@ #include "private/qwidget_p.h" #include "qgenericpluginfactory_lite.h" +#include "qplatformintegrationfactory_lite_p.h" #include #include -#include "private/qgraphicssystem_p.h" +#include #include #include #include +#include QT_BEGIN_NAMESPACE @@ -386,10 +388,9 @@ void QApplication::restoreOverrideCursor() QWidget *QApplication::topLevelAt(const QPoint &pos) { - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return 0; - QGraphicsSystemScreen *screen = gs->screens().first(); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + + QPlatformScreen *screen = pi->screens().first(); if (!screen) return 0; QWidget *w = screen->topLevelAt(pos); @@ -404,6 +405,23 @@ void QApplication::alert(QWidget *, int) { } +static void init_platform(const QString &name) +{ + QApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name); + QApplicationPrivate::graphics_system = new QLiteGraphicsSystem; + if (!QApplicationPrivate::platform_integration) { + QStringList keys = QPlatformIntegrationFactory::keys(); + QString fatalMessage = + QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name); + foreach(QString key, keys) { + fatalMessage.append(key + QString::fromLatin1("\n")); + } + qFatal("%s", fatalMessage.toLocal8Bit().constData()); + + } + +} + static void init_plugins(const QList pluginList) { for (int i = 0; i < pluginList.count(); ++i) { @@ -447,6 +465,7 @@ void qt_init(QApplicationPrivate *priv, int type) } QList pluginList; + QString platformName = qgetenv("QT_LITE_PLATFORM"); // Get command line params @@ -460,6 +479,9 @@ void qt_init(QApplicationPrivate *priv, int type) if (arg == "-fn" || arg == "-font") { if (++i < argc) appFont = argv[i]; + } else if (arg == "-platform") { + if (++i < argc) + platformName = argv[i]; } else if (arg == "-plugin") { if (++i < argc) pluginList << argv[i]; @@ -473,9 +495,6 @@ void qt_init(QApplicationPrivate *priv, int type) priv->argc = j; } - - - #if 0 QByteArray pluginEnv = qgetenv("QT_LITE_PLUGINS"); if (!pluginEnv.isEmpty()) { @@ -483,6 +502,7 @@ void qt_init(QApplicationPrivate *priv, int type) } #endif + init_platform(platformName); init_plugins(pluginList); QColormap::initialize(); diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 2cf5fce..d0ab0c4 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -78,6 +78,7 @@ #endif #ifdef Q_WS_LITE #include +#include "QtGui/qplatformintegration_lite.h" #endif QT_BEGIN_NAMESPACE @@ -312,10 +313,15 @@ public: static QString desktopStyleKey(); static QGraphicsSystem *graphicsSystem() -#if !defined(Q_WS_QWS) - { return graphics_system; } -#else +#if defined(Q_WS_QWS) { return QScreen::instance()->graphicsSystem(); } +#else + { return graphics_system; } +#endif + +#if defined(Q_WS_LITE) + static QPlatformIntegration *platformIntegration() + { return platform_integration; } #endif void createEventDispatcher(); @@ -417,6 +423,9 @@ public: static QPalette *set_pal; static QGraphicsSystem *graphics_system; static QString graphics_system_name; +#if defined(Q_WS_LITE) + static QPlatformIntegration *platform_integration; +#endif private: static QFont *app_font; // private for a reason! Always use QApplication::font() instead! diff --git a/src/gui/kernel/qdesktopwidget_lite.cpp b/src/gui/kernel/qdesktopwidget_lite.cpp index a3535fb..b077d57 100644 --- a/src/gui/kernel/qdesktopwidget_lite.cpp +++ b/src/gui/kernel/qdesktopwidget_lite.cpp @@ -69,10 +69,8 @@ int QDesktopWidget::primaryScreen() const int QDesktopWidget::numScreens() const { - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return 0; - return qMax(gs->screens().size(), 1); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + return qMax(pi->screens().size(), 1); } QWidget *QDesktopWidget::screen(int) @@ -82,10 +80,8 @@ QWidget *QDesktopWidget::screen(int) const QRect QDesktopWidget::availableGeometry(int screenNo) const { - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return QRect(); - QList screens = gs->screens(); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList screens = pi->screens(); if (screenNo == -1) screenNo = 0; if (screenNo < 0 || screenNo >= screens.size()) @@ -96,10 +92,8 @@ const QRect QDesktopWidget::availableGeometry(int screenNo) const const QRect QDesktopWidget::screenGeometry(int screenNo) const { - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return QRect(); - QList screens = gs->screens(); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList screens = pi->screens(); if (screenNo == -1) screenNo = 0; if (screenNo < 0 || screenNo >= screens.size()) @@ -122,10 +116,8 @@ int QDesktopWidget::screenNumber(const QWidget *w) const int QDesktopWidget::screenNumber(const QPoint &p) const { - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return -1; - QList screens = gs->screens(); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList screens = pi->screens(); for (int i = 0; i < screens.size(); ++i) if (screens[i]->geometry().contains(p)) diff --git a/src/gui/kernel/qplatformintegration_lite.cpp b/src/gui/kernel/qplatformintegration_lite.cpp new file mode 100644 index 0000000..0e28fc6 --- /dev/null +++ b/src/gui/kernel/qplatformintegration_lite.cpp @@ -0,0 +1,18 @@ +#include "qplatformintegration_lite.h" + +QT_BEGIN_NAMESPACE + +QBlittable *QPlatformIntegration::createBlittable(const QSize &) const +{ return 0; } + +QPixmap QPlatformIntegration::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(); +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h new file mode 100644 index 0000000..543b7bc --- /dev/null +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 QPLATFORMINTEGRATION_H +#define QPLATFORMINTEGRATION_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class Q_GUI_EXPORT QPlatformIntegration +{ +public: + virtual ~QPlatformIntegration() { }; + +// GraphicsSystem functions + virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; + virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0; + virtual QBlittable *createBlittable(const QSize &size) const; + +// Window System functions + virtual QList screens() const = 0; + virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMINTEGRATION_H diff --git a/src/gui/kernel/qplatformintegrationfactory_lite.cpp b/src/gui/kernel/qplatformintegrationfactory_lite.cpp new file mode 100644 index 0000000..7f650e9 --- /dev/null +++ b/src/gui/kernel/qplatformintegrationfactory_lite.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 "qplatformintegrationfactory_lite_p.h" +#include +#include "private/qfactoryloader_p.h" +#include "qmutex.h" + +#include "qapplication.h" +#include "qdebug.h" + +QT_BEGIN_NAMESPACE + +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, + (QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive)) +#endif + +QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key) +{ + QPlatformIntegration *ret = 0; + QString platform = key.toLower(); + + qDebug() << loader()->keys(); +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + if (QPlatformIntegrationFactoryInterface *factory = qobject_cast(loader()->instance(platform))) + ret = factory->create(platform); +#endif + + return ret; +} + +/*! + Returns the list of valid keys, i.e. the keys this factory can + create styles for. + + \sa create() +*/ +QStringList QPlatformIntegrationFactory::keys() +{ +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + QStringList list = loader()->keys(); +#else + QStringList list; +#endif + return list; +} + +QT_END_NAMESPACE + diff --git a/src/gui/kernel/qplatformintegrationfactory_lite_p.h b/src/gui/kernel/qplatformintegrationfactory_lite_p.h new file mode 100644 index 0000000..ba02d2c --- /dev/null +++ b/src/gui/kernel/qplatformintegrationfactory_lite_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 QPLATFORMINTEGRATIONFACTORY_H +#define QPLATFORMINTEGRATIONFACTORY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QPlatformIntegration; + +class QPlatformIntegrationFactory +{ +public: + static QStringList keys(); + static QPlatformIntegration *create(const QString&); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMINTEGRATIONFACTORY_H + diff --git a/src/gui/kernel/qplatformintegrationplugin_lite.cpp b/src/gui/kernel/qplatformintegrationplugin_lite.cpp new file mode 100644 index 0000000..cb1ed83 --- /dev/null +++ b/src/gui/kernel/qplatformintegrationplugin_lite.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** 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 "qplatformintegrationplugin_lite.h" + +QT_BEGIN_NAMESPACE + +QPlatformIntegrationPlugin::QPlatformIntegrationPlugin(QObject *parent) + : QObject(parent) +{ +} + +QPlatformIntegrationPlugin::~QPlatformIntegrationPlugin() +{ +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegrationplugin_lite.h b/src/gui/kernel/qplatformintegrationplugin_lite.h new file mode 100644 index 0000000..0e116f2 --- /dev/null +++ b/src/gui/kernel/qplatformintegrationplugin_lite.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** 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 QPLATFORMINTEGRATIONPLUGIN_H +#define QPLATFORMINTEGRATIONPLUGIN_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QPlatformIntegration; + +struct QPlatformIntegrationFactoryInterface : public QFactoryInterface +{ + virtual QPlatformIntegration *create(const QString &key) = 0; +}; + +#define QPlatformIntegrationFactoryInterface_iid "com.nokia.Qt.QPlatformIntegrationFactoryInterface" + +Q_DECLARE_INTERFACE(QPlatformIntegrationFactoryInterface, QPlatformIntegrationFactoryInterface_iid) + +class Q_GUI_EXPORT QPlatformIntegrationPlugin : public QObject, public QPlatformIntegrationFactoryInterface +{ + Q_OBJECT + Q_INTERFACES(QPlatformIntegrationFactoryInterface:QFactoryInterface) +public: + explicit QPlatformIntegrationPlugin(QObject *parent = 0); + ~QPlatformIntegrationPlugin(); + + virtual QStringList keys() const = 0; + virtual QPlatformIntegration *create(const QString &key) = 0; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMINTEGRATIONPLUGIN_H diff --git a/src/gui/kernel/qplatformscreen_lite.cpp b/src/gui/kernel/qplatformscreen_lite.cpp new file mode 100644 index 0000000..f2ea2f8 --- /dev/null +++ b/src/gui/kernel/qplatformscreen_lite.cpp @@ -0,0 +1,15 @@ +#include "qplatformscreen_lite.h" + +QWidget *QPlatformScreen::topLevelAt(const QPoint & pos) const +{ + QWidgetList list = QApplication::topLevelWidgets(); + for (int i = list.size()-1; i >= 0; --i) { + QWidget *w = list[i]; + //### mask is ignored + if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos)) + return w; + } + + return 0; +} + diff --git a/src/gui/kernel/qplatformscreen_lite.h b/src/gui/kernel/qplatformscreen_lite.h new file mode 100644 index 0000000..ef90dee --- /dev/null +++ b/src/gui/kernel/qplatformscreen_lite.h @@ -0,0 +1,31 @@ +#ifndef QPLATFORMSCREEN_H +#define QPLATFORMSCREEN_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class Q_GUI_EXPORT QPlatformScreen +{ +public: + virtual ~QPlatformScreen() { } + + virtual QRect geometry() const = 0; + virtual QRect availableGeometry() const {return geometry();}; + virtual int depth() const = 0; + virtual QImage::Format format() const = 0; + virtual QSize physicalSize() const = 0; + virtual void setDirty(const QRect &) {} + virtual QWidget *topLevelAt(const QPoint &point) const; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMSCREEN_H diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index bcbcd82..add5592 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -51,7 +51,7 @@ #include QT_BEGIN_NAMESPACE -static QGraphicsSystemScreen *qt_screenForWidget(const QWidget *w); +static QPlatformScreen *qt_screenForWidget(const QWidget *w); void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool /*destroyOldWindow*/) { @@ -535,7 +535,7 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) scrollRect(r, dx, dy); } -static QGraphicsSystemScreen *qt_screenForWidget(const QWidget *w) +static QPlatformScreen *qt_screenForWidget(const QWidget *w) { if (!w) return 0; @@ -544,12 +544,8 @@ static QGraphicsSystemScreen *qt_screenForWidget(const QWidget *w) frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0))); const QPoint p = (frame.topLeft() + frame.bottomRight()) / 2; - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) { - qWarning("qt_screenForWidget: no graphics system"); - return 0; - } - QList screens = gs->screens(); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList screens = pi->screens(); for (int i = 0; i < screens.size(); ++i) { if (screens[i]->geometry().contains(p)) @@ -569,7 +565,7 @@ int QWidget::metric(PaintDeviceMetric m) const { Q_D(const QWidget); - QGraphicsSystemScreen *screen = qt_screenForWidget(this); + QPlatformScreen *screen = qt_screenForWidget(this); if (!screen) { if (m == PdmDpiX || m == PdmDpiY) return 72; diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index fee7e75..70b2830 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -41,14 +41,18 @@ #ifndef QWINDOWSYSTEMINTERFACE_H #define QWINDOWSYSTEMINTERFACE_H -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +QT_MODULE(Gui) + class Q_GUI_EXPORT QWindowSystemInterface { public: @@ -129,5 +133,7 @@ public: static QWindowSystemInterface::UserEvent * getUserEvent() { return userEventQueue.takeFirst(); } static void queueUserEvent(QWindowSystemInterface::UserEvent *ev) { userEventQueue.append(ev); } }; + QT_END_NAMESPACE +QT_END_HEADER #endif // QWINDOWSYSTEMINTERFACE_H diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 3273cb3..c4e8f7a 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -187,9 +187,11 @@ embedded_lite { SOURCES += \ painting/qcolormap_lite.cpp \ painting/qpaintdevice_lite.cpp \ - painting/qgraphicssystemcursor_lite.cpp + painting/qgraphicssystemcursor_lite.cpp \ + painting/qgraphicssystem_lite.cpp HEADERS += \ - painting/qgraphicssystemcursor_lite.h + painting/qgraphicssystemcursor_lite.h \ + painting/qgraphicssystem_lite_p.h } symbian { diff --git a/src/gui/painting/qcolormap_lite.cpp b/src/gui/painting/qcolormap_lite.cpp index 1c1e9cf..1f4fea8 100644 --- a/src/gui/painting/qcolormap_lite.cpp +++ b/src/gui/painting/qcolormap_lite.cpp @@ -67,12 +67,8 @@ void QColormap::initialize() { screenMap = new QColormapPrivate; - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return; - QList screens = gs->screens(); - if (screens.isEmpty()) - return; + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList screens = pi->screens(); screenMap->depth = screens[0]->depth(); if (screenMap->depth < 8) { diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp index ebc504b..c9866ae 100644 --- a/src/gui/painting/qgraphicssystem.cpp +++ b/src/gui/painting/qgraphicssystem.cpp @@ -51,9 +51,7 @@ # include #endif #ifdef Q_WS_LITE -# include -# include -# include +# include #endif #ifdef Q_WS_S60 # include @@ -65,6 +63,9 @@ QGraphicsSystem::~QGraphicsSystem() { } +QBlittable *QGraphicsSystem::createBlittable(const QSize &) const +{ return 0; } + QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType type) { #ifdef Q_WS_QWS @@ -77,7 +78,7 @@ QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType typ #elif defined(Q_WS_MAC) return new QMacPixmapData(type); #elif defined(Q_WS_LITE) - return new QRasterPixmapData(type); + return QApplicationPrivate::platformIntegration()->createPixmapData(type); #elif defined(Q_WS_S60) return new QS60PixmapData(type); #elif !defined(Q_WS_QWS) @@ -86,49 +87,4 @@ QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType typ return 0; } -#ifdef Q_WS_LITE -QWidget *QGraphicsSystemScreen::topLevelAt(const QPoint & pos) const -{ - QWidgetList list = QApplication::topLevelWidgets(); - for (int i = list.size()-1; i >= 0; --i) { - QWidget *w = list[i]; - //### mask is ignored - if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos)) - return w; - } - - return 0; -} - -QList QGraphicsSystem::screens() const -{ - return QList(); -} - -QPixmap QGraphicsSystem::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(); -} - - -QGraphicsSystemScreen::QGraphicsSystemScreen(QObject *parent) - : QObject(parent) -{} - -QGraphicsSystemScreen::~QGraphicsSystemScreen() -{ -} - -QRect QGraphicsSystemScreen::availableGeometry() const -{ - return geometry(); -} - -#endif //Q_WS_LITE - QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem_lite.cpp b/src/gui/painting/qgraphicssystem_lite.cpp new file mode 100644 index 0000000..42e7238 --- /dev/null +++ b/src/gui/painting/qgraphicssystem_lite.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** 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 "qgraphicssystem_lite_p.h" +#include + +QT_BEGIN_NAMESPACE + +QPixmapData *QLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return QApplicationPrivate::platformIntegration()->createPixmapData(type); +} + +QWindowSurface *QLiteGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + return QApplicationPrivate::platformIntegration()->createWindowSurface(widget); +} + +QBlittable *QLiteGraphicsSystem::createBlittable(const QSize &size) const +{ + return QApplicationPrivate::platformIntegration()->createBlittable(size); +} + +QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem_lite_p.h b/src/gui/painting/qgraphicssystem_lite_p.h new file mode 100644 index 0000000..e29fa83 --- /dev/null +++ b/src/gui/painting/qgraphicssystem_lite_p.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_MAC_P_H +#define QGRAPHICSSYSTEM_MAC_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 "private/qgraphicssystem_p.h" + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QLiteGraphicsSystem : public QGraphicsSystem +{ +public: + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + QBlittable *createBlittable(const QSize &size) const; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index 03b0f48..e1e15e0 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -64,37 +64,14 @@ QT_BEGIN_NAMESPACE class QPixmapFilter; class QBlittable; -#ifdef Q_WS_LITE -class Q_GUI_EXPORT QGraphicsSystemScreen : public QObject -{ - Q_OBJECT -public: - QGraphicsSystemScreen(QObject *parent = 0); - virtual ~QGraphicsSystemScreen(); - - virtual QRect geometry() const = 0; - virtual QRect availableGeometry() const; - virtual int depth() const = 0; - virtual QImage::Format format() const = 0; - virtual QSize physicalSize() const = 0; - virtual void setDirty(const QRect &) {} - virtual QWidget *topLevelAt(const QPoint &point) const; -}; -#endif // Q_WS_LITE - class Q_GUI_EXPORT QGraphicsSystem { public: virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0; - virtual QBlittable *createBlittable(const QSize &) const { return 0; } - - virtual ~QGraphicsSystem() = 0; + virtual QBlittable *createBlittable(const QSize &size) const; -#ifdef Q_WS_LITE - virtual QList screens() const; - virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; -#endif + virtual ~QGraphicsSystem(); //### Remove this & change qpixmap.cpp & qbitmap.cpp once every platform is gaurenteed // to have a graphics system. diff --git a/src/gui/painting/qgraphicssystemcursor_lite.cpp b/src/gui/painting/qgraphicssystemcursor_lite.cpp index 76b7d97..fdb026c 100644 --- a/src/gui/painting/qgraphicssystemcursor_lite.cpp +++ b/src/gui/painting/qgraphicssystemcursor_lite.cpp @@ -94,7 +94,7 @@ QPointer QGraphicsSystemCursor::instance = 0; Constructs a QGraphicsSystemCursor */ -QGraphicsSystemCursor::QGraphicsSystemCursor(QGraphicsSystemScreen *scr ) +QGraphicsSystemCursor::QGraphicsSystemCursor(QPlatformScreen *scr ) : screen(scr) { instance = this; diff --git a/src/gui/painting/qgraphicssystemcursor_lite.h b/src/gui/painting/qgraphicssystemcursor_lite.h index 0d57d52..5288b83 100644 --- a/src/gui/painting/qgraphicssystemcursor_lite.h +++ b/src/gui/painting/qgraphicssystemcursor_lite.h @@ -47,6 +47,7 @@ #include #include #include "qgraphicssystem_p.h" +#include QT_BEGIN_NAMESPACE @@ -68,7 +69,7 @@ private: class Q_GUI_EXPORT QGraphicsSystemCursor : public QObject { public: - QGraphicsSystemCursor(QGraphicsSystemScreen *); + QGraphicsSystemCursor(QPlatformScreen *); // input methods virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } @@ -79,7 +80,7 @@ public: protected: static QPointer instance; // limit 1 cursor at a time - QGraphicsSystemScreen * screen; // Where to request an update + QPlatformScreen* screen; // Where to request an update }; QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/blittable/blittable.pro b/src/plugins/graphicssystems/blittable/blittable.pro index 596e92f..34c4165 100644 --- a/src/plugins/graphicssystems/blittable/blittable.pro +++ b/src/plugins/graphicssystems/blittable/blittable.pro @@ -5,8 +5,7 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems SOURCES = main.cpp HEADERS = qblittable_image.h \ - qgraphicssystem_blittable.h \ - qwindowsurface_imageblittable.h + qgraphicssystem_blittable.h target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems INSTALLS += target diff --git a/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h b/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h index b42021e..d45907f 100644 --- a/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h +++ b/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h @@ -43,5 +43,11 @@ public: QImage *image = new QImage(size, QImage::Format_ARGB32_Premultiplied); return new QImageBlittable(image,true); } + + QList screens() + { return m_screens; } + + QList m_screens; }; + diff --git a/src/plugins/graphicssystems/fb_base/fb_base.cpp b/src/plugins/graphicssystems/fb_base/fb_base.cpp deleted file mode 100644 index d30746a..0000000 --- a/src/plugins/graphicssystems/fb_base/fb_base.cpp +++ /dev/null @@ -1,364 +0,0 @@ -#include "fb_base.h" - -#include -#include -#include -#include -#include - -QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen *scr) - : QGraphicsSystemCursor(scr), currentRect(QRect()), prevRect(QRect()) -{ - graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); - setCursor(Qt::ArrowCursor); -} - -QRect QGraphicsSystemSoftwareCursor::getCurrentRect() -{ - QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(), - -graphic->hotspot().y()); - rect.translate(QCursor::pos()); - return rect; -} - - -void QGraphicsSystemSoftwareCursor::pointerEvent(const QMouseEvent & e) -{ - Q_UNUSED(e); - currentRect = getCurrentRect(); - screen->setDirty(currentRect); -} - -QRect QGraphicsSystemSoftwareCursor::drawCursor(QPainter & painter) -{ - if (currentRect.isNull()) - return QRect(); - - prevRect = currentRect; - painter.drawImage(prevRect, *graphic->image()); - return prevRect; -} - -QRect QGraphicsSystemSoftwareCursor::dirtyRect() -{ - if (!prevRect.isNull()) { - QRect rect = prevRect; - prevRect = QRect(); - return rect; - } - return QRect(); -} - -void QGraphicsSystemSoftwareCursor::setCursor(Qt::CursorShape shape) -{ - graphic->set(shape); -} - -void QGraphicsSystemSoftwareCursor::setCursor(const QImage * image, int hotx, int hoty) -{ - graphic->set(image, hotx, hoty); -} - -void QGraphicsSystemSoftwareCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) -{ - graphic->set(data, mask, width, height, hotX, hotY); -} - -void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) -{ - Q_UNUSED(widget); - Qt::CursorShape shape = widgetCursor->shape(); - - if (shape == Qt::BitmapCursor) { - // application supplied cursor - QPoint spot = widgetCursor->hotSpot(); - setCursor(&widgetCursor->pixmap().toImage(), spot.x(), spot.y()); - } else { - // system cursor - setCursor(shape); - } - currentRect = getCurrentRect(); - screen->setDirty(currentRect); -} - -QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false) -{ - mScreenImage = new QImage(mGeometry.size(), mFormat); - redrawTimer.setSingleShot(true); - redrawTimer.setInterval(0); - QObject::connect(&redrawTimer, SIGNAL(timeout()), this, SLOT(doRedraw())); -} - -void QGraphicsSystemFbScreen::setGeometry(QRect rect) -{ - delete mScreenImage; - mGeometry = rect; - mScreenImage = new QImage(mGeometry.size(), mFormat); - delete compositePainter; - compositePainter = 0; - invalidateRectCache(); -} - -void QGraphicsSystemFbScreen::setDepth(int depth) -{ - mDepth = depth; -} - -void QGraphicsSystemFbScreen::setPhysicalSize(QSize size) -{ - mPhysicalSize = size; -} - -void QGraphicsSystemFbScreen::setFormat(QImage::Format format) -{ - mFormat = format; - delete mScreenImage; - mScreenImage = new QImage(mGeometry.size(), mFormat); - delete compositePainter; - compositePainter = 0; -} - -QGraphicsSystemFbScreen::~QGraphicsSystemFbScreen() -{ - delete compositePainter; - delete mScreenImage; -} - -void QGraphicsSystemFbScreen::setDirty(const QRect &rect) -{ - repaintRegion += rect; - if (!redrawTimer.isActive()) { - redrawTimer.start(); - } -} - -void QGraphicsSystemFbScreen::generateRects() -{ - cachedRects.clear(); - QRegion remainingScreen(mGeometry); - - for (int i = 0; i < windowStack.length(); i++) { - if (remainingScreen.isEmpty()) - break; - if (!windowStack[i]->window()->testAttribute(Qt::WA_TranslucentBackground)) { - remainingScreen -= windowStack[i]->geometry(); - QRegion windowRegion(windowStack[i]->geometry()); - windowRegion -= remainingScreen; - foreach(QRect rect, windowRegion.rects()) { - cachedRects += QPair(rect, i); - } - } - } - foreach (QRect rect, remainingScreen.rects()) - cachedRects += QPair(rect, -1); - isUpToDate = true; - return; -} - - - -QRegion QGraphicsSystemFbScreen::doRedraw() -{ - QRegion touchedRegion; - if (cursor) - repaintRegion += cursor->dirtyRect(); - if (repaintRegion.isEmpty()) - return touchedRegion; - - QVector rects = repaintRegion.rects(); - - if (!isUpToDate) - generateRects(); - - if (!compositePainter) - compositePainter = new QPainter(mScreenImage); - for (int rectIndex = 0; rectIndex < repaintRegion.numRects(); rectIndex++) { - QRegion rectRegion = rects[rectIndex]; - - for(int i = 0; i < cachedRects.length(); i++) { - QRect screenSubRect = cachedRects[i].first; - int layer = cachedRects[i].second; - QRegion intersect = rectRegion.intersected(screenSubRect); - - if (intersect.isEmpty()) - continue; - - rectRegion -= intersect; - - // we only expect one rectangle, but defensive coding... - foreach (QRect rect, intersect.rects()) { - bool firstLayer = true; - if (layer == -1) { - compositePainter->fillRect(rect, Qt::black); - firstLayer = false; - layer = windowStack.size() - 1; - } - - for (int layerIndex = layer; layerIndex != -1; layerIndex--) { - if (!windowStack[layerIndex]->visible()) - continue; - if (windowStack[layerIndex]->window()->isMinimized()) - continue; - QRect windowRect = windowStack[layerIndex]->geometry(); - QRect windowIntersect = rect.translated(-windowRect.left(), - -windowRect.top()); - compositePainter->drawImage(rect, windowStack[layerIndex]->image(), - windowIntersect); - if (firstLayer) { - firstLayer = false; - } - } - } - } - if (!rectRegion.isEmpty()) - qWarning() << "non-empty region!" << rectRegion; - // Everything on screen should be mapped to a sub-rectangle - // unless it's off the screen... - } - - QRect cursorRect; - if (cursor) { - cursorRect = cursor->drawCursor(*compositePainter); - touchedRegion += cursorRect; - } - touchedRegion += repaintRegion; - repaintRegion = QRegion(); - - return touchedRegion; -} - -void QGraphicsSystemFbScreen::removeWindowSurface(QGraphicsSystemFbWindowSurface * surface) -{ - windowStack.removeOne(surface); - invalidateRectCache(); - setDirty(surface->geometry()); -} - -void QGraphicsSystemFbWindowSurface::raise() -{ - mScreen->raise(this); -} - -void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) -{ - QGraphicsSystemFbWindowSurface *s = static_cast(surface); - int index = windowStack.indexOf(s); - if (index <= 0) - return; - windowStack.move(index, 0); - invalidateRectCache(); - setDirty(s->geometry()); -} - -void QGraphicsSystemFbWindowSurface::lower() -{ - mScreen->lower(this); -} - -void QGraphicsSystemFbScreen::lower(QWindowSurface * surface) -{ - QGraphicsSystemFbWindowSurface *s = static_cast(surface); - int index = windowStack.indexOf(s); - if (index == -1 || index == (windowStack.size() - 1)) - return; - windowStack.move(index, windowStack.size() - 1); - invalidateRectCache(); - setDirty(s->geometry()); -} - -QWidget * QGraphicsSystemFbScreen::topLevelAt(const QPoint & p) const -{ - for(int i = 0; i < windowStack.size(); i++) { - if (windowStack[i]->geometry().contains(p, false) && - windowStack[i]->visible() && - !windowStack[i]->window()->isMinimized()) { - return windowStack[i]->window(); - } - } - return 0; -} - -QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window) - : QWindowSurface(window), - mScreen(screen), - visibleFlag(false) -{ - static QAtomicInt winIdGenerator(1); - - mImage = QImage(window->size(), mScreen->format()); - windowId = winIdGenerator.fetchAndAddRelaxed(1); -} - -QGraphicsSystemFbWindowSurface::~QGraphicsSystemFbWindowSurface() -{ - mScreen->removeWindowSurface(this); -} - -void QGraphicsSystemFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(offset); - - QRect currentGeometry = geometry(); - // If this is a move, redraw the previous location - if (oldGeometry != currentGeometry) { - mScreen->setDirty(oldGeometry); - oldGeometry = currentGeometry; - } - - QRect dirtyClient = region.boundingRect(); - QRect dirtyRegion(currentGeometry.left() + dirtyClient.left(), - currentGeometry.top() + dirtyClient.top(), - dirtyClient.width(), - dirtyClient.height()); - mScreen->setDirty(dirtyRegion); -} - -void QGraphicsSystemFbWindowSurface::setGeometry(const QRect &rect) -{ - // store previous geometry for screen update - oldGeometry = geometry(); - - // change the widget's QImage if this is a resize - if (mImage.size() != rect.size()) - mImage = QImage(rect.size(), mScreen->format()); - - mScreen->invalidateRectCache(); - QWindowSystemInterface::handleGeometryChange(window(), rect); - - QWindowSurface::setGeometry(rect); -} - -bool QGraphicsSystemFbWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - return QWindowSurface::scroll(area, dx, dy); -} - -void QGraphicsSystemFbWindowSurface::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -void QGraphicsSystemFbWindowSurface::endPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -void QGraphicsSystemFbWindowSurface::setVisible(bool visible) -{ - visibleFlag = visible; - mScreen->invalidateRectCache(); - mScreen->setDirty(geometry()); -} - -Qt::WindowFlags QGraphicsSystemFbWindowSurface::setWindowFlags(Qt::WindowFlags type) -{ - flags = type; - mScreen->invalidateRectCache(); - return flags; -} - -Qt::WindowFlags QGraphicsSystemFbWindowSurface::windowFlags() const -{ - return flags; -} diff --git a/src/plugins/graphicssystems/fb_base/fb_base.h b/src/plugins/graphicssystems/fb_base/fb_base.h deleted file mode 100644 index 7f9b005..0000000 --- a/src/plugins/graphicssystems/fb_base/fb_base.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef QLIGHTHOUSEGRAPHICSSCREEN_H -#define QLIGHTHOUSEGRAPHICSSCREEN_H - -#include -#include -#include -#include -#include -#include - -class QMouseEvent; -class QSize; -class QPainter; - -class QGraphicsSystemFbScreen; - -class QGraphicsSystemSoftwareCursor : public QGraphicsSystemCursor -{ -public: - QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen * scr); - - // output methods - QRect dirtyRect(); - virtual QRect drawCursor(QPainter & painter); - - // input methods - virtual void pointerEvent(const QMouseEvent & event); - virtual void changeCursor(QCursor * widgetCursor, QWidget * widget); - -protected: - QGraphicsSystemCursorImage * graphic; - -private: - void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); - void setCursor(Qt::CursorShape shape); - void setCursor(const QImage * image, int hotx, int hoty); - QRect currentRect; // next place to draw the cursor - QRect prevRect; // last place the cursor was drawn - QRect getCurrentRect(); -}; - -class QGraphicsSystemFbWindowSurface : public QWindowSurface -{ -public: - QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window); - ~QGraphicsSystemFbWindowSurface(); - - virtual QPaintDevice *paintDevice() { return &mImage; } - virtual void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - virtual bool scroll(const QRegion &area, int dx, int dy); - - virtual void beginPaint(const QRegion ®ion); - virtual void endPaint(const QRegion ®ion); - virtual void setVisible(bool visible); - virtual bool visible() { return visibleFlag; } - - const QImage image() { return mImage; } - void setGeometry(const QRect &rect); - - virtual void raise(); - virtual void lower(); - - virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); - virtual Qt::WindowFlags windowFlags() const; - - WId winId() const { return windowId; } -protected: - QGraphicsSystemFbScreen *mScreen; - QRect oldGeometry; - QImage mImage; - bool visibleFlag; - Qt::WindowFlags flags; - - WId windowId; -}; - -class QGraphicsSystemFbScreen : public QGraphicsSystemScreen -{ - Q_OBJECT -public: - QGraphicsSystemFbScreen(); - ~QGraphicsSystemFbScreen(); - - virtual QRect geometry() const { return mGeometry; } - virtual int depth() const { return mDepth; } - virtual QImage::Format format() const { return mFormat; } - virtual QSize physicalSize() const { return mPhysicalSize; } - - virtual void setGeometry(QRect rect); - virtual void setDepth(int depth); - virtual void setFormat(QImage::Format format); - virtual void setPhysicalSize(QSize size); - - virtual void setDirty(const QRect &rect); - - virtual void removeWindowSurface(QGraphicsSystemFbWindowSurface * surface); - virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { - windowStack.prepend(surface); invalidateRectCache(); } - virtual void raise(QWindowSurface * surface); - virtual void lower(QWindowSurface * surface); - virtual QWidget * topLevelAt(const QPoint & p) const; - - QImage * image() const { return mScreenImage; } - QPaintDevice * paintDevice() const { return mScreenImage; } - -protected: - QList windowStack; - QRegion repaintRegion; - QGraphicsSystemSoftwareCursor * cursor; - QTimer redrawTimer; - -protected slots: - virtual QRegion doRedraw(); - -protected: - QRect mGeometry; - int mDepth; - QImage::Format mFormat; - QSize mPhysicalSize; - QImage *mScreenImage; - -private: - QPainter * compositePainter; - void generateRects(); - QList > cachedRects; - - void invalidateRectCache() { isUpToDate = false; } - friend class QGraphicsSystemFbWindowSurface; - bool isUpToDate; -}; - -#endif // QLIGHTHOUSEGRAPHICSSCREEN_H diff --git a/src/plugins/graphicssystems/fb_base/fb_base.pri b/src/plugins/graphicssystems/fb_base/fb_base.pri deleted file mode 100644 index 41bd87f..0000000 --- a/src/plugins/graphicssystems/fb_base/fb_base.pri +++ /dev/null @@ -1,2 +0,0 @@ -SOURCES += ../fb_base/fb_base.cpp -HEADERS += ../fb_base/fb_base.h diff --git a/src/plugins/graphicssystems/fb_base/fb_base.pro b/src/plugins/graphicssystems/fb_base/fb_base.pro deleted file mode 100644 index e08c0c5..0000000 --- a/src/plugins/graphicssystems/fb_base/fb_base.pro +++ /dev/null @@ -1,23 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2009-11-05T13:22:31 -# -#------------------------------------------------- - -#QT -= core gui -TARGET = fb_base -#include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - -TEMPLATE = lib - -#DEFINES += STATIC_LIBRARY -CONFIG += staticlib - -SOURCES += fb_base.cpp - -HEADERS += fb_base.h - -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -INSTALLS += target diff --git a/src/plugins/graphicssystems/graphicssystems.pro b/src/plugins/graphicssystems/graphicssystems.pro index a5116d0..c00c9ff 100644 --- a/src/plugins/graphicssystems/graphicssystems.pro +++ b/src/plugins/graphicssystems/graphicssystems.pro @@ -13,11 +13,3 @@ contains(QT_CONFIG, shivavg) { # Only works under X11 at present !win32:!embedded:!mac:SUBDIRS += shivavg } - -embedded_lite: { - SUBDIRS += minimal -} - -embedded_lite:x11 { - SUBDIRS += linuxfb -} diff --git a/src/plugins/graphicssystems/linuxfb/linuxfb.pro b/src/plugins/graphicssystems/linuxfb/linuxfb.pro deleted file mode 100644 index 031b843..0000000 --- a/src/plugins/graphicssystems/linuxfb/linuxfb.pro +++ /dev/null @@ -1,12 +0,0 @@ -TARGET = qlinuxfbgraphicssystem -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - -SOURCES = main.cpp qgraphicssystem_linuxfb.cpp -HEADERS = qgraphicssystem_linuxfb.h - -include(../fb_base/fb_base.pri) - -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -INSTALLS += target diff --git a/src/plugins/graphicssystems/linuxfb/main.cpp b/src/plugins/graphicssystems/linuxfb/main.cpp deleted file mode 100644 index 4d03fe5..0000000 --- a/src/plugins/graphicssystems/linuxfb/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qgraphicssystem_linuxfb.h" - -QT_BEGIN_NAMESPACE - -class QLinuxFbGraphicsSystemPlugin : public QGraphicsSystemPlugin -{ -public: - QStringList keys() const; - QGraphicsSystem *create(const QString&); -}; - -QStringList QLinuxFbGraphicsSystemPlugin::keys() const -{ - QStringList list; - list << "LinuxFb"; - return list; -} - -QGraphicsSystem* QLinuxFbGraphicsSystemPlugin::create(const QString& system) -{ - if (system.toLower() == "linuxfb") - return new QLinuxFbGraphicsSystem; - - return 0; -} - -Q_EXPORT_PLUGIN2(linuxfb, QLinuxFbGraphicsSystemPlugin) - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp deleted file mode 100644 index 44960bb..0000000 --- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.cpp +++ /dev/null @@ -1,856 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_linuxfb.h" -#include "../fb_base/fb_base.h" -#include -#include // overrides QT_OPEN -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if !defined(Q_OS_DARWIN) && !defined(Q_OS_FREEBSD) -#include - -#ifdef __i386__ -#include -#endif -#endif - -QT_BEGIN_NAMESPACE - -class QLinuxFbGraphicsSystemPrivate -{ -public: - QLinuxFbGraphicsSystemPrivate(); - ~QLinuxFbGraphicsSystemPrivate(); - - void openTty(); - void closeTty(); - - int fd; - int startupw; - int startuph; - int startupd; - bool blank; - - bool doGraphicsMode; -#ifdef QT_QWS_DEPTH_GENERIC - bool doGenericColors; -#endif - int ttyfd; - long oldKdMode; - QString ttyDevice; - QString displaySpec; -}; - -QLinuxFbGraphicsSystemPrivate::QLinuxFbGraphicsSystemPrivate() - : fd(-1), blank(true), doGraphicsMode(true), -#ifdef QT_QWS_DEPTH_GENERIC - doGenericColors(false), -#endif - ttyfd(-1), oldKdMode(KD_TEXT) -{ -} - -QLinuxFbGraphicsSystemPrivate::~QLinuxFbGraphicsSystemPrivate() -{ - closeTty(); -} - -void QLinuxFbGraphicsSystemPrivate::openTty() -{ - const char *const devs[] = {"/dev/tty0", "/dev/tty", "/dev/console", 0}; - - if (ttyDevice.isEmpty()) { - for (const char * const *dev = devs; *dev; ++dev) { - ttyfd = QT_OPEN(*dev, O_RDWR); - if (ttyfd != -1) - break; - } - } else { - ttyfd = QT_OPEN(ttyDevice.toAscii().constData(), O_RDWR); - } - - if (ttyfd == -1) - return; - - if (doGraphicsMode) { - ioctl(ttyfd, KDGETMODE, &oldKdMode); - if (oldKdMode != KD_GRAPHICS) { - int ret = ioctl(ttyfd, KDSETMODE, KD_GRAPHICS); - if (ret == -1) - doGraphicsMode = false; - } - } - - // No blankin' screen, no blinkin' cursor!, no cursor! - const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c"; - QT_WRITE(ttyfd, termctl, sizeof(termctl)); -} - -void QLinuxFbGraphicsSystemPrivate::closeTty() -{ - if (ttyfd == -1) - return; - - if (doGraphicsMode) - ioctl(ttyfd, KDSETMODE, oldKdMode); - - // Blankin' screen, blinkin' cursor! - const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c"; - QT_WRITE(ttyfd, termctl, sizeof(termctl)); - - QT_CLOSE(ttyfd); - ttyfd = -1; -} - -QLinuxFbGraphicsSystem::QLinuxFbGraphicsSystem() -{ - d_ptr = new QLinuxFbGraphicsSystemPrivate(); - - // XXX - QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY")); - - if (!connect(displaySpec)) - qFatal("QLinuxFbGraphicsSystem: could not initialize screen"); - initDevice(); - - // Create a QImage directly on the screen's framebuffer. - // This is the blit target for copying windows to the screen. - mPrimaryScreen = new QLinuxFbGraphicsSystemScreen(data, w, h, lstep, - screenFormat); - mPrimaryScreen->setPhysicalSize(QSize(physWidth, physHeight)); - - mScreens.append(mPrimaryScreen); -} - -QLinuxFbGraphicsSystem::~QLinuxFbGraphicsSystem() -{ - delete mPrimaryScreen; - delete d_ptr; -} - -bool QLinuxFbGraphicsSystem::connect(const QString &displaySpec) -{ - const QStringList args = displaySpec.split(QLatin1Char(':')); - - if (args.contains(QLatin1String("nographicsmodeswitch"))) - d_ptr->doGraphicsMode = false; - -#ifdef QT_QWS_DEPTH_GENERIC - if (args.contains(QLatin1String("genericcolors"))) - d_ptr->doGenericColors = true; -#endif - - QRegExp ttyRegExp(QLatin1String("tty=(.*)")); - if (args.indexOf(ttyRegExp) != -1) - d_ptr->ttyDevice = ttyRegExp.cap(1); - -#if 0 -#if Q_BYTE_ORDER == Q_BIG_ENDIAN -#ifndef QT_QWS_FRAMEBUFFER_LITTLE_ENDIAN - if (args.contains(QLatin1String("littleendian"))) -#endif - QScreen::setFrameBufferLittleEndian(true); -#endif -#endif - - // Check for explicitly specified device - const int len = 8; // "/dev/fbx" - int m = displaySpec.indexOf(QLatin1String("/dev/fb")); - - QString dev; - if (m > 0) - dev = displaySpec.mid(m, len); - else - dev = QLatin1String("/dev/fb0"); - - if (access(dev.toLatin1().constData(), R_OK|W_OK) == 0) - d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDWR); - if (d_ptr->fd == -1) { - if (access(dev.toLatin1().constData(), R_OK) == 0) - d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDONLY); - if (d_ptr->fd == 1) { - qWarning("Error opening framebuffer device %s", qPrintable(dev)); - return false; - } - } - - fb_fix_screeninfo finfo; - fb_var_screeninfo vinfo; - //####################### - // Shut up Valgrind - memset(&vinfo, 0, sizeof(vinfo)); - memset(&finfo, 0, sizeof(finfo)); - //####################### - - /* Get fixed screen information */ - if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) { - perror("QLinuxFbGraphicsSystem::connect"); - qWarning("Error reading fixed information"); - return false; - } - - if (finfo.type == FB_TYPE_VGA_PLANES) { - qWarning("VGA16 video mode not supported"); - return false; - } - - /* Get variable screen information */ - if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) { - perror("QLinuxFbGraphicsSystem::connect"); - qWarning("Error reading variable information"); - return false; - } - - grayscale = vinfo.grayscale; - d = vinfo.bits_per_pixel; - if (d == 24) { - d = vinfo.red.length + vinfo.green.length + vinfo.blue.length; - if (d <= 0) - d = 24; // reset if color component lengths are not reported - } else if (d == 16) { - d = vinfo.red.length + vinfo.green.length + vinfo.blue.length; - if (d <= 0) - d = 16; - } - lstep = finfo.line_length; - - int xoff = vinfo.xoffset; - int yoff = vinfo.yoffset; - const char* qwssize; - if((qwssize=::getenv("QWS_SIZE")) && sscanf(qwssize,"%dx%d",&w,&h)==2) { - if (d_ptr->fd != -1) { - if ((uint)w > vinfo.xres) w = vinfo.xres; - if ((uint)h > vinfo.yres) h = vinfo.yres; - } - dw=w; - dh=h; - int xxoff, yyoff; - if (sscanf(qwssize, "%*dx%*d+%d+%d", &xxoff, &yyoff) == 2) { - if (xxoff < 0 || xxoff + w > (int)(vinfo.xres)) - xxoff = vinfo.xres - w; - if (yyoff < 0 || yyoff + h > (int)(vinfo.yres)) - yyoff = vinfo.yres - h; - xoff += xxoff; - yoff += yyoff; - } else { - xoff += (vinfo.xres - w)/2; - yoff += (vinfo.yres - h)/2; - } - } else { - dw=w=vinfo.xres; - dh=h=vinfo.yres; - } - - if (w == 0 || h == 0) { - qWarning("QLinuxFbGraphicsSystem::connect(): Unable to find screen geometry, " - "will use 320x240."); - dw = w = 320; - dh = h = 240; - } - - setPixelFormat(vinfo); - - // Handle display physical size spec. - QStringList displayArgs = displaySpec.split(QLatin1Char(':')); - QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)")); - int dimIdxW = displayArgs.indexOf(mmWidthRx); - QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)")); - int dimIdxH = displayArgs.indexOf(mmHeightRx); - if (dimIdxW >= 0) { - mmWidthRx.exactMatch(displayArgs.at(dimIdxW)); - physWidth = mmWidthRx.cap(1).toInt(); - if (dimIdxH < 0) - physHeight = dh*physWidth/dw; - } - if (dimIdxH >= 0) { - mmHeightRx.exactMatch(displayArgs.at(dimIdxH)); - physHeight = mmHeightRx.cap(1).toInt(); - if (dimIdxW < 0) - physWidth = dw*physHeight/dh; - } - if (dimIdxW < 0 && dimIdxH < 0) { - if (vinfo.width != 0 && vinfo.height != 0 - && vinfo.width != UINT_MAX && vinfo.height != UINT_MAX) { - physWidth = vinfo.width; - physHeight = vinfo.height; - } else { - const int dpi = 72; - physWidth = qRound(dw * 25.4 / dpi); - physHeight = qRound(dh * 25.4 / dpi); - } - } - - dataoffset = yoff * lstep + xoff * d / 8; - //qDebug("Using %dx%dx%d screen",w,h,d); - - /* Figure out the size of the screen in bytes */ - size = h * lstep; - - mapsize = finfo.smem_len; - - data = (unsigned char *)-1; - if (d_ptr->fd != -1) - data = (unsigned char *)mmap(0, mapsize, PROT_READ | PROT_WRITE, - MAP_SHARED, d_ptr->fd, 0); - - if ((long)data == -1) { - perror("QLinuxFbGraphicsSystem::connect"); - qWarning("Error: failed to map framebuffer device to memory."); - return false; - } else { - data += dataoffset; - } - -#if 0 - canaccel = useOffscreen(); - if(canaccel) - setupOffScreen(); -#endif - canaccel = false; - - // Now read in palette - if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { - screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; - int loopc; - fb_cmap startcmap; - startcmap.start=0; - startcmap.len=screencols; - startcmap.red=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - startcmap.green=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - startcmap.blue=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - startcmap.transp=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - if (d_ptr->fd == -1 || ioctl(d_ptr->fd, FBIOGETCMAP, &startcmap)) { - perror("QLinuxFbGraphicsSystem::connect"); - qWarning("Error reading palette from framebuffer, using default palette"); - createPalette(startcmap, vinfo, finfo); - } - int bits_used = 0; - for(loopc=0;loopc> 8, - startcmap.green[loopc] >> 8, - startcmap.blue[loopc] >> 8); - bits_used |= startcmap.red[loopc] - | startcmap.green[loopc] - | startcmap.blue[loopc]; - } - // WORKAROUND: Some framebuffer drivers only return 8 bit - // color values, so we need to not bit shift them.. - if ((bits_used & 0x00ff) && !(bits_used & 0xff00)) { - for(loopc=0;loopcopenTty(); - - // Grab current mode so we can reset it - fb_var_screeninfo vinfo; - fb_fix_screeninfo finfo; - //####################### - // Shut up Valgrind - memset(&vinfo, 0, sizeof(vinfo)); - memset(&finfo, 0, sizeof(finfo)); - //####################### - - if (ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) { - perror("QLinuxFbScreen::initDevice"); - qFatal("Error reading variable information in card init"); - return false; - } - -#ifdef DEBUG_VINFO - qDebug("Greyscale %d",vinfo.grayscale); - qDebug("Nonstd %d",vinfo.nonstd); - qDebug("Red %d %d %d",vinfo.red.offset,vinfo.red.length, - vinfo.red.msb_right); - qDebug("Green %d %d %d",vinfo.green.offset,vinfo.green.length, - vinfo.green.msb_right); - qDebug("Blue %d %d %d",vinfo.blue.offset,vinfo.blue.length, - vinfo.blue.msb_right); - qDebug("Transparent %d %d %d",vinfo.transp.offset,vinfo.transp.length, - vinfo.transp.msb_right); -#endif - - d_ptr->startupw=vinfo.xres; - d_ptr->startuph=vinfo.yres; - d_ptr->startupd=vinfo.bits_per_pixel; - grayscale = vinfo.grayscale; - - if (ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) { - perror("QLinuxFbScreen::initDevice"); - qCritical("Error reading fixed information in card init"); - // It's not an /error/ as such, though definitely a bad sign - // so we return true - return true; - } - -#ifdef __i386__ - // Now init mtrr - if(!::getenv("QWS_NOMTRR")) { - int mfd=QT_OPEN("/proc/mtrr",O_WRONLY,0); - // MTRR entry goes away when file is closed - i.e. - // hopefully when QWS is killed - if(mfd != -1) { - mtrr_sentry sentry; - sentry.base=(unsigned long int)finfo.smem_start; - //qDebug("Physical framebuffer address %p",(void*)finfo.smem_start); - // Size needs to be in 4k chunks, but that's not always - // what we get thanks to graphics card registers. Write combining - // these is Not Good, so we write combine what we can - // (which is not much - 4 megs on an 8 meg card, it seems) - unsigned int size=finfo.smem_len; - size=size >> 22; - size=size << 22; - sentry.size=size; - sentry.type=MTRR_TYPE_WRCOMB; - if(ioctl(mfd,MTRRIOC_ADD_ENTRY,&sentry)==-1) { - //printf("Couldn't add mtrr entry for %lx %lx, %s\n", - //sentry.base,sentry.size,strerror(errno)); - } - } - - // Should we close mfd here? - //QT_CLOSE(mfd); - } -#endif - if ((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4) || (finfo.visual==FB_VISUAL_DIRECTCOLOR)) - { - fb_cmap cmap; - createPalette(cmap, vinfo, finfo); - if (ioctl(d_ptr->fd, FBIOPUTCMAP, &cmap)) { - perror("QLinuxFbScreen::initDevice"); - qWarning("Error writing palette to framebuffer"); - } - free(cmap.red); - free(cmap.green); - free(cmap.blue); - free(cmap.transp); - } - -#if 0 - if (canaccel) { - *entryp=0; - *lowest = mapsize; - insert_entry(*entryp, *lowest, *lowest); // dummy entry to mark start - } - - shared->fifocount = 0; - shared->buffer_offset = 0xffffffff; // 0 would be a sensible offset (screen) - shared->linestep = 0; - shared->cliptop = 0xffffffff; - shared->clipleft = 0xffffffff; - shared->clipright = 0xffffffff; - shared->clipbottom = 0xffffffff; - shared->rop = 0xffffffff; -#endif - -#ifdef QT_QWS_DEPTH_GENERIC - if (pixelFormat() == QImage::Format_Invalid && screencols == 0 - && d_ptr->doGenericColors) - { - qt_set_generic_blit(this, vinfo.bits_per_pixel, - vinfo.red.length, vinfo.green.length, - vinfo.blue.length, vinfo.transp.length, - vinfo.red.offset, vinfo.green.offset, - vinfo.blue.offset, vinfo.transp.offset); - } -#endif - -#if 0 -#ifndef QT_NO_QWS_CURSOR - QScreenCursor::initSoftwareCursor(); -#endif -#endif - blank(false); - - return true; -} - -void QLinuxFbGraphicsSystem::setPixelFormat(struct fb_var_screeninfo info) -{ - const fb_bitfield rgba[4] = { info.red, info.green, - info.blue, info.transp }; - - QImage::Format format = QImage::Format_Invalid; - - switch (d) { - case 32: { - const fb_bitfield argb8888[4] = {{16, 8, 0}, {8, 8, 0}, - {0, 8, 0}, {24, 8, 0}}; - const fb_bitfield abgr8888[4] = {{0, 8, 0}, {8, 8, 0}, - {16, 8, 0}, {24, 8, 0}}; - if (memcmp(rgba, argb8888, 4 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_ARGB32; - } else if (memcmp(rgba, argb8888, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB32; - } else if (memcmp(rgba, abgr8888, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB32; - pixeltype = BGRPixel; - } - break; - } - case 24: { - const fb_bitfield rgb888[4] = {{16, 8, 0}, {8, 8, 0}, - {0, 8, 0}, {0, 0, 0}}; - const fb_bitfield bgr888[4] = {{0, 8, 0}, {8, 8, 0}, - {16, 8, 0}, {0, 0, 0}}; - if (memcmp(rgba, rgb888, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB888; - } else if (memcmp(rgba, bgr888, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB888; - pixeltype = BGRPixel; - } - break; - } - case 18: { - const fb_bitfield rgb666[4] = {{12, 6, 0}, {6, 6, 0}, - {0, 6, 0}, {0, 0, 0}}; - if (memcmp(rgba, rgb666, 3 * sizeof(fb_bitfield)) == 0) - format = QImage::Format_RGB666; - break; - } - case 16: { - const fb_bitfield rgb565[4] = {{11, 5, 0}, {5, 6, 0}, - {0, 5, 0}, {0, 0, 0}}; - const fb_bitfield bgr565[4] = {{0, 5, 0}, {5, 6, 0}, - {11, 5, 0}, {0, 0, 0}}; - if (memcmp(rgba, rgb565, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB16; - } else if (memcmp(rgba, bgr565, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB16; - pixeltype = BGRPixel; - } - break; - } - case 15: { - const fb_bitfield rgb1555[4] = {{10, 5, 0}, {5, 5, 0}, - {0, 5, 0}, {15, 1, 0}}; - const fb_bitfield bgr1555[4] = {{0, 5, 0}, {5, 5, 0}, - {10, 5, 0}, {15, 1, 0}}; - if (memcmp(rgba, rgb1555, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB555; - } else if (memcmp(rgba, bgr1555, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB555; - pixeltype = BGRPixel; - } - break; - } - case 12: { - const fb_bitfield rgb444[4] = {{8, 4, 0}, {4, 4, 0}, - {0, 4, 0}, {0, 0, 0}}; - if (memcmp(rgba, rgb444, 3 * sizeof(fb_bitfield)) == 0) - format = QImage::Format_RGB444; - break; - } - case 8: - break; - case 1: - format = QImage::Format_Mono; //###: LSB??? - break; - default: - break; - } - - screenFormat = format; -} - -void QLinuxFbGraphicsSystem::createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo) -{ - if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { - screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; - cmap.start=0; - cmap.len=screencols; - cmap.red=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - cmap.green=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - cmap.blue=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - cmap.transp=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - - if (screencols==16) { - if (finfo.type == FB_TYPE_PACKED_PIXELS) { - // We'll setup a grayscale cmap for 4bpp linear - int val = 0; - for (int idx = 0; idx < 16; ++idx, val += 17) { - cmap.red[idx] = (val<<8)|val; - cmap.green[idx] = (val<<8)|val; - cmap.blue[idx] = (val<<8)|val; - screenclut[idx]=qRgb(val, val, val); - } - } else { - // Default 16 colour palette - // Green is now trolltech green so certain images look nicer - // black d_gray l_gray white red green blue cyan magenta yellow - unsigned char reds[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0xFF, 0xA2, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x82 }; - unsigned char greens[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0xC5, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F }; - unsigned char blues[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0x11, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00 }; - - for (int idx = 0; idx < 16; ++idx) { - cmap.red[idx] = ((reds[idx]) << 8)|reds[idx]; - cmap.green[idx] = ((greens[idx]) << 8)|greens[idx]; - cmap.blue[idx] = ((blues[idx]) << 8)|blues[idx]; - cmap.transp[idx] = 0; - screenclut[idx]=qRgb(reds[idx], greens[idx], blues[idx]); - } - } - } else { - if (grayscale) { - // Build grayscale palette - int i; - for(i=0;iblank == on) - return; - -#if defined(QT_QWS_IPAQ) - if (on) - system("apm -suspend"); -#else - if (d_ptr->fd == -1) - return; -// Some old kernel versions don't have this. These defines should go -// away eventually -#if defined(FBIOBLANK) -#if defined(VESA_POWERDOWN) && defined(VESA_NO_BLANKING) - ioctl(d_ptr->fd, FBIOBLANK, on ? VESA_POWERDOWN : VESA_NO_BLANKING); -#else - ioctl(d_ptr->fd, FBIOBLANK, on ? 1 : 0); -#endif -#endif -#endif - - d_ptr->blank = on; -} - -QPixmapData *QLinuxFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -QWindowSurface *QLinuxFbGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - if (widget->windowType() == Qt::Desktop) - return 0; // Don't create an explicit window surface for the destkop. - QGraphicsSystemFbWindowSurface * surface = - new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); - mPrimaryScreen->addWindowSurface(surface); - return surface; -} - -QLinuxFbGraphicsSystemScreen::QLinuxFbGraphicsSystemScreen(uchar * d, int w, - int h, int lstep, QImage::Format screenFormat) : compositePainter(0) -{ - data = d; - mGeometry = QRect(0,0,w,h); - bytesPerLine = lstep; - mFormat = screenFormat; - mDepth = 16; - mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), - mFormat); - mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), - bytesPerLine, mFormat); - cursor = new QGraphicsSystemSoftwareCursor(this); -} - -void QLinuxFbGraphicsSystemScreen::setGeometry(QRect rect) -{ - mGeometry = rect; - delete mFbScreenImage; - mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), - bytesPerLine, mFormat); - delete compositePainter; - compositePainter = 0; - - delete mScreenImage; - mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), - mFormat); -} - -void QLinuxFbGraphicsSystemScreen::setFormat(QImage::Format format) -{ - mFormat = format; - delete mFbScreenImage; - mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), - bytesPerLine, mFormat); - delete compositePainter; - compositePainter = 0; - - delete mScreenImage; - mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), - mFormat); -} - -QRegion QLinuxFbGraphicsSystemScreen::doRedraw() -{ - QRegion touched; - touched = QGraphicsSystemFbScreen::doRedraw(); - - if (!compositePainter) { - compositePainter = new QPainter(mFbScreenImage); - } - - QVector rects = touched.rects(); - for (int i = 0; i < rects.size(); i++) - compositePainter->drawImage(rects[i], *mScreenImage, rects[i]); - return touched; -} -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h b/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h deleted file mode 100644 index cc8ce7e..0000000 --- a/src/plugins/graphicssystems/linuxfb/qgraphicssystem_linuxfb.h +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_LINUXFB_H -#define QGRAPHICSSYSTEM_LINUXFB_H - -#include -#include "../fb_base/fb_base.h" - -QT_BEGIN_NAMESPACE - -class QLinuxFbGraphicsSystemScreen : public QGraphicsSystemFbScreen -{ -public: - QLinuxFbGraphicsSystemScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat); - void setGeometry(QRect rect); - void setFormat(QImage::Format format); - -public slots: - QRegion doRedraw(); - -private: - QImage * mFbScreenImage; - uchar * data; - int bytesPerLine; - - QPainter *compositePainter; -}; - -class QLinuxFbGraphicsSystemPrivate; -struct fb_cmap; -struct fb_var_screeninfo; -struct fb_fix_screeninfo; - -class QLinuxFbGraphicsSystem : public QGraphicsSystem -{ -public: - QLinuxFbGraphicsSystem(); - ~QLinuxFbGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - - QList screens() const { return mScreens; } - -private: - QLinuxFbGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; - QLinuxFbGraphicsSystemPrivate *d_ptr; - - enum PixelType { NormalPixel, BGRPixel }; - - QRgb screenclut[256]; - int screencols; - - uchar * data; - - QImage::Format screenFormat; - int w; - int lstep; - int h; - int d; - PixelType pixeltype; - bool grayscale; - - int dw; - int dh; - - int size; // Screen size - int mapsize; // Total mapped memory - - int displayId; - - int physWidth; - int physHeight; - - bool canaccel; - int dataoffset; - int cacheStart; - - bool connect(const QString &displaySpec); - bool initDevice(); - void setPixelFormat(struct fb_var_screeninfo); - void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo); - void blank(bool on); -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/minimal/main.cpp b/src/plugins/graphicssystems/minimal/main.cpp deleted file mode 100644 index 2e9d80e..0000000 --- a/src/plugins/graphicssystems/minimal/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qgraphicssystem_minimal.h" - -QT_BEGIN_NAMESPACE - -class QMinimalGraphicsSystemPlugin : public QGraphicsSystemPlugin -{ -public: - QStringList keys() const; - QGraphicsSystem *create(const QString&); -}; - -QStringList QMinimalGraphicsSystemPlugin::keys() const -{ - QStringList list; - list << "Minimal"; - return list; -} - -QGraphicsSystem* QMinimalGraphicsSystemPlugin::create(const QString& system) -{ - if (system.toLower() == "minimal") - return new QMinimalGraphicsSystem; - - return 0; -} - -Q_EXPORT_PLUGIN2(minimal, QMinimalGraphicsSystemPlugin) - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimal/minimal.pro b/src/plugins/graphicssystems/minimal/minimal.pro deleted file mode 100644 index 11604dd..0000000 --- a/src/plugins/graphicssystems/minimal/minimal.pro +++ /dev/null @@ -1,10 +0,0 @@ -TARGET = qminimalgraphicssystem -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - -SOURCES = main.cpp qgraphicssystem_minimal.cpp qwindowsurface_minimal.cpp -HEADERS = qgraphicssystem_minimal.h qwindowsurface_minimal.h - -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -INSTALLS += target diff --git a/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp b/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp deleted file mode 100644 index 78aff06..0000000 --- a/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_minimal.h" -#include "qwindowsurface_minimal.h" -#include - -QT_BEGIN_NAMESPACE - -QMinimalGraphicsSystem::QMinimalGraphicsSystem() -{ - mPrimaryScreen = new QMinimalGraphicsSystemScreen(); - - mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320); - mPrimaryScreen->mDepth = 16; - mPrimaryScreen->mFormat = QImage::Format_RGB16; - mPrimaryScreen->mPhysicalSize = QSize(40, 54); - - mScreens.append(mPrimaryScreen); -} - -QPixmapData *QMinimalGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -QWindowSurface *QMinimalGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - return new QMinimalWindowSurface(mPrimaryScreen, widget); -} - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h b/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h deleted file mode 100644 index 5bf230f..0000000 --- a/src/plugins/graphicssystems/minimal/qgraphicssystem_minimal.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_MINIMAL_H -#define QGRAPHICSSYSTEM_MINIMAL_H - -#include - -QT_BEGIN_NAMESPACE - -class QMinimalGraphicsSystemScreen : public QGraphicsSystemScreen -{ -public: - QMinimalGraphicsSystemScreen() - : mDepth(16), mFormat(QImage::Format_RGB16) {} - ~QMinimalGraphicsSystemScreen() {} - - QRect geometry() const { return mGeometry; } - int depth() const { return mDepth; } - QImage::Format format() const { return mFormat; } - QSize physicalSize() const { return mPhysicalSize; } - -public: - QRect mGeometry; - int mDepth; - QImage::Format mFormat; - QSize mPhysicalSize; -}; - -class QMinimalGraphicsSystem : public QGraphicsSystem -{ -public: - QMinimalGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - - QList screens() const { return mScreens; } - -private: - QMinimalGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp b/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp deleted file mode 100644 index a87e690..0000000 --- a/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindowsurface_minimal.h" -#include "qgraphicssystem_minimal.h" -#include - -QT_BEGIN_NAMESPACE - -QMinimalWindowSurface::QMinimalWindowSurface - (QMinimalGraphicsSystemScreen *screen, QWidget *window) - : QWindowSurface(window), - mScreen(screen) -{ - //qDebug() << "QMinimalWindowSurface::QMinimalWindowSurface:" << (long)this; -} - -QMinimalWindowSurface::~QMinimalWindowSurface() -{ -} - -QPaintDevice *QMinimalWindowSurface::paintDevice() -{ - //qDebug() << "QMinimalWindowSurface::paintDevice"; - return &mImage; -} - -void QMinimalWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(region); - Q_UNUSED(offset); - - static int c = 0; - QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0')); - qDebug() << "QMinimalWindowSurface::flush() saving contents to" << filename.toLocal8Bit().constData(); - mImage.save(filename); -} - -void QMinimalWindowSurface::setGeometry(const QRect &rect) -{ - //qDebug() << "QMinimalWindowSurface::setGeometry:" << (long)this << rect; - QWindowSurface::setGeometry(rect); - if (mImage.size() != rect.size()) - mImage = QImage(rect.size(), mScreen->format()); -} - -bool QMinimalWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - return QWindowSurface::scroll(area, dx, dy); -} - -void QMinimalWindowSurface::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -void QMinimalWindowSurface::endPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h b/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h deleted file mode 100644 index c7593e7..0000000 --- a/src/plugins/graphicssystems/minimal/qwindowsurface_minimal.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_MINIMAL_H -#define QWINDOWSURFACE_MINIMAL_H - -#include - -QT_BEGIN_NAMESPACE - -class QMinimalGraphicsSystemScreen; - -class QMinimalWindowSurface : public QWindowSurface -{ -public: - QMinimalWindowSurface - (QMinimalGraphicsSystemScreen *screen, QWidget *window); - ~QMinimalWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - -private: - QMinimalGraphicsSystemScreen *mScreen; - QImage mImage; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/minimaldfb/main.cpp b/src/plugins/graphicssystems/minimaldfb/main.cpp deleted file mode 100644 index fe9407c..0000000 --- a/src/plugins/graphicssystems/minimaldfb/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qgraphicssystem_minimaldfb.h" - -QT_BEGIN_NAMESPACE - -class QDirectFbGraphicsSystemPlugin : public QGraphicsSystemPlugin -{ -public: - QStringList keys() const; - QGraphicsSystem *create(const QString&); -}; - -QStringList QDirectFbGraphicsSystemPlugin::keys() const -{ - QStringList list; - list << "MinimalDfb"; - return list; -} - -QGraphicsSystem* QDirectFbGraphicsSystemPlugin::create(const QString& system) -{ - if (system.toLower() == "minimaldfb") - return new QDirectFbGraphicsSystem; - - return 0; -} - -Q_EXPORT_PLUGIN2(directfb, QDirectFbGraphicsSystemPlugin) - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro b/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro deleted file mode 100644 index b6c2ea8..0000000 --- a/src/plugins/graphicssystems/minimaldfb/minimaldfb.pro +++ /dev/null @@ -1,29 +0,0 @@ -TARGET = qminimaldfb -include(../../qpluginbase.pri) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - -isEmpty(DIRECTFB_LIBS) { - DIRECTFB_LIBS = -ldirectfb -lfusion -ldirect -lpthread -} -isEmpty(DIRECTFB_INCLUDEPATH) { - DIRECTFB_INCLUDEPATH = /usr/include/directfb -} - -INCLUDEPATH += $$DIRECTFB_INCLUDEPATH -LIBS += $$DIRECTFB_LIBS - -SOURCES = main.cpp \ - qgraphicssystem_minimaldfb.cpp \ - qwindowsurface_minimaldfb.cpp \ - qblitter_directfb.cpp \ - qdirectfbconvenience.cpp \ - qdirectfbinput.cpp \ - qdirectfbcursor.cpp -HEADERS = qgraphicssystem_minimaldfb.h \ - qwindowsurface_minimaldfb.h \ - qblitter_directfb.h \ - qdirectfbconvenience.h \ - qdirectfbinput.h \ - qdirectfbcursor.h -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -INSTALLS += target diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp deleted file mode 100644 index ded57d3..0000000 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "qblitter_directfb.h" -#include "qgraphicssystem_minimaldfb.h" -#include "qdirectfbconvenience.h" - -#include - -#include - -#include - -QDirectFbBlitter::QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface) - : QBlittable(rect, QBlittable::Capabilities(QBlittable::SolidRectCapability - |QBlittable::SourcePixmapCapability - |QBlittable::SourceOverPixmapCapability - |QBlittable::SourceOverScaledPixmapCapability)) -{ - if (surface) { - m_surface = surface; - } else { - DFBSurfaceDescription surfaceDesc; - memset(&surfaceDesc,0,sizeof(DFBSurfaceDescription)); - surfaceDesc.width = rect.width(); - surfaceDesc.height = rect.height(); - surfaceDesc.caps = DSCAPS_PREMULTIPLIED; - surfaceDesc.pixelformat = DSPF_ARGB; - surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT); - - IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); - dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); - m_surface->Clear(m_surface,0,0,0,0); - } -} - -QDirectFbBlitter::~QDirectFbBlitter() -{ - unlock(); - m_surface->Release(m_surface); -} - -void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color) -{ - m_surface->SetColor(m_surface, color.red(), color.green(), color.blue(), color.alpha()); -// When the blitter api supports non opaque blits, also remember to change -// qpixmap_blitter.cpp::fill -// DFBSurfaceDrawingFlags drawingFlags = color.alpha() ? DSDRAW_BLEND : DSDRAW_NOFX; -// m_surface->SetDrawingFlags(m_surface, drawingFlags); - m_surface->SetDrawingFlags(m_surface, DSDRAW_NOFX); - m_surface->FillRectangle(m_surface, rect.x(), rect.y(), - rect.width(), rect.height()); -} - -void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &srcRect) -{ - QPixmapData *data = pixmap.pixmapData(); - Q_ASSERT(data->width() && data->height()); - Q_ASSERT(data->classId() == QPixmapData::BlitterClass); - QBlittablePixmapData *blitPm = static_cast(data); - QDirectFbBlitter *dfbBlitter = static_cast(blitPm->blittable()); - dfbBlitter->unlock(); - - IDirectFBSurface *s = dfbBlitter->m_surface; - - quint32 blittingFlags = pixmap.hasAlpha()? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; - - s->SetBlittingFlags(s, DFBSurfaceBlittingFlags(blittingFlags)); - m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags)); - m_surface->SetPorterDuff(m_surface,DSPD_SRC_OVER); - m_surface->SetDstBlendFunction(m_surface,DSBF_INVSRCALPHA); - - const DFBRectangle sRect = { srcRect.x(), srcRect.y(), rect.width(), rect.height() }; - - DFBResult result; - if (rect.width() == srcRect.width() && rect.height() == srcRect.height()) - result = m_surface->Blit(m_surface, s, &sRect, rect.x(), rect.y()); - else { - const DFBRectangle dRect = { rect.x(), rect.y(), rect.width(), rect.height() }; - result = m_surface->StretchBlit(m_surface, s, &sRect, &dRect); - } - if (result != DFB_OK) - DirectFBError("QDirectFBBlitter::drawPixmap()", result); -} - -QImage *QDirectFbBlitter::doLock() -{ - Q_ASSERT(m_surface); - Q_ASSERT(rect().isValid()); - - void *mem; - int bpl; - const DFBResult result = m_surface->Lock(m_surface, DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast(&mem), &bpl); - if (result == DFB_OK) { - DFBSurfacePixelFormat dfbFormat; - DFBSurfaceCapabilities dfbCaps; - m_surface->GetPixelFormat(m_surface,&dfbFormat); - m_surface->GetCapabilities(m_surface,&dfbCaps); - QImage::Format format = QDirectFbConvenience::imageFormatFromSurfaceFormat(dfbFormat, dfbCaps); - int w, h; - m_surface->GetSize(m_surface,&w,&h); - m_image = QImage(static_cast(mem),w,h,bpl,format); - } else { - DirectFBError("Failed to lock image", result); - } - - return &m_image; -} - -void QDirectFbBlitter::doUnlock() -{ - m_surface->Unlock(m_surface); -} diff --git a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h b/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h deleted file mode 100644 index 8d24678..0000000 --- a/src/plugins/graphicssystems/minimaldfb/qblitter_directfb.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef QDIRECTFBBLITTER_H -#define QDIRECTFBBLITTER_H - -#include "qdirectfbconvenience.h" - -#include - -#include - -class QDirectFbBlitter : public QBlittable -{ -public: - QDirectFbBlitter(const QRect &rect, IDirectFBSurface *surface = 0); - virtual ~QDirectFbBlitter(); - - virtual void fillRect(const QRectF &rect, const QColor &color); - virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect); - -protected: - virtual QImage *doLock(); - virtual void doUnlock(); - - IDirectFBSurface *m_surface; - QImage m_image; - - friend class QDirectFbConvenience; -}; - -#endif // QDIRECTFBBLITTER_H diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp deleted file mode 100644 index 8594c09..0000000 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp +++ /dev/null @@ -1,335 +0,0 @@ -#include "qdirectfbconvenience.h" -#include "qblitter_directfb.h" - -#include - -IDirectFB *QDirectFbConvenience::dfbInterface() -{ - static IDirectFB *dfb = 0; - if (!dfb) { - DFBResult result = DirectFBCreate(&dfb); - if (result != DFB_OK) { - DirectFBError("QDirectFBConvenience: error creating DirectFB interface",result); - return 0; - } - } - return dfb; -} - -IDirectFBDisplayLayer *QDirectFbConvenience::dfbDisplayLayer(int display) -{ - IDirectFBDisplayLayer *layer; - DFBResult result = QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),display,&layer); - if (result != DFB_OK) { - DirectFBError("QDirectFbConvenience: " - "Unable to get primary display layer!", result); - } - return layer; -} - -QImage::Format QDirectFbConvenience::imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps) -{ - switch (format) { - case DSPF_LUT8: - return QImage::Format_Indexed8; - case DSPF_RGB24: - return QImage::Format_RGB888; - case DSPF_ARGB4444: - return QImage::Format_ARGB4444_Premultiplied; - case DSPF_RGB444: - return QImage::Format_RGB444; - case DSPF_RGB555: - case DSPF_ARGB1555: - return QImage::Format_RGB555; - case DSPF_RGB16: - return QImage::Format_RGB16; - case DSPF_ARGB6666: - return QImage::Format_ARGB6666_Premultiplied; - case DSPF_RGB18: - return QImage::Format_RGB666; - case DSPF_RGB32: - return QImage::Format_RGB32; - case DSPF_ARGB: { - if (caps & DSCAPS_PREMULTIPLIED) - return QImage::Format_ARGB32_Premultiplied; - else return QImage::Format_ARGB32; } - default: - break; - } - return QImage::Format_Invalid; - -} - -int QDirectFbConvenience::colorDepthForSurface(const DFBSurfacePixelFormat format) -{ - return ((0x1f << 7) & format) >> 7; -} - -IDirectFBSurface *QDirectFbConvenience::dfbSurfaceForPixmapData(QPixmapData *pixmapData) -{ - QBlittablePixmapData *blittablePmData = static_cast(pixmapData); - if (blittablePmData) { - QBlittable *blittable = blittablePmData->blittable(); - QDirectFbBlitter *dfbBlitter = static_cast(blittable); - return dfbBlitter->m_surface; - } - return 0; -} - -Qt::MouseButton QDirectFbConvenience::mouseButton(DFBInputDeviceButtonIdentifier identifier) -{ - switch (identifier){ - case DIBI_LEFT: - return Qt::LeftButton; - case DIBI_MIDDLE: - return Qt::MidButton; - case DIBI_RIGHT: - return Qt::RightButton; - default: - return Qt::NoButton; - } -} - -Qt::MouseButtons QDirectFbConvenience::mouseButtons(DFBInputDeviceButtonMask mask) -{ - Qt::MouseButtons buttons = Qt::NoButton; - - if (mask & DIBM_LEFT) { - buttons |= Qt::LeftButton; - } - if (mask & DIBM_MIDDLE) { - buttons |= Qt::MidButton; - } - if (mask & DIBM_RIGHT) { - buttons |= Qt::RightButton; - } - return buttons; -} - -Qt::KeyboardModifiers QDirectFbConvenience::keyboardModifiers(DFBInputDeviceModifierMask mask) -{ - Qt::KeyboardModifiers modifiers = Qt::NoModifier; - - if (mask & DIMM_SHIFT) { - modifiers |= Qt::ShiftModifier; - } - if (mask & DIMM_ALT) { - modifiers |= Qt::AltModifier; - } - if (mask & DIMM_ALTGR) { - modifiers |= Qt::MetaModifier; - } - if (mask & DIMM_CONTROL) { - modifiers |= Qt::ControlModifier; - } - if (mask & DIMM_META) { - modifiers | Qt::MetaModifier; - } - return modifiers; -} - -QEvent::Type QDirectFbConvenience::eventType(DFBWindowEventType type) -{ - switch(type) { - case DWET_BUTTONDOWN: - return QEvent::MouseButtonPress; - case DWET_BUTTONUP: - return QEvent::MouseButtonRelease; - case DWET_MOTION: - return QEvent::MouseMove; - case DWET_WHEEL: - return QEvent::Wheel; - case DWET_KEYDOWN: - return QEvent::KeyPress; - case DWET_KEYUP: - return QEvent::KeyRelease; - default: - return QEvent::None; - } -} -QDirectFbKeyMap *QDirectFbConvenience::dfbKeymap = 0; -QDirectFbKeyMap *QDirectFbConvenience::keyMap() -{ - if (!dfbKeymap) - dfbKeymap = new QDirectFbKeyMap(); - return dfbKeymap; -} - -QDirectFbKeyMap::QDirectFbKeyMap() -{ - insert(DIKS_BACKSPACE , Qt::Key_Backspace); - insert(DIKS_TAB , Qt::Key_Tab); - insert(DIKS_RETURN , Qt::Key_Return); - insert(DIKS_ESCAPE , Qt::Key_Escape); - insert(DIKS_DELETE , Qt::Key_Delete); - - insert(DIKS_CURSOR_LEFT , Qt::Key_Left); - insert(DIKS_CURSOR_RIGHT , Qt::Key_Right); - insert(DIKS_CURSOR_UP , Qt::Key_Up); - insert(DIKS_CURSOR_DOWN , Qt::Key_Down); - insert(DIKS_INSERT , Qt::Key_Insert); - insert(DIKS_HOME , Qt::Key_Home); - insert(DIKS_END , Qt::Key_End); - insert(DIKS_PAGE_UP , Qt::Key_PageUp); - insert(DIKS_PAGE_DOWN , Qt::Key_PageDown); - insert(DIKS_PRINT , Qt::Key_Print); - insert(DIKS_PAUSE , Qt::Key_Pause); - insert(DIKS_SELECT , Qt::Key_Select); - insert(DIKS_GOTO , Qt::Key_OpenUrl); - insert(DIKS_CLEAR , Qt::Key_Clear); - insert(DIKS_MENU , Qt::Key_Menu); - insert(DIKS_HELP , Qt::Key_Help); - - insert(DIKS_INTERNET , Qt::Key_HomePage); - insert(DIKS_MAIL , Qt::Key_LaunchMail); - insert(DIKS_FAVORITES , Qt::Key_Favorites); - - insert(DIKS_BACK , Qt::Key_Back); - insert(DIKS_FORWARD , Qt::Key_Forward); - insert(DIKS_VOLUME_UP , Qt::Key_VolumeUp); - insert(DIKS_VOLUME_DOWN , Qt::Key_VolumeDown); - insert(DIKS_MUTE , Qt::Key_VolumeMute); - insert(DIKS_PLAYPAUSE , Qt::Key_Pause); - insert(DIKS_PLAY , Qt::Key_MediaPlay); - insert(DIKS_STOP , Qt::Key_MediaStop); - insert(DIKS_RECORD , Qt::Key_MediaRecord); - insert(DIKS_PREVIOUS , Qt::Key_MediaPrevious); - insert(DIKS_NEXT , Qt::Key_MediaNext); - - insert(DIKS_F1 , Qt::Key_F1); - insert(DIKS_F2 , Qt::Key_F2); - insert(DIKS_F3 , Qt::Key_F3); - insert(DIKS_F4 , Qt::Key_F4); - insert(DIKS_F5 , Qt::Key_F5); - insert(DIKS_F6 , Qt::Key_F6); - insert(DIKS_F7 , Qt::Key_F7); - insert(DIKS_F8 , Qt::Key_F8); - insert(DIKS_F9 , Qt::Key_F9); - insert(DIKS_F10 , Qt::Key_F10); - insert(DIKS_F11 , Qt::Key_F11); - insert(DIKS_F12 , Qt::Key_F12); - - insert(DIKS_SHIFT , Qt::Key_Shift); - insert(DIKS_CONTROL , Qt::Key_Control); - insert(DIKS_ALT , Qt::Key_Alt); - insert(DIKS_ALTGR , Qt::Key_AltGr); - - insert(DIKS_META , Qt::Key_Meta); - insert(DIKS_SUPER , Qt::Key_Super_L); // ??? - insert(DIKS_HYPER , Qt::Key_Hyper_L); // ??? - - insert(DIKS_CAPS_LOCK , Qt::Key_CapsLock); - insert(DIKS_NUM_LOCK , Qt::Key_NumLock); - insert(DIKS_SCROLL_LOCK , Qt::Key_ScrollLock); - - insert(DIKS_DEAD_ABOVEDOT , Qt::Key_Dead_Abovedot); - insert(DIKS_DEAD_ABOVERING , Qt::Key_Dead_Abovering); - insert(DIKS_DEAD_ACUTE , Qt::Key_Dead_Acute); - insert(DIKS_DEAD_BREVE , Qt::Key_Dead_Breve); - insert(DIKS_DEAD_CARON , Qt::Key_Dead_Caron); - insert(DIKS_DEAD_CEDILLA , Qt::Key_Dead_Cedilla); - insert(DIKS_DEAD_CIRCUMFLEX , Qt::Key_Dead_Circumflex); - insert(DIKS_DEAD_DIAERESIS , Qt::Key_Dead_Diaeresis); - insert(DIKS_DEAD_DOUBLEACUTE , Qt::Key_Dead_Doubleacute); - insert(DIKS_DEAD_GRAVE , Qt::Key_Dead_Grave); - insert(DIKS_DEAD_IOTA , Qt::Key_Dead_Iota); - insert(DIKS_DEAD_MACRON , Qt::Key_Dead_Macron); - insert(DIKS_DEAD_OGONEK , Qt::Key_Dead_Ogonek); - insert(DIKS_DEAD_SEMIVOICED_SOUND , Qt::Key_Dead_Semivoiced_Sound); - insert(DIKS_DEAD_TILDE , Qt::Key_Dead_Tilde); - insert(DIKS_DEAD_VOICED_SOUND , Qt::Key_Dead_Voiced_Sound); - insert(DIKS_SPACE , Qt::Key_Space); - insert(DIKS_EXCLAMATION_MARK , Qt::Key_Exclam); - insert(DIKS_QUOTATION , Qt::Key_QuoteDbl); - insert(DIKS_NUMBER_SIGN , Qt::Key_NumberSign); - insert(DIKS_DOLLAR_SIGN , Qt::Key_Dollar); - insert(DIKS_PERCENT_SIGN , Qt::Key_Percent); - insert(DIKS_AMPERSAND , Qt::Key_Ampersand); - insert(DIKS_APOSTROPHE , Qt::Key_Apostrophe); - insert(DIKS_PARENTHESIS_LEFT , Qt::Key_ParenLeft); - insert(DIKS_PARENTHESIS_RIGHT , Qt::Key_ParenRight); - insert(DIKS_ASTERISK , Qt::Key_Asterisk); - insert(DIKS_PLUS_SIGN , Qt::Key_Plus); - insert(DIKS_COMMA , Qt::Key_Comma); - insert(DIKS_MINUS_SIGN , Qt::Key_Minus); - insert(DIKS_PERIOD , Qt::Key_Period); - insert(DIKS_SLASH , Qt::Key_Slash); - insert(DIKS_0 , Qt::Key_0); - insert(DIKS_1 , Qt::Key_1); - insert(DIKS_2 , Qt::Key_2); - insert(DIKS_3 , Qt::Key_3); - insert(DIKS_4 , Qt::Key_4); - insert(DIKS_5 , Qt::Key_5); - insert(DIKS_6 , Qt::Key_6); - insert(DIKS_7 , Qt::Key_7); - insert(DIKS_8 , Qt::Key_8); - insert(DIKS_9 , Qt::Key_9); - insert(DIKS_COLON , Qt::Key_Colon); - insert(DIKS_SEMICOLON , Qt::Key_Semicolon); - insert(DIKS_LESS_THAN_SIGN , Qt::Key_Less); - insert(DIKS_EQUALS_SIGN , Qt::Key_Equal); - insert(DIKS_GREATER_THAN_SIGN , Qt::Key_Greater); - insert(DIKS_QUESTION_MARK , Qt::Key_Question); - insert(DIKS_AT , Qt::Key_At); - insert(DIKS_CAPITAL_A , Qt::Key_A); - insert(DIKS_CAPITAL_B , Qt::Key_B); - insert(DIKS_CAPITAL_C , Qt::Key_C); - insert(DIKS_CAPITAL_D , Qt::Key_D); - insert(DIKS_CAPITAL_E , Qt::Key_E); - insert(DIKS_CAPITAL_F , Qt::Key_F); - insert(DIKS_CAPITAL_G , Qt::Key_G); - insert(DIKS_CAPITAL_H , Qt::Key_H); - insert(DIKS_CAPITAL_I , Qt::Key_I); - insert(DIKS_CAPITAL_J , Qt::Key_J); - insert(DIKS_CAPITAL_K , Qt::Key_K); - insert(DIKS_CAPITAL_L , Qt::Key_L); - insert(DIKS_CAPITAL_M , Qt::Key_M); - insert(DIKS_CAPITAL_N , Qt::Key_N); - insert(DIKS_CAPITAL_O , Qt::Key_O); - insert(DIKS_CAPITAL_P , Qt::Key_P); - insert(DIKS_CAPITAL_Q , Qt::Key_Q); - insert(DIKS_CAPITAL_R , Qt::Key_R); - insert(DIKS_CAPITAL_S , Qt::Key_S); - insert(DIKS_CAPITAL_T , Qt::Key_T); - insert(DIKS_CAPITAL_U , Qt::Key_U); - insert(DIKS_CAPITAL_V , Qt::Key_V); - insert(DIKS_CAPITAL_W , Qt::Key_W); - insert(DIKS_CAPITAL_X , Qt::Key_X); - insert(DIKS_CAPITAL_Y , Qt::Key_Y); - insert(DIKS_CAPITAL_Z , Qt::Key_Z); - insert(DIKS_SQUARE_BRACKET_LEFT , Qt::Key_BracketLeft); - insert(DIKS_BACKSLASH , Qt::Key_Backslash); - insert(DIKS_SQUARE_BRACKET_RIGHT , Qt::Key_BracketRight); - insert(DIKS_CIRCUMFLEX_ACCENT , Qt::Key_AsciiCircum); - insert(DIKS_UNDERSCORE , Qt::Key_Underscore); - insert(DIKS_SMALL_A , Qt::Key_A); - insert(DIKS_SMALL_B , Qt::Key_B); - insert(DIKS_SMALL_C , Qt::Key_C); - insert(DIKS_SMALL_D , Qt::Key_D); - insert(DIKS_SMALL_E , Qt::Key_E); - insert(DIKS_SMALL_F , Qt::Key_F); - insert(DIKS_SMALL_G , Qt::Key_G); - insert(DIKS_SMALL_H , Qt::Key_H); - insert(DIKS_SMALL_I , Qt::Key_I); - insert(DIKS_SMALL_J , Qt::Key_J); - insert(DIKS_SMALL_K , Qt::Key_K); - insert(DIKS_SMALL_L , Qt::Key_L); - insert(DIKS_SMALL_M , Qt::Key_M); - insert(DIKS_SMALL_N , Qt::Key_N); - insert(DIKS_SMALL_O , Qt::Key_O); - insert(DIKS_SMALL_P , Qt::Key_P); - insert(DIKS_SMALL_Q , Qt::Key_Q); - insert(DIKS_SMALL_R , Qt::Key_R); - insert(DIKS_SMALL_S , Qt::Key_S); - insert(DIKS_SMALL_T , Qt::Key_T); - insert(DIKS_SMALL_U , Qt::Key_U); - insert(DIKS_SMALL_V , Qt::Key_V); - insert(DIKS_SMALL_W , Qt::Key_W); - insert(DIKS_SMALL_X , Qt::Key_X); - insert(DIKS_SMALL_Y , Qt::Key_Y); - insert(DIKS_SMALL_Z , Qt::Key_Z); - insert(DIKS_CURLY_BRACKET_LEFT , Qt::Key_BraceLeft); - insert(DIKS_VERTICAL_BAR , Qt::Key_Bar); - insert(DIKS_CURLY_BRACKET_RIGHT , Qt::Key_BraceRight); - insert(DIKS_TILDE , Qt::Key_AsciiTilde); -} diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h deleted file mode 100644 index 0b1a24f..0000000 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef QDIRECTFBCONVENIENCE_H -#define QDIRECTFBCONVENIENCE_H - -#include -#include -#include -#include - -#include - -class QDirectFbKeyMap: public QHash -{ -public: - QDirectFbKeyMap(); -}; - - -class QDirectFbConvenience -{ -public: - static QImage::Format imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps); - static bool pixelFomatHasAlpha(const DFBSurfacePixelFormat format) { return (1 << 16) & format; } - static int colorDepthForSurface(const DFBSurfacePixelFormat format); - - //This is set by the graphicssystem constructor - static IDirectFB *dfbInterface(); - static IDirectFBDisplayLayer *dfbDisplayLayer(int display = DLID_PRIMARY); - - static IDirectFBSurface *dfbSurfaceForPixmapData(QPixmapData *); - - static Qt::MouseButton mouseButton(DFBInputDeviceButtonIdentifier identifier); - static Qt::MouseButtons mouseButtons(DFBInputDeviceButtonMask mask); - static Qt::KeyboardModifiers keyboardModifiers(DFBInputDeviceModifierMask mask); - static QEvent::Type eventType(DFBWindowEventType type); - - static QDirectFbKeyMap *keyMap(); - -private: - static QDirectFbKeyMap *dfbKeymap; - friend class QDirectFbGraphicsSystem; -}; - -#endif // QDIRECTFBCONVENIENCE_H diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp deleted file mode 100644 index 229a875..0000000 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "qdirectfbcursor.h" -#include "qblitter_directfb.h" -#include "qgraphicssystem_minimaldfb.h" -#include "qdirectfbconvenience.h" - -#include - -QDirectFBCursor::QDirectFBCursor(QGraphicsSystemScreen * screen) : - QGraphicsSystemCursor(screen), surface(0) -{ - QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY, &m_layer); - image = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); -} - -void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) -{ - Q_UNUSED(widget); - int xSpot; - int ySpot; - QPixmap map; - - if (cursor->shape() != Qt::BitmapCursor) { - image->set(cursor->shape()); - xSpot = image->hotspot().x(); - ySpot = image->hotspot().y(); - QImage *i = image->image(); - map = QPixmap::fromImage(*i); - } else { - QPoint point = cursor->hotSpot(); - xSpot = point.x(); - ySpot = point.y(); - map = cursor->pixmap(); - } - - IDirectFBSurface *surface = QDirectFbConvenience::dfbSurfaceForPixmapData(map.pixmapData()); - - if (m_layer->SetCooperativeLevel(m_layer, DLSCL_ADMINISTRATIVE) != DFB_OK) { - return; - } - m_layer->SetCursorShape( m_layer, surface, xSpot, ySpot); - m_layer->SetCooperativeLevel(m_layer, DLSCL_SHARED); -} diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.h deleted file mode 100644 index 064a336..0000000 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbcursor.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef QDIRECTFBCURSOR_H -#define QDIRECTFBCURSOR_H - -#include -#include -class QDirectFbGraphicsSystemScreen; -class QDirectFbBlitter; - -class QDirectFBCursor : public QGraphicsSystemCursor -{ -public: - QDirectFBCursor(QGraphicsSystemScreen *screem); - void changeCursor(QCursor * cursor, QWidget * widget); - -private: - IDirectFBDisplayLayer * m_layer; - IDirectFBSurface * surface; - QGraphicsSystemCursorImage * image; - QDirectFbBlitter *blitter; -}; - -#endif // QDIRECTFBCURSOR_H diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp deleted file mode 100644 index 74a38a4..0000000 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include "qdirectfbinput.h" -#include "qdirectfbconvenience.h" - -#include -#include -#include -#include -#include -#include - -#include - -InputSocketWaiter::InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent) - : QThread(parent), m_eventBuffer(eventBuffer),m_shouldStop(false) -{ - this->start(); -} - -InputSocketWaiter::~InputSocketWaiter() -{ - m_shouldStop = true; - m_eventBuffer->WakeUp(m_eventBuffer); - m_cleanupMutex.lock(); -} - -void InputSocketWaiter::continueWaitingForEvents() -{ - m_finishedProcessingEvents.wakeAll(); -} - -void InputSocketWaiter::run() -{ - m_cleanupMutex.lock(); - while (1) { - m_eventBuffer->WaitForEvent(m_eventBuffer); - if (m_shouldStop) - break; - emit newEvent(); - QMutex waitForProcessingMutex; - waitForProcessingMutex.lock(); - m_finishedProcessingEvents.wait(&waitForProcessingMutex); - } - m_cleanupMutex.unlock(); -} - -QDirectFbInput *QDirectFbInput::instance() -{ - static QDirectFbInput *input = 0; - if (!input) { - input = new QDirectFbInput(); - } - return input; -} - -QDirectFbInput::QDirectFbInput() - : QObject() -{ - dfbInterface = QDirectFbConvenience::dfbInterface(); - - DFBResult ok = dfbInterface->CreateEventBuffer(dfbInterface,&eventBuffer); - if (ok != DFB_OK) - DirectFBError("Failed to initialise eventbuffer", ok); - - dfbInterface->GetDisplayLayer(dfbInterface,DLID_PRIMARY, &dfbDisplayLayer); - - m_inputHandler = new InputSocketWaiter(eventBuffer,this); - connect(m_inputHandler,SIGNAL(newEvent()),this,SLOT(handleEvents())); - - connect(QApplication::instance(),SIGNAL(aboutToQuit()),SLOT(applicationEnd())); -} - -void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) -{ - tlwMap.insert(id,tlw); - IDirectFBWindow *window; - dfbDisplayLayer->GetWindow(dfbDisplayLayer,id,&window); - - window->AttachEventBuffer(window,eventBuffer); -} - -void QDirectFbInput::removeWindow(QWidget *tlw) -{ - DFBWindowID id = tlwMap.key(tlw,0); - if (id) { - IDirectFBWindow *window; - dfbDisplayLayer->GetWindow(dfbDisplayLayer,id, &window); - - window->DetachEventBuffer(window,eventBuffer); - tlwMap.remove(id); - } -} - -void QDirectFbInput::handleEvents() -{ - DFBResult hasEvent = eventBuffer->HasEvent(eventBuffer); - while(hasEvent == DFB_OK){ - DFBEvent event; - DFBResult ok = eventBuffer->GetEvent(eventBuffer,&event); - if (ok != DFB_OK) - DirectFBError("Failed to get event",ok); - if (event.clazz == DFEC_WINDOW) { - switch (event.window.type) { - case DWET_BUTTONDOWN: - case DWET_BUTTONUP: - case DWET_MOTION: - handleMouseEvents(event); - break; - case DWET_WHEEL: - handleWheelEvent(event); - break; - case DWET_KEYDOWN: - case DWET_KEYUP: - handleKeyEvents(event); - break; - case DWET_ENTER: - case DWET_LEAVE: - handleEnterLeaveEvents(event); - default: - break; - } - - } - - hasEvent = eventBuffer->HasEvent(eventBuffer); - } - m_inputHandler->continueWaitingForEvents(); -} - -void QDirectFbInput::handleMouseEvents(const DFBEvent &event) -{ - QPoint p(event.window.x, event.window.y); - QPoint globalPos = globalPoint(event); - Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); - - IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); - IDirectFBWindow *window; - layer->GetWindow(layer,event.window.window_id,&window); - - long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); - - if (event.window.type == DWET_BUTTONDOWN) { - window->GrabPointer(window); - } else if (event.window.type == DWET_BUTTONUP) { - window->UngrabPointer(window); - } - QWidget *tlw = tlwMap.value(event.window.window_id); - QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons); -} - -void QDirectFbInput::applicationEnd() -{ - delete m_inputHandler; - m_inputHandler = 0; -} - -void QDirectFbInput::handleWheelEvent(const DFBEvent &event) -{ - QPoint p(event.window.cx, event.window.cy); - QPoint globalPos = globalPoint(event); - long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); - QWidget *tlw = tlwMap.value(event.window.window_id); - QWindowSystemInterface::handleWheelEvent(tlw, timestamp, p, globalPos, - event.window.step*120, - Qt::Vertical); -} - -void QDirectFbInput::handleKeyEvents(const DFBEvent &event) -{ - QEvent::Type type = QDirectFbConvenience::eventType(event.window.type); - Qt::Key key = QDirectFbConvenience::keyMap()->value(event.window.key_symbol); - Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers); - - long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); - - QChar character; - if (DFB_KEY_TYPE(event.window.key_symbol) == DIKT_UNICODE) - character = QChar(event.window.key_symbol); - QWidget *tlw = tlwMap.value(event.window.window_id); - QWindowSystemInterface::handleKeyEvent(tlw, timestamp, type, key, modifiers, character); -} - -void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) -{ - QWidget *tlw = tlwMap.value(event.window.window_id); - switch (event.window.type) { - case DWET_ENTER: - QWindowSystemInterface::handleEnterEvent(tlw); - break; - case DWET_LEAVE: - QWindowSystemInterface::handleLeaveEvent(tlw); - break; - default: - break; - } -} - -inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const -{ - IDirectFBWindow *window; - dfbDisplayLayer->GetWindow(dfbDisplayLayer,event.window.window_id,&window); - int x,y; - window->GetPosition(window,&x,&y); - return QPoint(event.window.cx +x, event.window.cy + y); -} - diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h deleted file mode 100644 index 31aa082..0000000 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef QDIRECTFBINPUT_H -#define QDIRECTFBINPUT_H - -#include -#include -#include -#include -#include -#include -#include - -#include - -class InputSocketWaiter : public QThread -{ - Q_OBJECT -public: - InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent); - virtual ~InputSocketWaiter(); - void continueWaitingForEvents(); -protected: - void run(); -signals: - void newEvent(); -private: - IDirectFBEventBuffer *m_eventBuffer; - bool m_shouldStop; - QMutex m_cleanupMutex; - QWaitCondition m_finishedProcessingEvents; -}; - -class QDirectFbInput : public QObject -{ - Q_OBJECT -public: - static QDirectFbInput *instance(); - void addWindow(DFBWindowID id, QWidget *tlw); - void removeWindow(QWidget *tlw); - -public slots: - void handleEvents(); - void applicationEnd(); - -private: - QDirectFbInput(); - - void handleMouseEvents(const DFBEvent &event); - void handleWheelEvent(const DFBEvent &event); - void handleKeyEvents(const DFBEvent &event); - void handleEnterLeaveEvents(const DFBEvent &event); - IDirectFB *dfbInterface; - IDirectFBDisplayLayer *dfbDisplayLayer; - IDirectFBEventBuffer *eventBuffer; - - QHashtlwMap; - - inline QPoint globalPoint(const DFBEvent &event) const; - - InputSocketWaiter *m_inputHandler; - -}; - -#endif // QDIRECTFBINPUT_H diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp deleted file mode 100644 index 4489e31..0000000 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_minimaldfb.h" -#include "qwindowsurface_minimaldfb.h" -#include "qblitter_directfb.h" -#include "qdirectfbconvenience.h" -#include "qdirectfbcursor.h" - -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(int display) - :QGraphicsSystemScreen() -{ - m_layer = QDirectFbConvenience::dfbDisplayLayer(display); - m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); - - DFBDisplayLayerConfig config; - m_layer->GetConfiguration(m_layer, &config); - - m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps); - m_geometry = QRect(0,0,config.width,config.height); - const int dpi = 72; - const qreal inch = 25.4; - m_depth = 32; - m_physicalSize = QSize(qRound(config.width * inch / dpi), qRound(config.height *inch / dpi)); - - cursor = new QDirectFBCursor(this); -} - -QDirectFbGraphicsSystemScreen::~QDirectFbGraphicsSystemScreen() -{ -} - -QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() -{ - const QStringList args = QCoreApplication::arguments(); - int argc = args.size(); - char **argv = new char*[argc]; - - for (int i = 0; i < argc; ++i) - argv[i] = qstrdup(args.at(i).toLocal8Bit().constData()); - - DFBResult result = DirectFBInit(&argc, &argv); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreen: error initializing DirectFB", - result); - } - delete[] argv; - - mPrimaryScreen = new QDirectFbGraphicsSystemScreen(0); - mScreens.append(mPrimaryScreen); -} - -QPixmapData *QDirectFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - if (type == QPixmapData::BitmapType) - return new QRasterPixmapData(type); - else - return new QBlittablePixmapData(type); -} - -QWindowSurface *QDirectFbGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - return new QDirectFbWindowSurface (widget); -} - -QBlittable *QDirectFbGraphicsSystem::createBlittable(const QRect &rect) const -{ - return new QDirectFbBlitter(rect); -} - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h deleted file mode 100644 index b16153d..0000000 --- a/src/plugins/graphicssystems/minimaldfb/qgraphicssystem_minimaldfb.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_MINIMAL_H -#define QGRAPHICSSYSTEM_MINIMAL_H - -#include "qdirectfbinput.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDirectFBCursor; - -class QDirectFbGraphicsSystemScreen : public QGraphicsSystemScreen -{ -public: - QDirectFbGraphicsSystemScreen(int display); - ~QDirectFbGraphicsSystemScreen(); - - 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; } - -public: - QRect m_geometry; - int m_depth; - QImage::Format m_format; - QSize m_physicalSize; - - IDirectFBDisplayLayer *m_layer; - -private: - QDirectFBCursor * cursor; - -}; - -class QDirectFbGraphicsSystem : public QGraphicsSystem -{ -public: - QDirectFbGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - QBlittable *createBlittable(const QRect &rect) const; - - QList screens() const { return mScreens; } - - - -private: - QDirectFbGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp deleted file mode 100644 index 07a9b8a..0000000 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindowsurface_minimaldfb.h" -#include "qgraphicssystem_minimaldfb.h" -#include "qblitter_directfb.h" -#include "qdirectfbconvenience.h" -#include - -#include - -QT_BEGIN_NAMESPACE - -QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window) - : QWindowSurface(window), m_pixmap(0), m_pmdata(0), - m_dfbWindow(0), m_dfbSurface(0) -{ - window->setWindowSurface(this); - - IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); - DFBDisplayLayerConfig layerConfig; - layer->GetConfiguration(layer,&layerConfig); - - DFBWindowDescription description; - memset(&description,0,sizeof(DFBWindowDescription)); - description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS -#if DIRECTFB_MINOR_VERSION >= 1 - |DWDESC_OPTIONS -#endif - |DWDESC_CAPS); - description.width = window->rect().width(); - description.height = window->rect().height(); - description.posx = window->rect().x(); - description.posy = window->rect().y(); - - if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED) - description.surface_caps = DSCAPS_PREMULTIPLIED; - description.pixelformat = layerConfig.pixelformat; - -#if DIRECTFB_MINOR_VERSION >= 1 - description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); -#endif - description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL); - description.surface_caps = DSCAPS_PREMULTIPLIED; - - DFBResult result = layer->CreateWindow(layer,&description,&m_dfbWindow); - if (result != DFB_OK) { - DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); - } - - DFBWindowID id; - m_dfbWindow->GetID(m_dfbWindow, &id); - QDirectFbInput::instance()->addWindow(id,window); - - m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); - - QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect(), m_dfbSurface); - m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); - m_pmdata->setBlittable(blitter); - m_pixmap = new QPixmap(m_pmdata); -} - -QDirectFbWindowSurface::~QDirectFbWindowSurface() -{ - QDirectFbInput::instance()->removeWindow(this->window()); - m_dfbWindow->Destroy(m_dfbWindow); -} - -QPaintDevice *QDirectFbWindowSurface::paintDevice() -{ - return m_pixmap; -} - -void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - m_pmdata->blittable()->unlock(); - - const quint8 windowOpacity = quint8(widget->windowOpacity() * 0xff); - m_dfbWindow->SetOpacity(m_dfbWindow,windowOpacity); - - QVector rects = region.rects(); - for (int i = 0 ; i < rects.size(); i++) { - const QRect rect = rects.at(i); - DFBRegion dfbReg = { rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()}; - m_dfbSurface->Flip(m_dfbSurface, &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC)); - } -} - -void QDirectFbWindowSurface::setGeometry(const QRect &rect) -{ - m_pmdata->blittable()->unlock(); - - QWindowSurface::setGeometry(rect); - m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), - rect.width(), rect.height()); - - //Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable - m_dfbSurface->AddRef(m_dfbSurface); - QDirectFbBlitter *blitter = new QDirectFbBlitter(rect,m_dfbSurface); - m_pmdata->setBlittable(blitter); -} - -static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) -{ - const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; - surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy); - const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy }; - surface->Flip(surface, ®ion, DFBSurfaceFlipFlags(DSFLIP_BLIT)); -} - -bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - m_pmdata->blittable()->unlock(); - - if (!m_dfbSurface || area.isEmpty()) - return false; - m_dfbSurface->SetBlittingFlags(m_dfbSurface, DSBLIT_NOFX); - if (area.rectCount() == 1) { - scrollSurface(m_dfbSurface, area.boundingRect(), dx, dy); - } else { - const QVector rects = area.rects(); - const int n = rects.size(); - for (int i=0; iblittable()->unlock(); - - if (visible) { - int x = this->geometry().x(); - int y = this->geometry().y(); - m_dfbWindow->MoveTo(m_dfbWindow,x,y); - } else { - IDirectFBDisplayLayer *displayLayer; - QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY,&displayLayer); - - DFBDisplayLayerConfig config; - displayLayer->GetConfiguration(displayLayer,&config); - m_dfbWindow->MoveTo(m_dfbWindow,config.width+1,config.height + 1); - } -} - -Qt::WindowFlags QDirectFbWindowSurface::setWindowFlags(Qt::WindowFlags flags) -{ - switch (flags & Qt::WindowType_Mask) { - case Qt::ToolTip: { - DFBWindowOptions options; - m_dfbWindow->GetOptions(m_dfbWindow,&options); - options = DFBWindowOptions(options | DWOP_GHOST); - m_dfbWindow->SetOptions(m_dfbWindow,options); - break; } - default: - break; - } - - m_dfbWindow->SetStackingClass(m_dfbWindow, flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE); - return flags; -} - -void QDirectFbWindowSurface::raise() -{ - m_dfbWindow->RaiseToTop(m_dfbWindow); -} - -void QDirectFbWindowSurface::lower() -{ - m_dfbWindow->LowerToBottom(m_dfbWindow); -} - -WId QDirectFbWindowSurface::winId() const -{ - DFBWindowID id; - m_dfbWindow->GetID(m_dfbWindow, &id); - return WId(id); -} - - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h deleted file mode 100644 index ca34cbf..0000000 --- a/src/plugins/graphicssystems/minimaldfb/qwindowsurface_minimaldfb.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_MINIMAL_H -#define QWINDOWSURFACE_MINIMAL_H - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class QDirectFbGraphicsSystemScreen; - -class QDirectFbWindowSurface : public QWindowSurface -{ -public: - QDirectFbWindowSurface(QWidget *window); - ~QDirectFbWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - - void setVisible(bool visible); - Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); - - void raise(); - void lower(); - - WId winId() const; - -private: - void lockSurfaceToImage(); - - QPixmap *m_pixmap; - QBlittablePixmapData *m_pmdata; - - IDirectFBWindow *m_dfbWindow; - IDirectFBSurface *m_dfbSurface; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/openkode/frag.glslf b/src/plugins/graphicssystems/openkode/frag.glslf deleted file mode 100644 index a593434..0000000 --- a/src/plugins/graphicssystems/openkode/frag.glslf +++ /dev/null @@ -1,8 +0,0 @@ -uniform sampler2D tex_samp; - -varying vec2 texcoord_var; - -void main() -{ - gl_FragColor = texture2D(tex_samp, texcoord_var); -} diff --git a/src/plugins/graphicssystems/openkode/frag.h b/src/plugins/graphicssystems/openkode/frag.h deleted file mode 100644 index 6575cb5..0000000 --- a/src/plugins/graphicssystems/openkode/frag.h +++ /dev/null @@ -1,37 +0,0 @@ -0x4e,0x56,0x75,0x63,0x01,0x00,0x00,0x00,0x09,0x00,0x06,0x00,0x06,0x00,0x50,0x00, -0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x50,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x40,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x27,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x50,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0xe8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x70,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x11,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xb0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x12,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0xc0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x2b,0x00,0x00,0x00,0x7a,0x00,0x00,0x00,0xd0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x2c,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x68,0x69,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff, -0x00,0x00,0x00,0x80,0x04,0x00,0x00,0x90,0x00,0x02,0x01,0x82,0x04,0x02,0x02,0x82, -0x01,0x00,0x40,0xf6,0x85,0xc7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x3a,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x2a,0x00,0x06,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0x3b,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x49,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x04,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0x00,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x00,0x00,0x00,0x74,0x65,0x78,0x63, -0x6f,0x6f,0x72,0x64,0x5f,0x76,0x61,0x72,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/src/plugins/graphicssystems/openkode/main.cpp b/src/plugins/graphicssystems/openkode/main.cpp deleted file mode 100644 index e9c1083..0000000 --- a/src/plugins/graphicssystems/openkode/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qgraphicssystem_openkode.h" - -QT_BEGIN_NAMESPACE - -class QOpenKODEGraphicsSystemPlugin : public QGraphicsSystemPlugin -{ -public: - QStringList keys() const; - QGraphicsSystem *create(const QString&); -}; - -QStringList QOpenKODEGraphicsSystemPlugin::keys() const -{ - QStringList list; - list << "OpenKODE"; - return list; -} - -QGraphicsSystem* QOpenKODEGraphicsSystemPlugin::create(const QString& system) -{ - if (system.toLower() == "openkode") - return new QOpenKODEGraphicsSystem; - - return 0; -} - -Q_EXPORT_PLUGIN2(openkode, QOpenKODEGraphicsSystemPlugin) - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openkode/openkode.pro b/src/plugins/graphicssystems/openkode/openkode.pro deleted file mode 100644 index 055048d..0000000 --- a/src/plugins/graphicssystems/openkode/openkode.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qopenkodegraphicssystem -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - -SOURCES = main.cpp qgraphicssystem_openkode.cpp qwindowsurface_openkode.cpp -HEADERS = qgraphicssystem_openkode.h qwindowsurface_openkode.h - -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -INSTALLS += target - -# openkode specific stuff -INCLUDEPATH += $(OPENKODE_DIR)/include -LIBS += $${QMAKE_RPATH}/$(OPENKODE_DIR)/lib-target -L$(OPENKODE_DIR)/lib-target -lKD -lEGL -lGLESv2 diff --git a/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.cpp b/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.cpp deleted file mode 100644 index 7a07776..0000000 --- a/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_openkode.h" -#include "qwindowsurface_openkode.h" -#include - -#include -#include - -#include -#include -#include - -#include "GLES2/gl2ext.h" - - -QT_BEGIN_NAMESPACE - -QOpenKODEGraphicsSystemScreen::QOpenKODEGraphicsSystemScreen() -{ - KDDesktopNV *kdDesktop = KD_NULL; - KDDisplayNV *kdDisplay = KD_NULL; - - qDebug() << "QOpenKODEGraphicsSystemScreen::QOpenKODEGraphicsSystemScreen()"; - - // Get the default desktop and display - kdDesktop = kdGetDesktopNV(KD_DEFAULT_DESKTOP_NV, KD_NULL); - if (!kdDesktop || kdDesktop == (void*)-1) { - qErrnoWarning(kdGetError(), "Could not obtain KDDesktopNV pointer"); - return; - } - - kdDisplay = kdGetDisplayNV(KD_DEFAULT_DISPLAY_NV, KD_NULL); - if (!kdDisplay || kdDisplay == (void*)-1) { - qErrnoWarning(kdGetError(), "Could not obtain KDDisplayNV pointer"); - kdReleaseDesktopNV(kdDesktop); - return; - } - - KDDisplayModeNV mode; - if (kdGetDisplayModeNV(kdDisplay, &mode)) { - qErrnoWarning(kdGetError(), "Could not get display mode"); - return; - } - - qDebug() << " - display mode " << mode.width << "x" << mode.height << " refresh " << mode.refresh; - - KDint desktopSize[] = { mode.width, mode.height }; - - if (kdSetDesktopPropertyivNV(kdDesktop, KD_DESKTOPPROPERTY_SIZE_NV, desktopSize)) { - qErrnoWarning(kdGetError(), "Could not set desktop size"); - return; - } - - // Once we've set up the desktop and display we don't need them anymore - kdReleaseDisplayNV(kdDisplay); - kdReleaseDesktopNV(kdDesktop); - - const int defaultDpi = 72; - mGeometry = QRect(0, 0, mode.width, mode.height); - mPhysicalSize = QSize(mode.width * 25.4 / defaultDpi, mode.height * 25.4 / defaultDpi); - - mDepth = 24; - mFormat = QImage::Format_RGB888; - - - QEglProperties properties; - properties.setPixelFormat(QImage::Format_RGB888); - properties.setValue(EGL_BUFFER_SIZE, EGL_DONT_CARE); - properties.setRenderableType(QEgl::OpenGL); - - if (!mContext.chooseConfig(properties, QEgl::BestPixelFormat)) { - qWarning("qEglContext: Unable to choose config!"); - return; - } - - if (!mContext.display()) { - qWarning("qEglContext: Unable to open display!"); - return; - } - - qDebug() << " - QEglContext::openDisplay OK"; -} - -static GLuint NvKdTestLoadShaders(const char *vertex_shader_binary, - const char *fragment_shader_binary, - GLuint vertex_shader_binary_size, - GLuint fragment_shader_binary_size) -{ - GLuint prog; - GLuint vertShader; - GLuint fragShader; - - // Create the program - prog = glCreateProgram(); - - // Create the GL shader objects - vertShader = glCreateShader(GL_VERTEX_SHADER); - fragShader = glCreateShader(GL_FRAGMENT_SHADER); - - // Load the binary data into the shader objects - glShaderBinary(1, &vertShader, - GL_NVIDIA_PLATFORM_BINARY_NV, vertex_shader_binary, vertex_shader_binary_size); - glShaderBinary(1, &fragShader, - GL_NVIDIA_PLATFORM_BINARY_NV, fragment_shader_binary, fragment_shader_binary_size); - - // Attach the shaders to the program - glAttachShader(prog, vertShader); - glAttachShader(prog, fragShader); - - // Delete the shaders - glDeleteShader(vertShader); - glDeleteShader(fragShader); - - // Link and validate the shader program - glLinkProgram(prog); - glValidateProgram(prog); - - return prog; -} - -class QOpenKODEEventLoopHelper : public QThread -{ -public: - QOpenKODEEventLoopHelper(QSemaphore *m) - : eventMutex(m) - { - m->acquire(); - } - -protected: - void run() - { - qDebug() << "initializing KD"; - kdInitializeNV(); - qDebug() << "done initializing KD"; - eventMutex->release(); - - const KDEvent *event; - while ((event = kdWaitEvent(-1)) != 0) { - qDebug() << "!!! received event!"; - kdDefaultEvent(event); - } - - qDebug() << "exiting event loop"; - } - -private: - QSemaphore *eventMutex; -}; - -QOpenKODEGraphicsSystem::QOpenKODEGraphicsSystem() - : eventMutex(1) -{ - QOpenKODEEventLoopHelper *loop = new QOpenKODEEventLoopHelper(&eventMutex); - loop->start(); - eventMutex.acquire(); // block until initialization done - - mPrimaryScreen = new QOpenKODEGraphicsSystemScreen(); - - mScreens.append(mPrimaryScreen); - -} - -QPixmapData *QOpenKODEGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -QWindowSurface *QOpenKODEGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - return new QOpenKODEWindowSurface(mPrimaryScreen, widget); -} - -GLuint QOpenKODEGraphicsSystem::blitterProgram() -{ - static GLuint shaderProgram = 0; - if (!shaderProgram) { - - const char vertShaderBinary[] = { -# include "vert.h" - }; - const char fragShaderBinary[] = { -# include "frag.h" - }; - - shaderProgram = NvKdTestLoadShaders(vertShaderBinary, fragShaderBinary, - sizeof(vertShaderBinary), sizeof(fragShaderBinary)); - - if (!shaderProgram) - qFatal("QOpenKodeGraphicsSystem(): Cannot load shaders!"); - } - return shaderProgram; -} - - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.h b/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.h deleted file mode 100644 index 7d73ae0..0000000 --- a/src/plugins/graphicssystems/openkode/qgraphicssystem_openkode.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_OPENKODE_H -#define QGRAPHICSSYSTEM_OPENKODE_H - -#include - -#include -#include - -# include - -QT_BEGIN_NAMESPACE - -struct KDDesktopNV; - -class QOpenKODEGraphicsSystemScreen : public QGraphicsSystemScreen -{ -public: - QOpenKODEGraphicsSystemScreen(); - ~QOpenKODEGraphicsSystemScreen() {} - - QRect geometry() const { return mGeometry; } - int depth() const { return mDepth; } - QImage::Format format() const { return mFormat; } - QSize physicalSize() const { return mPhysicalSize; } - -public: - QRect mGeometry; - int mDepth; - QImage::Format mFormat; - QSize mPhysicalSize; - QEglContext mContext; -}; - -class QOpenKODEGraphicsSystem : public QGraphicsSystem -{ -public: - QOpenKODEGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - - QList screens() const { return mScreens; } - - static GLuint blitterProgram(); - -private: - QOpenKODEGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; - QSemaphore eventMutex; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.cpp b/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.cpp deleted file mode 100644 index b3f3965..0000000 --- a/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindowsurface_openkode.h" -#include "qgraphicssystem_openkode.h" -#include - -#include "KD/kd.h" -#include "KD/NV_display.h" - -QT_BEGIN_NAMESPACE - -QOpenKODEWindowSurface::QOpenKODEWindowSurface - (QOpenKODEGraphicsSystemScreen *screen, QWidget *window) - : QWindowSurface(window), - mScreen(screen), - mSurface(0) -{ - qDebug() << "QOpenKODEWindowSurface::QOpenKODEWindowSurface:" << window << window->width() << "x" << window->height() - << "pos" << window->x() << "x" << window->y(); - - if (!mContext.display()) { - qWarning("qEglContext: Unable to open display!"); - return; - } - - QEglProperties properties; - properties.setPixelFormat(QImage::Format_RGB888); - properties.setValue(EGL_BUFFER_SIZE, EGL_DONT_CARE); - properties.setRenderableType(QEgl::OpenGL); - - if (!mContext.chooseConfig(properties, QEgl::BestPixelFormat)) { - qWarning("qEglContext: Unable to choose config!"); - return; - } - - createWindow(window); -} - -void QOpenKODEWindowSurface::createWindow(QWidget *window) -{ - qDebug() << "createWindow"; - kdWindow = kdCreateWindow(mContext.display(), mContext.config(), KD_NULL); - - if (!kdWindow) { - qErrnoWarning(kdGetError(), "Error creating native window"); - return; - } - - const KDint windowSize[2] = { window->width(), window->height() }; - if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { - qErrnoWarning(kdGetError(), "Could not set native window size"); - return; - } - - //const KDboolean windowExclusive[] = { false }; - //if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, windowExclusive)) { - // qErrnoWarning(kdGetError(), "Could not set exclusive bit"); - // //return; - //} - - //const KDint windowPos[2] = { window->x(), window->y() }; - //if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { - // qErrnoWarning(kdGetError(), "Could not set native window position"); - // //return; - //} - - EGLNativeWindowType nativeWindow; - - if (kdRealizeWindow(kdWindow, &nativeWindow)) { - qErrnoWarning(kdGetError(), "Could not realize native window"); - return; - } - qDebug() << "kdRealizeWindow" << nativeWindow; - - // Create an EGL window surface for the native window - EGLint windowAttrs[3] = { EGL_NONE }; - qDebug() << "doing createwindowsurface"; - *mSurface = eglCreateWindowSurface(mContext.display(), - mContext.config(), - nativeWindow, - windowAttrs); - qDebug() << "create windowsurface"; - if (!mSurface) { - qWarning("EGL couldn't create window surface: 0x%x", eglGetError()); - return; - } - - qDebug() << "making context"; - if (!mContext.createContext()) { - qDebug() << "Unable to create context!"; - return; - } - - qDebug() << "about to make current"; - mContext.makeCurrent(mSurface); -} - -QOpenKODEWindowSurface::~QOpenKODEWindowSurface() -{ -} - -QPaintDevice *QOpenKODEWindowSurface::paintDevice() -{ - qDebug() << "QOpenKODEWindowSurface::paintDevice"; - return &mImage; -} - -// ### TODO - this updates the entire toplevel, should only update the region -void QOpenKODEWindowSurface::flush(QWidget *, const QRegion ®ion, const QPoint &offset) -{ - qDebug() << "in flush"; - if (!offset.isNull()) { - qWarning("Offset flushing not supported yet"); - return; - } - - if (!mContext.makeCurrent(mSurface)) { - qWarning("EGL couldn't make context/surface current: 0x%x", eglGetError()); - return; - } - - QRect boundingRect = region.boundingRect(); - - int x, y, w, h; - QImage blitImage; - if (true || boundingRect == mImage.rect()) { // TODO - check optimization - blitImage = mImage; - x = y = 0; - w = mImage.width(); - h = mImage.height(); - } else { - blitImage = mImage.copy(boundingRect); - w = boundingRect.width(); - h = boundingRect.height(); - x = boundingRect.x(); - y = boundingRect.y(); - } - -// qDebug() << "flush" << widget << offset << region.boundingRect() << mImage.format() << blitImage.format(); - - GLuint shaderProgram = QOpenKODEGraphicsSystem::blitterProgram(); - - glUseProgram(shaderProgram); - - GLuint index = glGetUniformLocation(shaderProgram, "window"); - glUniform2f(index, GLfloat(mImage.width()), GLfloat(mImage.height())); - - // attributes - GLuint posId = glGetAttribLocation(shaderProgram, "pos_attr"); - GLuint texcoordId = glGetAttribLocation(shaderProgram, "texcoord_attr"); - - // sampler - index = glGetUniformLocation(shaderProgram, "tex_samp"); - - glUniform1i(index, 0); - - glDisable(GL_DEPTH_TEST); - glActiveTexture(GL_TEXTURE0); - - GLuint texId; - GLfloat coords[8] = {x, y, x, y + h, x + w, y + h, x + w, y }; - GLfloat texcoords[8] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0 }; - - // Generate texture for checkered background - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glGenTextures(1, &texId); - glBindTexture(GL_TEXTURE_2D, texId); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, blitImage.bits()); - - // Enable vertex attribute associated with vertex position - glEnableVertexAttribArray(posId); - glEnableVertexAttribArray(texcoordId); - - // Set the quad vertices - glVertexAttribPointer(posId, 2, GL_FLOAT, 0, 0, coords); - glVertexAttribPointer(texcoordId, 2, GL_FLOAT, 0, 0, texcoords); - - // Draw the quad - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - // Cleanup - glDisableVertexAttribArray(posId); - glDisableVertexAttribArray(texcoordId); - - // Release all textures - glBindTexture(GL_TEXTURE_2D, 0); - if (texId) - glDeleteTextures(1, &texId); - - mContext.doneCurrent(); - mContext.swapBuffers(mSurface); -} - -void QOpenKODEWindowSurface::setGeometry(const QRect &rect) -{ - qDebug() << "QOpenKODEWindowSurface::setGeometry:" << rect; - QWindowSurface::setGeometry(rect); - if (mImage.size() != rect.size()) - mImage = QImage(rect.size(), mScreen->format()); - - mContext.destroySurface(mSurface); - kdDestroyWindow(kdWindow); - createWindow(window()); - qDebug() << "set geometry workded"; -} - -bool QOpenKODEWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - return QWindowSurface::scroll(area, dx, dy); -} - -void QOpenKODEWindowSurface::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -void QOpenKODEWindowSurface::endPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.h b/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.h deleted file mode 100644 index bee94a5..0000000 --- a/src/plugins/graphicssystems/openkode/qwindowsurface_openkode.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_OPENKODE_H -#define QWINDOWSURFACE_OPENKODE_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QOpenKODEGraphicsSystemScreen; - -class QOpenKODEWindowSurface : public QWindowSurface -{ -public: - QOpenKODEWindowSurface - (QOpenKODEGraphicsSystemScreen *screen, QWidget *window); - ~QOpenKODEWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - -private: - QOpenKODEGraphicsSystemScreen *mScreen; - QImage mImage; - struct KDWindow *kdWindow; - EGLSurface *mSurface; - QEglContext mContext; - - void createWindow(QWidget *window); -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/openkode/vert.glslv b/src/plugins/graphicssystems/openkode/vert.glslv deleted file mode 100644 index 57b5866..0000000 --- a/src/plugins/graphicssystems/openkode/vert.glslv +++ /dev/null @@ -1,14 +0,0 @@ -uniform vec2 window; // window size - -// Per-vertex attributes] -attribute vec2 pos_attr; -attribute vec2 texcoord_attr; - -// Output vertex color -varying vec2 texcoord_var; - -void main() -{ - gl_Position = vec4( (2.0 * pos_attr / window -1.0) * vec2(1.0, -1.0), 0.0, 1.0); - texcoord_var = texcoord_attr; -} diff --git a/src/plugins/graphicssystems/openkode/vert.h b/src/plugins/graphicssystems/openkode/vert.h deleted file mode 100644 index bdf564d..0000000 --- a/src/plugins/graphicssystems/openkode/vert.h +++ /dev/null @@ -1,63 +0,0 @@ -0x4e,0x56,0x75,0x63,0x01,0x00,0x00,0x00,0x0a,0x00,0x06,0x00,0x06,0x00,0x50,0x00, -0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0xf0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x60,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x24,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x70,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x26,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0xe8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x06,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0xb0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x28,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x05,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x10,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x20,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x30,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x2b,0x00,0x00,0x00,0x39,0x01,0x00,0x00,0xb0,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x04,0x05,0x08,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x0f,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x01,0x02,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xff,0xff,0xff,0xff,0x04,0x05,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x80,0x3f,0x00,0x00,0x00,0x40,0x00,0x00,0x80,0xbf,0x00,0x00,0x00,0x00, -0x05,0x00,0x00,0x10,0x80,0xc7,0x00,0x24,0x05,0x02,0x00,0x10,0x80,0xc7,0x00,0x24, -0x01,0x02,0x81,0xc0,0x80,0x07,0x60,0x00,0x05,0x02,0x00,0x90,0x80,0x07,0x00,0x00, -0x09,0x00,0x01,0xe1,0x80,0x87,0x40,0x00,0x05,0x00,0x00,0x10,0x80,0xc7,0x00,0x24, -0x01,0x00,0x81,0xc0,0x80,0x07,0x60,0x00,0x09,0x04,0x00,0xa0,0x80,0x47,0x00,0xe4, -0x05,0x02,0x00,0x90,0x80,0x07,0x00,0x00,0x05,0x04,0x00,0x10,0x88,0xc7,0x03,0x04, -0x01,0x00,0x01,0xe1,0x88,0x87,0x40,0x00,0x09,0xf8,0x00,0x10,0x88,0xc7,0x03,0x04, -0x0d,0x00,0x00,0x10,0x88,0xc7,0x40,0x24,0x11,0x04,0x00,0x10,0x88,0xc7,0x23,0x04, -0x15,0x06,0x00,0x10,0x89,0xc7,0x23,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xa0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xa1,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0xad,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x28,0x00,0x02,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00, -0xb6,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xb7,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0xbe,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x05,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xbf,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0xc9,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x01,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xca,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xcb,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0xd9,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x01,0x00,0x00,0x00, -0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xda,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xdb,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0xe8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x02,0x00,0x00,0x00, -0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0x00,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x50,0x4f,0x53, -0x49,0x54,0x49,0x4f,0x4e,0x00,0x00,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x00,0x00, -0x70,0x6f,0x73,0x5f,0x61,0x74,0x74,0x72,0x00,0x00,0x00,0x74,0x65,0x78,0x63,0x6f, -0x6f,0x72,0x64,0x5f,0x61,0x74,0x74,0x72,0x00,0x00,0x00,0x74,0x65,0x78,0x63,0x6f, -0x6f,0x72,0x64,0x5f,0x76,0x61,0x72,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/src/plugins/graphicssystems/openvglite/main.cpp b/src/plugins/graphicssystems/openvglite/main.cpp deleted file mode 100644 index dc0b4a8..0000000 --- a/src/plugins/graphicssystems/openvglite/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qgraphicssystem_vglite.h" - -QT_BEGIN_NAMESPACE - -class QVGGraphicsSystemPlugin : public QGraphicsSystemPlugin -{ -public: - QStringList keys() const; - QGraphicsSystem *create(const QString&); -}; - -QStringList QVGGraphicsSystemPlugin::keys() const -{ - QStringList list; - list << "OpenVG"; - return list; -} - -QGraphicsSystem* QVGGraphicsSystemPlugin::create(const QString& system) -{ - if (system.toLower() == "openvg") - return new QVGLiteGraphicsSystem; - - return 0; -} - -Q_EXPORT_PLUGIN2(openvg, QVGGraphicsSystemPlugin) - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openvglite/openvglite.pro b/src/plugins/graphicssystems/openvglite/openvglite.pro deleted file mode 100644 index 9d7860a..0000000 --- a/src/plugins/graphicssystems/openvglite/openvglite.pro +++ /dev/null @@ -1,12 +0,0 @@ -TARGET = qvglitegraphicssystem -include(../../qpluginbase.pri) - -QT += openvg - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - -SOURCES = main.cpp qgraphicssystem_vglite.cpp qwindowsurface_vglite.cpp -HEADERS = qgraphicssystem_vglite.h qwindowsurface_vglite.h - -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -INSTALLS += target diff --git a/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp b/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp deleted file mode 100644 index 41b2303..0000000 --- a/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_vglite.h" -#include "qwindowsurface_vglite.h" -#include -#include -#include -#ifdef OPENVG_USBHP_INIT -extern "C" { -#include -}; -#endif - -QT_BEGIN_NAMESPACE - -QVGLiteGraphicsSystem::QVGLiteGraphicsSystem() - : w(0), h(0), d(0), dw(0), dh(0), physWidth(0), physHeight(0), - surface(0), context(0), rootWindow(0), - screenFormat(QImage::Format_RGB16), preservedSwap(false) -{ -#ifdef OPENVG_USBHP_INIT - initLibrary(); -#endif - - // The graphics system is also the screen definition. - mScreens.append(this); - - QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY")); - QStringList displayArgs = displaySpec.split(QLatin1Char(':')); - - // Initialize EGL and create the global EGL context. - context = qt_vg_create_context(0); - if (!context) { - qFatal("QVGLiteGraphicsSystem: could not initialize EGL"); - return; - } - - // Get the root window handle to use. Default to zero. - QRegExp winidRx(QLatin1String("winid=?(\\d+)")); - int winidIdx = displayArgs.indexOf(winidRx); - int handle = 0; - if (winidIdx >= 0) { - winidRx.exactMatch(displayArgs.at(winidIdx)); - handle = winidRx.cap(1).toInt(); - } - - // Create a full-screen window based on the native handle. - // If the context is premultiplied, the window should be too. - QEglProperties props; -#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT - EGLint surfaceType = 0; - if (context->configAttrib(EGL_SURFACE_TYPE, &surfaceType) && - (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) != 0) - props.setValue(EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE); -#endif - rootWindow = eglCreateWindowSurface - (context->display(), context->config(), - (EGLNativeWindowType)handle, props.properties()); - if (rootWindow == EGL_NO_SURFACE) { - delete context; - context = 0; - qFatal("QVGLiteGraphicsSystem: could not create full-screen window"); - return; - } - - // Try to turn on preserved swap behaviour on the root window. - // This will allow us to optimize compositing to focus on just - // the screen region that has changed. Otherwise we must - // re-composite the entire screen every frame. -#if !defined(QVG_NO_PRESERVED_SWAP) - eglGetError(); // Clear error state first. - eglSurfaceAttrib(context->display(), rootWindow, - EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); - preservedSwap = (eglGetError() == EGL_SUCCESS); -#else - preservedSwap = false; -#endif - - // Fetch the root window properties. - eglQuerySurface(context->display(), rootWindow, EGL_WIDTH, &w); - eglQuerySurface(context->display(), rootWindow, EGL_HEIGHT, &h); - screenFormat = qt_vg_config_to_image_format(context); - switch (screenFormat) { - case QImage::Format_ARGB32_Premultiplied: - case QImage::Format_ARGB32: - case QImage::Format_RGB32: - default: - d = 32; - break; - case QImage::Format_RGB16: - case QImage::Format_ARGB4444_Premultiplied: - d = 16; - break; - } - dw = w; - dh = h; - qDebug("screen size: %dx%dx%d", w, h, d); - - // Handle display physical size spec. From qscreenlinuxfb_qws.cpp. - QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)")); - int dimIdxW = displayArgs.indexOf(mmWidthRx); - QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)")); - int dimIdxH = displayArgs.indexOf(mmHeightRx); - if (dimIdxW >= 0) { - mmWidthRx.exactMatch(displayArgs.at(dimIdxW)); - physWidth = mmWidthRx.cap(1).toInt(); - if (dimIdxH < 0) - physHeight = dh*physWidth/dw; - } - if (dimIdxH >= 0) { - mmHeightRx.exactMatch(displayArgs.at(dimIdxH)); - physHeight = mmHeightRx.cap(1).toInt(); - if (dimIdxW < 0) - physWidth = dw*physHeight/dh; - } - if (dimIdxW < 0 && dimIdxH < 0) { - const int dpi = 72; - physWidth = qRound(dw * 25.4 / dpi); - physHeight = qRound(dh * 25.4 / dpi); - } -} - -QVGLiteGraphicsSystem::~QVGLiteGraphicsSystem() -{ -} - -QPixmapData *QVGLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ -#if !defined(QVGLite_NO_SINGLE_CONTEXT) && !defined(QVGLite_NO_PIXMAP_DATA) - // Pixmaps can use QVGLitePixmapData; bitmaps must use raster. - if (type == QPixmapData::PixmapType) - return new QVGPixmapData(type); - else - return new QRasterPixmapData(type); -#else - return new QRasterPixmapData(type); -#endif -} - -QWindowSurface *QVGLiteGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - if (widget->windowType() == Qt::Desktop) - return 0; // Don't create an explicit window surface for the destkop. - if (surface) { - qWarning() << "QVGLiteGraphicsSystem: only one window surface " - "is supported at a time"; - return 0; - } - surface = new QVGLiteWindowSurface - (const_cast(this), widget); - return surface; -} - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h b/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h deleted file mode 100644 index 512793d..0000000 --- a/src/plugins/graphicssystems/openvglite/qgraphicssystem_vglite.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_VGLITE_H -#define QGRAPHICSSYSTEM_VGLITE_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QVGLiteWindowSurface; - -class QVGLiteGraphicsSystem : public QGraphicsSystem, - public QGraphicsSystemScreen -{ -public: - QVGLiteGraphicsSystem(); - ~QVGLiteGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - QList screens() const { return mScreens; } - - QRect geometry() const { return QRect(0, 0, w, h); } - int depth() const { return d; } - QImage::Format format() const { return screenFormat; } - QSize physicalSize() const { return QSize(physWidth, physHeight); } - -private: - friend class QVGLiteWindowSurface; - - int w; - int h; - int d; - - int dw; - int dh; - - int physWidth; - int physHeight; - - mutable QVGLiteWindowSurface *surface; - QEglContext *context; - EGLSurface rootWindow; - QImage::Format screenFormat; - bool preservedSwap; - - QList mScreens; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp b/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp deleted file mode 100644 index c73e35a..0000000 --- a/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindowsurface_vglite.h" -#include "qgraphicssystem_vglite.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QVGLiteWindowSurface::QVGLiteWindowSurface - (QVGLiteGraphicsSystem *gs, QWidget *window) - : QWindowSurface(window), graphicsSystem(gs), - isPaintingActive(false), engine(0) -{ -} - -QVGLiteWindowSurface::~QVGLiteWindowSurface() -{ - graphicsSystem->surface = 0; - if (engine) - qt_vg_destroy_paint_engine(engine); -} - -QPaintDevice *QVGLiteWindowSurface::paintDevice() -{ - qt_vg_make_current(graphicsSystem->context, graphicsSystem->rootWindow); - isPaintingActive = true; - // TODO: clear the parts of the back buffer that are not - // covered by the window surface to black. - return this; -} - -void QVGLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(region); - Q_UNUSED(offset); - QEglContext *context = graphicsSystem->context; - if (context) { - if (!isPaintingActive) - qt_vg_make_current(context, graphicsSystem->rootWindow); - context->swapBuffers(); - qt_vg_done_current(context); - context->setSurface(EGL_NO_SURFACE); - isPaintingActive = false; - } -} - -void QVGLiteWindowSurface::setGeometry(const QRect &rect) -{ - QWindowSurface::setGeometry(rect); -} - -bool QVGLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - return QWindowSurface::scroll(area, dx, dy); -} - -void QVGLiteWindowSurface::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -void QVGLiteWindowSurface::endPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -QPaintEngine *QVGLiteWindowSurface::paintEngine() const -{ - if (!engine) - engine = qt_vg_create_paint_engine(); - return engine; -} - -// We need to get access to QWidget::metric() from QVGLiteWindowSurface::metric, -// but it is not a friend of QWidget. To get around this, we create a -// fake QX11PaintEngine class, which is a friend. -class QX11PaintEngine -{ -public: - static int metric(const QWidget *widget, QPaintDevice::PaintDeviceMetric met) - { - return widget->metric(met); - } -}; - -int QVGLiteWindowSurface::metric(PaintDeviceMetric met) const -{ - return QX11PaintEngine::metric(window(), met); -} diff --git a/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h b/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h deleted file mode 100644 index 59faba8..0000000 --- a/src/plugins/graphicssystems/openvglite/qwindowsurface_vglite.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_VGLITE_H -#define QWINDOWSURFACE_VGLITE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -class QVGLiteGraphicsSystem; -class QVGPaintEngine; - -class Q_OPENVG_EXPORT QVGLiteWindowSurface : public QWindowSurface, public QPaintDevice -{ -public: - QVGLiteWindowSurface(QVGLiteGraphicsSystem *gs, QWidget *window); - ~QVGLiteWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - - QPaintEngine *paintEngine() const; - -protected: - int metric(PaintDeviceMetric metric) const; - -private: - QVGLiteGraphicsSystem *graphicsSystem; - bool isPaintingActive; - mutable QVGPaintEngine *engine; -}; - -QT_END_NAMESPACE - -#endif // QWINDOWSURFACE_VGLITE_H diff --git a/src/plugins/graphicssystems/qvfb/main.cpp b/src/plugins/graphicssystems/qvfb/main.cpp deleted file mode 100644 index b28dde8..0000000 --- a/src/plugins/graphicssystems/qvfb/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qgraphicssystem_qvfb.h" -#include - -QT_BEGIN_NAMESPACE - -class QVFbGraphicsSystemPlugin : public QGraphicsSystemPlugin -{ -public: - QStringList keys() const; - QGraphicsSystem *create(const QString&); -}; - -QStringList QVFbGraphicsSystemPlugin::keys() const -{ - QStringList list; - list << "QVFb"; - return list; -} - -QGraphicsSystem* QVFbGraphicsSystemPlugin::create(const QString& system) -{ - if (system.toLower() == "qvfb") - return new QVFbGraphicsSystem; - - return 0; -} - -Q_EXPORT_PLUGIN2(qvfb, QVFbGraphicsSystemPlugin) - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp b/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp deleted file mode 100644 index 19058a6..0000000 --- a/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.cpp +++ /dev/null @@ -1,434 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include // overrides QT_OPEN - -#include -#include - -#include "qgraphicssystem_qvfb.h" -#include "qwindowsurface_qvfb.h" -#include -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - - -class QVFbGraphicsSystemScreenKeyboardHandler : public QObject -{ - Q_OBJECT -public: - QVFbGraphicsSystemScreenKeyboardHandler(); - ~QVFbGraphicsSystemScreenKeyboardHandler(); - -private slots: - void readKeyboardData(); - -private: - int kbdFD; - int kbdIdx; - int kbdBufferLen; - unsigned char *kbdBuffer; - QSocketNotifier *keyNotifier; -}; - -QVFbGraphicsSystemScreenKeyboardHandler::QVFbGraphicsSystemScreenKeyboardHandler() -{ - int displayId = 0; //TODO displayId - const QString keyboardDev = QT_VFB_KEYBOARD_PIPE(displayId); - - - kbdFD = -1; - kbdIdx = 0; - kbdBufferLen = sizeof(QVFbKeyData) * 5; - kbdBuffer = new unsigned char [kbdBufferLen]; - - kbdFD = QT_OPEN(keyboardDev.toLatin1().constData(), O_RDWR | O_NDELAY); - - if (kbdFD == -1) { - perror("QVFbGraphicsSystemScreenKeyboardHandler"); - qWarning("QVFbGraphicsSystemScreenKeyboardHandler: Unable to open device %s", - qPrintable(keyboardDev)); - return; - } - - // Clear pending input - char buf[2]; - while (QT_READ(kbdFD, buf, 1) > 0) { } - - keyNotifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this); - connect(keyNotifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData())); - -} - -QVFbGraphicsSystemScreenKeyboardHandler::~QVFbGraphicsSystemScreenKeyboardHandler() -{ - if (kbdFD >= 0) - QT_CLOSE(kbdFD); - delete [] kbdBuffer; -} - - -void QVFbGraphicsSystemScreenKeyboardHandler::readKeyboardData() -{ - int n; - do { - n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx); - if (n > 0) - kbdIdx += n; - } while (n > 0); - - int idx = 0; - while (kbdIdx - idx >= (int)sizeof(QVFbKeyData)) { - QVFbKeyData *kd = (QVFbKeyData *)(kbdBuffer + idx); - if (kd->unicode == 0 && kd->keycode == 0 && kd->modifiers == 0 && kd->press) { - // magic exit key - qWarning("Instructed to quit by Virtual Keyboard"); - qApp->quit(); - } - - //QWSServer::processKeyEvent(kd->unicode ? kd->unicode : 0xffff, kd->keycode, kd->modifiers, kd->press, kd->repeat); - - QEvent::Type type = kd->press ? QEvent::KeyPress : QEvent::KeyRelease; - - QString text; - if (kd->unicode && kd->unicode != 0xffff) - text += QChar(kd->unicode); - -// qDebug() << "readKeyboardData" << type << hex << kd->keycode << kd->modifiers << text; - - QWindowSystemInterface::handleKeyEvent(0, type, kd->keycode, kd->modifiers, text, kd->repeat, int(text.length())); - idx += sizeof(QVFbKeyData); - } - - int surplus = kbdIdx - idx; - for (int i = 0; i < surplus; i++) - kbdBuffer[i] = kbdBuffer[idx+i]; - kbdIdx = surplus; -} - - - - -class QVFbGraphicsSystemScreenMouseHandler : public QObject -{ - Q_OBJECT -public: - QVFbGraphicsSystemScreenMouseHandler(); - ~QVFbGraphicsSystemScreenMouseHandler(); - -private slots: - void readMouseData(); - -private: - int mouseFD; - int mouseIdx; - enum {mouseBufSize = 128}; - uchar mouseBuf[mouseBufSize]; - QSocketNotifier *mouseNotifier; - - int oldButtonState; -}; - -QVFbGraphicsSystemScreenMouseHandler::QVFbGraphicsSystemScreenMouseHandler() -{ - int displayId = 0; //TODO: displayId - QString mouseDev = QT_VFB_MOUSE_PIPE(displayId); - - mouseFD = QT_OPEN(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY); - - if (mouseFD == -1) { - perror("QVFbMouseHandler::QVFbMouseHandler"); - qWarning("QVFbMouseHander: Unable to open device %s", - qPrintable(mouseDev)); - return; - } - - // Clear pending input - char buf[2]; - while (QT_READ(mouseFD, buf, 1) > 0) { } - - mouseIdx = 0; - oldButtonState = 0; - mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this); - connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData())); -} - - -QVFbGraphicsSystemScreenMouseHandler::~QVFbGraphicsSystemScreenMouseHandler() -{ - if (mouseFD >= 0) - QT_CLOSE(mouseFD); -} - -void QVFbGraphicsSystemScreenMouseHandler::readMouseData() -{ - int n; - do { - n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx); - if (n > 0) - mouseIdx += n; - } while (n > 0); - - int idx = 0; - static const int packetsize = sizeof(QPoint) + 2*sizeof(int); - while (mouseIdx-idx >= packetsize) { - uchar *mb = mouseBuf+idx; - QPoint mousePos = *reinterpret_cast(mb); - mb += sizeof(QPoint); - int bstate = *reinterpret_cast(mb); - mb += sizeof(int); - int wheel = *reinterpret_cast(mb); - - int button = bstate ^ oldButtonState; - QEvent::Type type = QEvent::MouseMove; - - if (button) { - type = (button & bstate) ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - } - QWindowSystemInterface::handleMouseEvent(0, mousePos, mousePos, Qt::MouseButtons(bstate)); - -// qDebug() << "readMouseData" << mousePos << button << bstate << oldButtonState << type; - - oldButtonState = bstate; - - idx += packetsize; - } - - int surplus = mouseIdx - idx; - for (int i = 0; i < surplus; i++) - mouseBuf[i] = mouseBuf[idx+i]; - mouseIdx = surplus; - -} - - -class QVFbGraphicsSystemScreenPrivate -{ -public: - QVFbGraphicsSystemScreenPrivate(QVFbGraphicsSystemScreen *) - : shmrgn(0), hdr(0), data(0), mouseHandler(0), keyboardHandler(0) - { - connect(0); //for now we only handle one screen - } - - ~QVFbGraphicsSystemScreenPrivate() { disconnect(); } - void setDirty(const QRect &r); - - bool connect(int displayId); - void disconnect(); - - QImage *screenImage() { return &img; } - QSize screenSize() { return img.size(); } - - int depth() const { return img.depth(); } - QImage::Format format() const { return img.format(); } - -private: - unsigned char *shmrgn; - QVFbHeader *hdr; - uchar *data; - QVFbGraphicsSystemScreenMouseHandler *mouseHandler; - QVFbGraphicsSystemScreenKeyboardHandler *keyboardHandler; - - - QImage img; -}; - - -void QVFbGraphicsSystemScreenPrivate::setDirty(const QRect &r) -{ - hdr->dirty = true; - hdr->update = hdr->update.united(r); -} - - -bool QVFbGraphicsSystemScreenPrivate::connect(int displayId) -{ - - key_t key = ftok(QT_VFB_MOUSE_PIPE(displayId).toLatin1(), 'b'); - - if (key == -1) - return false; - - - int shmId = shmget(key, 0, 0); - if (shmId != -1) - shmrgn = (unsigned char *)shmat(shmId, 0, 0); - else - return false; - - if ((long)shmrgn == -1 || shmrgn == 0) { - qDebug("No shmrgn %ld", (long)shmrgn); - return false; - } - - hdr = (QVFbHeader *)shmrgn; - data = shmrgn + hdr->dataoffset; - - int w = hdr->width; - int h = hdr->height; - int d = hdr->depth; - int lstep = hdr->linestep; - - QImage::Format format = QImage::Format_Invalid; - if (d == 32) - format = QImage::Format_ARGB32_Premultiplied; - else if (d == 16) - format = QImage::Format_RGB16; - - - if (format == QImage::Format_Invalid) { - img = QImage(); - return false; - } - - img = QImage(data, w, h, lstep, format); - - qDebug("connected %dx%d %d bpp", w, h, d); - - - mouseHandler = new QVFbGraphicsSystemScreenMouseHandler; - keyboardHandler = new QVFbGraphicsSystemScreenKeyboardHandler; - return true; -} - -void QVFbGraphicsSystemScreenPrivate::disconnect() -{ - if ((long)shmrgn != -1 && shmrgn) { - shmdt((char*)shmrgn); - shmrgn = 0; - } - delete mouseHandler; - mouseHandler = 0; - delete keyboardHandler; - keyboardHandler = 0; -} - - -QVFbGraphicsSystemScreen::QVFbGraphicsSystemScreen() -{ - d_ptr = new QVFbGraphicsSystemScreenPrivate(this); -} - - -QVFbGraphicsSystemScreen::~QVFbGraphicsSystemScreen() -{ - delete d_ptr; -} - -void QVFbGraphicsSystemScreen::setDirty(const QRect &rect) -{ - d_ptr->setDirty(rect); -} - - - -QRect QVFbGraphicsSystemScreen::geometry() const { - return QRect(QPoint(), d_ptr->screenSize()); -} - - -int QVFbGraphicsSystemScreen::depth() const -{ - return d_ptr->depth(); -} - -QImage::Format QVFbGraphicsSystemScreen::format() const -{ - return d_ptr->format(); -} - -QSize QVFbGraphicsSystemScreen::physicalSize() const { - return (d_ptr->screenSize()*254)/720; -} - -#if 0 -int QVFbGraphicsSystemScreen::linestep() const { - return d_ptr->screenImage() ? d_ptr->screenImage()->bytesPerLine() : 0; -} - -uchar *QVFbGraphicsSystemScreen::base() const { - return d_ptr->screenImage() ? d_ptr->screenImage()->bits() : 0; -} -#endif - -QImage *QVFbGraphicsSystemScreen::screenImage() -{ - return d_ptr->screenImage(); -} - -QVFbGraphicsSystem::QVFbGraphicsSystem() -{ - mPrimaryScreen = new QVFbGraphicsSystemScreen(); - - mScreens.append(mPrimaryScreen); -} - -QPixmapData *QVFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -QWindowSurface *QVFbGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - if (widget->windowType() == Qt::Desktop) - return 0; // Don't create an explicit window surface for the destkop. - return new QVFbWindowSurface - (const_cast(this), mPrimaryScreen, widget); -} - -QT_END_NAMESPACE - -#include "qgraphicssystem_qvfb.moc" diff --git a/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.h b/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.h deleted file mode 100644 index b31869c..0000000 --- a/src/plugins/graphicssystems/qvfb/qgraphicssystem_qvfb.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_QVFB_H -#define QGRAPHICSSYSTEM_QVFB_H - -#include - -QT_BEGIN_NAMESPACE - - -class QVFbGraphicsSystemScreenPrivate; - -class QVFbGraphicsSystemScreen : public QGraphicsSystemScreen -{ -public: - QVFbGraphicsSystemScreen(); - ~QVFbGraphicsSystemScreen(); - - QRect geometry() const; - int depth() const; - QImage::Format format() const; - QSize physicalSize() const; - - QImage *screenImage(); - - void setDirty(const QRect &rect); - -public: - - QVFbGraphicsSystemScreenPrivate *d_ptr; -}; - -class QVFbGraphicsSystemPrivate; - - -class QVFbGraphicsSystem : public QGraphicsSystem -{ -public: - QVFbGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - - QList screens() const { return mScreens; } - -private: - QVFbGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; -}; - - - -QT_END_NAMESPACE - - -#endif diff --git a/src/plugins/graphicssystems/qvfb/qvfb.pro b/src/plugins/graphicssystems/qvfb/qvfb.pro deleted file mode 100644 index b321725..0000000 --- a/src/plugins/graphicssystems/qvfb/qvfb.pro +++ /dev/null @@ -1,12 +0,0 @@ -TARGET = qvfbgraphicssystem -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - - - -SOURCES = main.cpp qgraphicssystem_qvfb.cpp qwindowsurface_qvfb.cpp -HEADERS = qgraphicssystem_qvfb.h qwindowsurface_qvfb.h - -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -INSTALLS += target diff --git a/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp b/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp deleted file mode 100644 index 0aafe28..0000000 --- a/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qwindowsurface_qvfb.h" -#include "qgraphicssystem_qvfb.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QVFbWindowSurface::QVFbWindowSurface(QVFbGraphicsSystem *graphicsSystem, - QVFbGraphicsSystemScreen *screen, QWidget *window) - : QWindowSurface(window), - mScreen(screen) -{ -} - -QVFbWindowSurface::~QVFbWindowSurface() -{ -} - -QPaintDevice *QVFbWindowSurface::paintDevice() -{ - return mScreen->screenImage(); -} - -void QVFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(offset); - - QRect rect = geometry(); - QPoint topLeft = rect.topLeft(); - - mScreen->setDirty(region.boundingRect()); -} - -void QVFbWindowSurface::setGeometry(const QRect &) -{ - -// any size you like as long as it's full-screen... - - QRect rect(mScreen->availableGeometry()); - QWindowSystemInterface::handleGeometryChange(this->window(), rect); - - QWindowSurface::setGeometry(rect); -} - -bool QVFbWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - return QWindowSurface::scroll(area, dx, dy); -} - -void QVFbWindowSurface::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -void QVFbWindowSurface::endPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.h b/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.h deleted file mode 100644 index 1971caa..0000000 --- a/src/plugins/graphicssystems/qvfb/qwindowsurface_qvfb.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_QVFB_H -#define QWINDOWSURFACE_QVFB_H - -#include - -QT_BEGIN_NAMESPACE - -class QVFbGraphicsSystem; -class QVFbGraphicsSystemScreen; - -class QVFbWindowSurface : public QWindowSurface -{ -public: - QVFbWindowSurface(QVFbGraphicsSystem *graphicsSystem, - QVFbGraphicsSystemScreen *screen, QWidget *window); - ~QVFbWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - -private: - QVFbGraphicsSystem *mGraphicsSystem; - QVFbGraphicsSystemScreen *mScreen; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/testlite/main.cpp b/src/plugins/graphicssystems/testlite/main.cpp deleted file mode 100644 index 28caea7..0000000 --- a/src/plugins/graphicssystems/testlite/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qgraphicssystem_testlite.h" - -QT_BEGIN_NAMESPACE - -class QTestLiteGraphicsSystemPlugin : public QGraphicsSystemPlugin -{ -public: - QStringList keys() const; - QGraphicsSystem *create(const QString&); -}; - -QStringList QTestLiteGraphicsSystemPlugin::keys() const -{ - QStringList list; - list << "TestLite"; - return list; -} - -QGraphicsSystem* QTestLiteGraphicsSystemPlugin::create(const QString& system) -{ - if (system.toLower() == "testlite") - return new QTestLiteGraphicsSystem; - - return 0; -} - -Q_EXPORT_PLUGIN2(testlite, QTestLiteGraphicsSystemPlugin) - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp deleted file mode 100644 index 92e0ebc..0000000 --- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_testlite.h" -#include "qwindowsurface_testlite.h" -#include -#include - -#include - - -#include "x11util.h" - -QT_BEGIN_NAMESPACE - -class MyCursor : QGraphicsSystemCursor -{ -public: - MyCursor(QGraphicsSystemScreen *screen) : QGraphicsSystemCursor(screen) {} - - void changeCursor(QCursor * cursor, QWidget * widget) { - QTestLiteWindowSurface *ws = 0; - if (widget) { - QWidget *window = widget->window(); - ws = static_cast(window->windowSurface()); - } else { - // No X11 cursor control when there is no widget under the cursor - return; - } - - //qDebug() << "changeCursor" << widget << ws; - if (!ws) - return; - - ws->setCursor(cursor); - } -}; - - -QTestLiteGraphicsSystem::QTestLiteGraphicsSystem() -{ - - xd = new MyDisplay; - - mPrimaryScreen = new QTestLiteGraphicsSystemScreen(); - - mPrimaryScreen->mGeometry = QRect - (0, 0, xd->width, xd->height); - mPrimaryScreen->mDepth = 32; - mPrimaryScreen->mFormat = QImage::Format_RGB32; - mPrimaryScreen->mPhysicalSize = - QSize(xd->physicalWidth, xd->physicalHeight); - - mScreens.append(mPrimaryScreen); - - - (void)new MyCursor(mPrimaryScreen); - -} - -QPixmapData *QTestLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -QWindowSurface *QTestLiteGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - if (widget->windowType() == Qt::Desktop) - return 0; // Don't create an explicit window surface for the destkop. - return new QTestLiteWindowSurface - (const_cast(this), mPrimaryScreen, widget); -} - - -QPixmap QTestLiteGraphicsSystem::grabWindow(WId window, int x, int y, int width, int height) const -{ - QImage img = xd->grabWindow(window, x, y, width, height); - return QPixmap::fromImage(img); -} - - - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h b/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h deleted file mode 100644 index b2cd496..0000000 --- a/src/plugins/graphicssystems/testlite/qgraphicssystem_testlite.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_TESTLITE_H -#define QGRAPHICSSYSTEM_TESTLITE_H - -#include - -QT_BEGIN_NAMESPACE - -class MyDisplay; - -class QTestLiteGraphicsSystemScreen : public QGraphicsSystemScreen -{ -public: - QTestLiteGraphicsSystemScreen() - : mDepth(16), mFormat(QImage::Format_RGB16) {} - ~QTestLiteGraphicsSystemScreen() {} - - QRect geometry() const { return mGeometry; } - int depth() const { return mDepth; } - QImage::Format format() const { return mFormat; } - QSize physicalSize() const { return mPhysicalSize; } - -public: - QRect mGeometry; - int mDepth; - QImage::Format mFormat; - QSize mPhysicalSize; -}; - -class QTestLiteGraphicsSystem : public QGraphicsSystem -{ -public: - QTestLiteGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - - QPixmap grabWindow(WId window, int x, int y, int width, int height) const; - - QList screens() const { return mScreens; } - - MyDisplay *xd; - -private: - QTestLiteGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp deleted file mode 100644 index c54f6eb..0000000 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp +++ /dev/null @@ -1,661 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindowsurface_testlite.h" -#include "qgraphicssystem_testlite.h" - -#include -#include - -#include "x11util.h" - -QT_BEGIN_NAMESPACE - -QTestLiteWindowSurface::QTestLiteWindowSurface - (QTestLiteGraphicsSystem *graphicsSystem, - QTestLiteGraphicsSystemScreen *screen, QWidget *window) - : QWindowSurface(window), - mGraphicsSystem(graphicsSystem), - mScreen(screen), - xw(0) -{ - - - xw = new MyWindow(graphicsSystem->xd, 0,0,300,300); - xw->windowSurface = this; - -// qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window; - - setWindowFlags(window->windowFlags()); //##### This should not be the plugin's responsibility -} - -QTestLiteWindowSurface::~QTestLiteWindowSurface() -{ -// qDebug() << "~QTestLiteWindowSurface" << xw->window; - delete xw; -} - -QPaintDevice *QTestLiteWindowSurface::paintDevice() -{ - return xw->image(); -} - -void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(region); - Q_UNUSED(offset); - - // qDebug() << "QTestLiteWindowSurface::flush:" << (long)this; - - xw->paintEvent(); -} - - -void QTestLiteWindowSurface::setGeometry(const QRect &rect) -{ - QRect oldRect = geometry(); - if (rect == oldRect) - return; - - QWindowSurface::setGeometry(rect); - - //if unchanged ### -// xw->setSize(rect.width(), rect.height()); - xw->setGeometry(rect.x(), rect.y(), rect.width(), rect.height()); -} - -//### scroll logic copied from QRasterWindowSurface, we should make better API for this - -void copied_qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) -{ - // make sure we don't detach - uchar *mem = const_cast(const_cast(img).bits()); - - int lineskip = img.bytesPerLine(); - int depth = img.depth() >> 3; - - const QRect imageRect(0, 0, img.width(), img.height()); - const QRect r = rect & imageRect & imageRect.translated(-offset); - const QPoint p = rect.topLeft() + offset; - - if (r.isEmpty()) - return; - - const uchar *src; - uchar *dest; - - if (r.top() < p.y()) { - src = mem + r.bottom() * lineskip + r.left() * depth; - dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth; - lineskip = -lineskip; - } else { - src = mem + r.top() * lineskip + r.left() * depth; - dest = mem + p.y() * lineskip + p.x() * depth; - } - - const int w = r.width(); - int h = r.height(); - const int bytes = w * depth; - - // overlapping segments? - if (offset.y() == 0 && qAbs(offset.x()) < w) { - do { - ::memmove(dest, src, bytes); - dest += lineskip; - src += lineskip; - } while (--h); - } else { - do { - ::memcpy(dest, src, bytes); - dest += lineskip; - src += lineskip; - } while (--h); - } -} - -bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - if (!xw->image() || xw->image()->isNull()) - return false; - - const QVector rects = area.rects(); - for (int i = 0; i < rects.size(); ++i) - copied_qt_scrollRectInImage(*xw->image(), rects.at(i), QPoint(dx, dy)); - - return true; -} - - -void QTestLiteWindowSurface::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); - xw->resizeBuffer(geometry().size()); -} - -void QTestLiteWindowSurface::endPaint(const QRegion ®ion) -{ - Q_UNUSED(region); - xw->painted = true; //there is content in the buffer -} - - - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Mouse event stuff - - - - -static Qt::MouseButtons translateMouseButtons(int s) -{ - Qt::MouseButtons ret = 0; - if (s & Button1Mask) - ret |= Qt::LeftButton; - if (s & Button2Mask) - ret |= Qt::MidButton; - if (s & Button3Mask) - ret |= Qt::RightButton; - return ret; -} - - -static Qt::KeyboardModifiers translateModifiers(int s) -{ - const uchar qt_alt_mask = Mod1Mask; - const uchar qt_meta_mask = Mod4Mask; - - - Qt::KeyboardModifiers ret = 0; - if (s & ShiftMask) - ret |= Qt::ShiftModifier; - if (s & ControlMask) - ret |= Qt::ControlModifier; - if (s & qt_alt_mask) - ret |= Qt::AltModifier; - if (s & qt_meta_mask) - ret |= Qt::MetaModifier; -#if 0 - if (s & qt_mode_switch_mask) - ret |= Qt::GroupSwitchModifier; -#endif - return ret; -} - -void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) -{ - static QPoint mousePoint; - - XButtonEvent *e = static_cast(ev); - - Qt::MouseButton button = Qt::NoButton; - Qt::MouseButtons buttons = translateMouseButtons(e->state); - Qt::KeyboardModifiers modifiers = translateModifiers(e->state); - if (type != QEvent::MouseMove) { - switch (e->button) { - case Button1: button = Qt::LeftButton; break; - case Button2: button = Qt::MidButton; break; - case Button3: button = Qt::RightButton; break; - case Button4: - case Button5: - case 6: - case 7: { - //mouse wheel - if (type == QEvent::MouseButtonPress) { - //logic borrowed from qapplication_x11.cpp - int delta = 120 * ((e->button == Button4 || e->button == 6) ? 1 : -1); - bool hor = (((e->button == Button4 || e->button == Button5) - && (modifiers & Qt::AltModifier)) - || (e->button == 6 || e->button == 7)); - QWindowSystemInterface::handleWheelEvent(window(), e->time, - QPoint(e->x, e->y), - QPoint(e->x_root, e->y_root), - delta, hor ? Qt::Horizontal : Qt::Vertical); - } - return; - } - default: break; - } - } - - buttons ^= button; // X event uses state *before*, Qt uses state *after* - - QWindowSystemInterface::handleMouseEvent(window(), e->time, QPoint(e->x, e->y), - QPoint(e->x_root, e->y_root), - buttons); - - mousePoint = QPoint(e->x_root, e->y_root); -} - -void QTestLiteWindowSurface::handleGeometryChange(int x, int y, int w, int h) -{ - QWindowSystemInterface::handleGeometryChange(window(), QRect(x,y,w,h)); -} - - -void QTestLiteWindowSurface::handleCloseEvent() -{ - QWindowSystemInterface::handleCloseEvent(window()); -} - - -void QTestLiteWindowSurface::handleEnterEvent() -{ - QWindowSystemInterface::handleEnterEvent(window()); -} - -void QTestLiteWindowSurface::handleLeaveEvent() -{ - QWindowSystemInterface::handleLeaveEvent(window()); -} - - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Key event stuff -- not pretty either -// -// What we want to do is to port Robert's keytable code properly - - - - - - - -// keyboard mapping table -static const unsigned int keyTbl[] = { - - // misc keys - - XK_Escape, Qt::Key_Escape, - XK_Tab, Qt::Key_Tab, - XK_ISO_Left_Tab, Qt::Key_Backtab, - XK_BackSpace, Qt::Key_Backspace, - XK_Return, Qt::Key_Return, - XK_Insert, Qt::Key_Insert, - XK_Delete, Qt::Key_Delete, - XK_Clear, Qt::Key_Delete, - XK_Pause, Qt::Key_Pause, - XK_Print, Qt::Key_Print, - 0x1005FF60, Qt::Key_SysReq, // hardcoded Sun SysReq - 0x1007ff00, Qt::Key_SysReq, // hardcoded X386 SysReq - - // cursor movement - - XK_Home, Qt::Key_Home, - XK_End, Qt::Key_End, - XK_Left, Qt::Key_Left, - XK_Up, Qt::Key_Up, - XK_Right, Qt::Key_Right, - XK_Down, Qt::Key_Down, - XK_Prior, Qt::Key_PageUp, - XK_Next, Qt::Key_PageDown, - - // modifiers - - XK_Shift_L, Qt::Key_Shift, - XK_Shift_R, Qt::Key_Shift, - XK_Shift_Lock, Qt::Key_Shift, - XK_Control_L, Qt::Key_Control, - XK_Control_R, Qt::Key_Control, - XK_Meta_L, Qt::Key_Meta, - XK_Meta_R, Qt::Key_Meta, - XK_Alt_L, Qt::Key_Alt, - XK_Alt_R, Qt::Key_Alt, - XK_Caps_Lock, Qt::Key_CapsLock, - XK_Num_Lock, Qt::Key_NumLock, - XK_Scroll_Lock, Qt::Key_ScrollLock, - XK_Super_L, Qt::Key_Super_L, - XK_Super_R, Qt::Key_Super_R, - XK_Menu, Qt::Key_Menu, - XK_Hyper_L, Qt::Key_Hyper_L, - XK_Hyper_R, Qt::Key_Hyper_R, - XK_Help, Qt::Key_Help, - 0x1000FF74, Qt::Key_Backtab, // hardcoded HP backtab - 0x1005FF10, Qt::Key_F11, // hardcoded Sun F36 (labeled F11) - 0x1005FF11, Qt::Key_F12, // hardcoded Sun F37 (labeled F12) - - // numeric and function keypad keys - - XK_KP_Space, Qt::Key_Space, - XK_KP_Tab, Qt::Key_Tab, - XK_KP_Enter, Qt::Key_Enter, - //XK_KP_F1, Qt::Key_F1, - //XK_KP_F2, Qt::Key_F2, - //XK_KP_F3, Qt::Key_F3, - //XK_KP_F4, Qt::Key_F4, - XK_KP_Home, Qt::Key_Home, - XK_KP_Left, Qt::Key_Left, - XK_KP_Up, Qt::Key_Up, - XK_KP_Right, Qt::Key_Right, - XK_KP_Down, Qt::Key_Down, - XK_KP_Prior, Qt::Key_PageUp, - XK_KP_Next, Qt::Key_PageDown, - XK_KP_End, Qt::Key_End, - XK_KP_Begin, Qt::Key_Clear, - XK_KP_Insert, Qt::Key_Insert, - XK_KP_Delete, Qt::Key_Delete, - XK_KP_Equal, Qt::Key_Equal, - XK_KP_Multiply, Qt::Key_Asterisk, - XK_KP_Add, Qt::Key_Plus, - XK_KP_Separator, Qt::Key_Comma, - XK_KP_Subtract, Qt::Key_Minus, - XK_KP_Decimal, Qt::Key_Period, - XK_KP_Divide, Qt::Key_Slash, - - // International input method support keys - - // International & multi-key character composition - XK_ISO_Level3_Shift, Qt::Key_AltGr, - XK_Multi_key, Qt::Key_Multi_key, - XK_Codeinput, Qt::Key_Codeinput, - XK_SingleCandidate, Qt::Key_SingleCandidate, - XK_MultipleCandidate, Qt::Key_MultipleCandidate, - XK_PreviousCandidate, Qt::Key_PreviousCandidate, - - // Misc Functions - XK_Mode_switch, Qt::Key_Mode_switch, - XK_script_switch, Qt::Key_Mode_switch, - - // Japanese keyboard support - XK_Kanji, Qt::Key_Kanji, - XK_Muhenkan, Qt::Key_Muhenkan, - //XK_Henkan_Mode, Qt::Key_Henkan_Mode, - XK_Henkan_Mode, Qt::Key_Henkan, - XK_Henkan, Qt::Key_Henkan, - XK_Romaji, Qt::Key_Romaji, - XK_Hiragana, Qt::Key_Hiragana, - XK_Katakana, Qt::Key_Katakana, - XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana, - XK_Zenkaku, Qt::Key_Zenkaku, - XK_Hankaku, Qt::Key_Hankaku, - XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku, - XK_Touroku, Qt::Key_Touroku, - XK_Massyo, Qt::Key_Massyo, - XK_Kana_Lock, Qt::Key_Kana_Lock, - XK_Kana_Shift, Qt::Key_Kana_Shift, - XK_Eisu_Shift, Qt::Key_Eisu_Shift, - XK_Eisu_toggle, Qt::Key_Eisu_toggle, - //XK_Kanji_Bangou, Qt::Key_Kanji_Bangou, - //XK_Zen_Koho, Qt::Key_Zen_Koho, - //XK_Mae_Koho, Qt::Key_Mae_Koho, - XK_Kanji_Bangou, Qt::Key_Codeinput, - XK_Zen_Koho, Qt::Key_MultipleCandidate, - XK_Mae_Koho, Qt::Key_PreviousCandidate, - -#ifdef XK_KOREAN - // Korean keyboard support - XK_Hangul, Qt::Key_Hangul, - XK_Hangul_Start, Qt::Key_Hangul_Start, - XK_Hangul_End, Qt::Key_Hangul_End, - XK_Hangul_Hanja, Qt::Key_Hangul_Hanja, - XK_Hangul_Jamo, Qt::Key_Hangul_Jamo, - XK_Hangul_Romaja, Qt::Key_Hangul_Romaja, - //XK_Hangul_Codeinput, Qt::Key_Hangul_Codeinput, - XK_Hangul_Codeinput, Qt::Key_Codeinput, - XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja, - XK_Hangul_Banja, Qt::Key_Hangul_Banja, - XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja, - XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja, - //XK_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate, - //XK_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate, - //XK_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate, - XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate, - XK_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate, - XK_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate, - XK_Hangul_Special, Qt::Key_Hangul_Special, - //XK_Hangul_switch, Qt::Key_Hangul_switch, - XK_Hangul_switch, Qt::Key_Mode_switch, -#endif // XK_KOREAN - - // dead keys - XK_dead_grave, Qt::Key_Dead_Grave, - XK_dead_acute, Qt::Key_Dead_Acute, - XK_dead_circumflex, Qt::Key_Dead_Circumflex, - XK_dead_tilde, Qt::Key_Dead_Tilde, - XK_dead_macron, Qt::Key_Dead_Macron, - XK_dead_breve, Qt::Key_Dead_Breve, - XK_dead_abovedot, Qt::Key_Dead_Abovedot, - XK_dead_diaeresis, Qt::Key_Dead_Diaeresis, - XK_dead_abovering, Qt::Key_Dead_Abovering, - XK_dead_doubleacute, Qt::Key_Dead_Doubleacute, - XK_dead_caron, Qt::Key_Dead_Caron, - XK_dead_cedilla, Qt::Key_Dead_Cedilla, - XK_dead_ogonek, Qt::Key_Dead_Ogonek, - XK_dead_iota, Qt::Key_Dead_Iota, - XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound, - XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound, - XK_dead_belowdot, Qt::Key_Dead_Belowdot, - XK_dead_hook, Qt::Key_Dead_Hook, - XK_dead_horn, Qt::Key_Dead_Horn, - -#if 0 - // Special multimedia keys - // currently only tested with MS internet keyboard - - // browsing keys - XF86XK_Back, Qt::Key_Back, - XF86XK_Forward, Qt::Key_Forward, - XF86XK_Stop, Qt::Key_Stop, - XF86XK_Refresh, Qt::Key_Refresh, - XF86XK_Favorites, Qt::Key_Favorites, - XF86XK_AudioMedia, Qt::Key_LaunchMedia, - XF86XK_OpenURL, Qt::Key_OpenUrl, - XF86XK_HomePage, Qt::Key_HomePage, - XF86XK_Search, Qt::Key_Search, - - // media keys - XF86XK_AudioLowerVolume, Qt::Key_VolumeDown, - XF86XK_AudioMute, Qt::Key_VolumeMute, - XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp, - XF86XK_AudioPlay, Qt::Key_MediaPlay, - XF86XK_AudioStop, Qt::Key_MediaStop, - XF86XK_AudioPrev, Qt::Key_MediaPrevious, - XF86XK_AudioNext, Qt::Key_MediaNext, - XF86XK_AudioRecord, Qt::Key_MediaRecord, - - // launch keys - XF86XK_Mail, Qt::Key_LaunchMail, - XF86XK_MyComputer, Qt::Key_Launch0, - XF86XK_Calculator, Qt::Key_Launch1, - XF86XK_Standby, Qt::Key_Standby, - - XF86XK_Launch0, Qt::Key_Launch2, - XF86XK_Launch1, Qt::Key_Launch3, - XF86XK_Launch2, Qt::Key_Launch4, - XF86XK_Launch3, Qt::Key_Launch5, - XF86XK_Launch4, Qt::Key_Launch6, - XF86XK_Launch5, Qt::Key_Launch7, - XF86XK_Launch6, Qt::Key_Launch8, - XF86XK_Launch7, Qt::Key_Launch9, - XF86XK_Launch8, Qt::Key_LaunchA, - XF86XK_Launch9, Qt::Key_LaunchB, - XF86XK_LaunchA, Qt::Key_LaunchC, - XF86XK_LaunchB, Qt::Key_LaunchD, - XF86XK_LaunchC, Qt::Key_LaunchE, - XF86XK_LaunchD, Qt::Key_LaunchF, -#endif - -#if 0 - // Qtopia keys - QTOPIAXK_Select, Qt::Key_Select, - QTOPIAXK_Yes, Qt::Key_Yes, - QTOPIAXK_No, Qt::Key_No, - QTOPIAXK_Cancel, Qt::Key_Cancel, - QTOPIAXK_Printer, Qt::Key_Printer, - QTOPIAXK_Execute, Qt::Key_Execute, - QTOPIAXK_Sleep, Qt::Key_Sleep, - QTOPIAXK_Play, Qt::Key_Play, - QTOPIAXK_Zoom, Qt::Key_Zoom, - QTOPIAXK_Context1, Qt::Key_Context1, - QTOPIAXK_Context2, Qt::Key_Context2, - QTOPIAXK_Context3, Qt::Key_Context3, - QTOPIAXK_Context4, Qt::Key_Context4, - QTOPIAXK_Call, Qt::Key_Call, - QTOPIAXK_Hangup, Qt::Key_Hangup, - QTOPIAXK_Flip, Qt::Key_Flip, -#endif - 0, 0 -}; - - -static int lookupCode(unsigned int xkeycode) -{ - if (xkeycode >= XK_F1 && xkeycode <= XK_F35) - return Qt::Key_F1 + (int(xkeycode) - XK_F1); - - const unsigned int *p = keyTbl; - while (*p) { - if (*p == xkeycode) - return *++p; - p += 2; - } - - return 0; -} - - -static Qt::KeyboardModifiers modifierFromKeyCode(int qtcode) -{ - switch (qtcode) { - case Qt::Key_Control: - return Qt::ControlModifier; - case Qt::Key_Alt: - return Qt::AltModifier; - case Qt::Key_Shift: - return Qt::ShiftModifier; - case Qt::Key_Meta: - return Qt::MetaModifier; - default: - return Qt::NoModifier; - } -} - -void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) -{ - XKeyEvent *e = static_cast(ev); - - KeySym keySym; - QByteArray chars; - chars.resize(513); - - int count = XLookupString(e, chars.data(), chars.size(), &keySym, 0); - -// qDebug() << "QTLWS::handleKeyEvent" << count << hex << "XKeysym:" << keySym; -// if (count) -// qDebug() << hex << int(chars[0]) << "String:" << chars; - - Qt::KeyboardModifiers modifiers = translateModifiers(e->state); - - int qtcode = lookupCode(keySym); -// qDebug() << "lookup: " << hex << keySym << qtcode << "mod" << modifiers; - - //X11 specifies state *before*, Qt expects state *after* the event - - modifiers ^= modifierFromKeyCode(qtcode); - - if (qtcode) { - QWindowSystemInterface::handleKeyEvent(window(), e->time, type, qtcode, modifiers); - } else if (chars[0]) { - int qtcode = chars.toUpper()[0]; //Not exactly right... - if (modifiers & Qt::ControlModifier && qtcode < ' ') - qtcode = chars[0] + '@'; - QWindowSystemInterface::handleKeyEvent(window(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars)); - } else { - qWarning() << "unknown X keycode" << hex << e->keycode << keySym; - } -} - - - -Qt::WindowFlags QTestLiteWindowSurface::setWindowFlags(Qt::WindowFlags flags) -{ - Q_ASSERT(flags & Qt::Window); - - window_flags = flags; - - xw->setWindowFlags(flags); - - return window_flags; - -} - -Qt::WindowFlags QTestLiteWindowSurface::windowFlags() const -{ - return window_flags; -} - -void QTestLiteWindowSurface::setVisible(bool visible) -{ - //qDebug() << "QTestLiteWindowSurface::setVisible" << visible << xw->window; - xw->setVisible(visible); -} - - -WId QTestLiteWindowSurface::winId() const -{ - if (xw) - return (WId) xw->window; - else - return WId(0); -} - -void QTestLiteWindowSurface::raise() -{ - WId window = winId(); - XRaiseWindow(mGraphicsSystem->xd->display, window); -} - -void QTestLiteWindowSurface::lower() -{ - WId window = winId(); - XLowerWindow(mGraphicsSystem->xd->display, window); -} - -void QTestLiteWindowSurface::setWindowTitle(const QString &title) -{ - xw->setWindowTitle(title); -} - -void QTestLiteWindowSurface::setCursor(QCursor *cursor) -{ - xw->setCursor(cursor); -} -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h deleted file mode 100644 index 0c4df1a..0000000 --- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_TESTLITE_H -#define QWINDOWSURFACE_TESTLITE_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class MyWindow; -class QTestLiteGraphicsSystem; -class QTestLiteGraphicsSystemScreen; - -class QTestLiteWindowSurface : public QWindowSurface -{ -public: - QTestLiteWindowSurface - (QTestLiteGraphicsSystem *graphicsSystem, - QTestLiteGraphicsSystemScreen *screen, QWidget *window); - ~QTestLiteWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - - void handleMouseEvent(QEvent::Type, void *); //forwarding X types is apparently impossible :( - void handleKeyEvent(QEvent::Type, void *); - void handleGeometryChange(int x, int y, int w, int h); - void handleCloseEvent(); - void handleEnterEvent(); - void handleLeaveEvent(); - - Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); - Qt::WindowFlags windowFlags() const; - void setVisible(bool visible); - WId winId() const; - void raise(); - void lower(); - void setWindowTitle(const QString &title); - - void setCursor(QCursor * cursor); - -private: - QTestLiteGraphicsSystem *mGraphicsSystem; - QTestLiteGraphicsSystemScreen *mScreen; - Qt::WindowFlags window_flags; - MyWindow *xw; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/graphicssystems/testlite/testlite.pro b/src/plugins/graphicssystems/testlite/testlite.pro deleted file mode 100644 index d483f45..0000000 --- a/src/plugins/graphicssystems/testlite/testlite.pro +++ /dev/null @@ -1,17 +0,0 @@ -TARGET = qtestlitegraphicssystem -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - -SOURCES = main.cpp qgraphicssystem_testlite.cpp qwindowsurface_testlite.cpp -HEADERS = qgraphicssystem_testlite.h qwindowsurface_testlite.h - - -HEADERS += x11util.h -SOURCES += x11util.cpp - -LIBS += -lX11 -lXext - - -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -INSTALLS += target diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp deleted file mode 100644 index 6d2966f..0000000 --- a/src/plugins/graphicssystems/testlite/x11util.cpp +++ /dev/null @@ -1,1215 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include -#include -#include - -#include "x11util.h" -#include "qwindowsurface_testlite.h" - -#include -#include - - -#include - -#include - -# include -# include -# include - - -#include -#include -#include -#include - -//### remove stuff we don't want from qt_x11_p.h -#undef ATOM -#undef X11 - -//#define MYX11_DEBUG - -//#define DONT_USE_MIT_SHM - -static int (*original_x_errhandler)(Display *dpy, XErrorEvent *); -static bool seen_badwindow; - - -static Atom wmProtocolsAtom; -static Atom wmDeleteWindowAtom; - -//### copied from qapplication_x11.cpp - -static int qt_x_errhandler(Display *dpy, XErrorEvent *err) -{ - -qDebug() << "qt_x_errhandler" << err->error_code; - - switch (err->error_code) { - case BadAtom: -#if 0 - if (err->request_code == 20 /* X_GetProperty */ - && (err->resourceid == XA_RESOURCE_MANAGER - || err->resourceid == XA_RGB_DEFAULT_MAP - || err->resourceid == ATOM(_NET_SUPPORTED) - || err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK) - || err->resourceid == ATOM(KDE_FULL_SESSION) - || err->resourceid == ATOM(KWIN_RUNNING) - || err->resourceid == ATOM(XdndProxy) - || err->resourceid == ATOM(XdndAware)) - - - ) { - // Perhaps we're running under SECURITY reduction? :/ - return 0; - } -#endif - qDebug() << "BadAtom"; - break; - - case BadWindow: - if (err->request_code == 2 /* X_ChangeWindowAttributes */ - || err->request_code == 38 /* X_QueryPointer */) { - for (int i = 0; i < ScreenCount(dpy); ++i) { - if (err->resourceid == RootWindow(dpy, i)) { - // Perhaps we're running under SECURITY reduction? :/ - return 0; - } - } - } - seen_badwindow = true; - if (err->request_code == 25 /* X_SendEvent */) { - for (int i = 0; i < ScreenCount(dpy); ++i) { - if (err->resourceid == RootWindow(dpy, i)) { - // Perhaps we're running under SECURITY reduction? :/ - return 0; - } - } -#if 0 - if (X11->xdndHandleBadwindow()) { - qDebug("xdndHandleBadwindow returned true"); - return 0; - } -#endif - } -#if 0 - if (X11->ignore_badwindow) - return 0; -#endif - break; - - case BadMatch: - if (err->request_code == 42 /* X_SetInputFocus */) - return 0; - break; - - default: -#if 0 //!defined(QT_NO_XINPUT) - if (err->request_code == X11->xinput_major - && err->error_code == (X11->xinput_errorbase + XI_BadDevice) - && err->minor_code == 3 /* X_OpenDevice */) { - return 0; - } -#endif - break; - } - - char errstr[256]; - XGetErrorText( dpy, err->error_code, errstr, 256 ); - char buffer[256]; - char request_str[256]; - qsnprintf(buffer, 256, "%d", err->request_code); - XGetErrorDatabaseText(dpy, "XRequest", buffer, "", request_str, 256); - if (err->request_code < 128) { - // X error for a normal protocol request - qWarning( "X Error: %s %d\n" - " Major opcode: %d (%s)\n" - " Resource id: 0x%lx", - errstr, err->error_code, - err->request_code, - request_str, - err->resourceid ); - } else { - // X error for an extension request - const char *extensionName = 0; -#if 0 - if (err->request_code == X11->xrender_major) - extensionName = "RENDER"; - else if (err->request_code == X11->xrandr_major) - extensionName = "RANDR"; - else if (err->request_code == X11->xinput_major) - extensionName = "XInputExtension"; - else if (err->request_code == X11->mitshm_major) - extensionName = "MIT-SHM"; -#endif - char minor_str[256]; - if (extensionName) { - qsnprintf(buffer, 256, "%s.%d", extensionName, err->minor_code); - XGetErrorDatabaseText(dpy, "XRequest", buffer, "", minor_str, 256); - } else { - extensionName = "Uknown extension"; - qsnprintf(minor_str, 256, "Unknown request"); - } - qWarning( "X Error: %s %d\n" - " Extension: %d (%s)\n" - " Minor opcode: %d (%s)\n" - " Resource id: 0x%lx", - errstr, err->error_code, - err->request_code, - extensionName, - err->minor_code, - minor_str, - err->resourceid ); - } - - // ### we really should distinguish between severe, non-severe and - // ### application specific errors - - return 0; -} - - - - - - - - - -bool MyDisplay::handleEvent(XEvent *xe) -{ - //qDebug() << "handleEvent" << xe->xany.type << xe->xany.window; - int quit = false; - MyWindow *xw = 0; - foreach (MyWindow *w, windowList) { - if (w->window == xe->xany.window) { - xw = w; - break; - } - } - if (!xw) { -#ifdef MYX11_DEBUG - qWarning() << "Unknown window" << hex << xe->xany.window << "received event" << xe->type; -#endif - return quit; - } - - switch (xe->type) { - - case ClientMessage: - if (xe->xclient.format == 32 && xe->xclient.message_type == wmProtocolsAtom) { - Atom a = xe->xclient.data.l[0]; - if (a == wmDeleteWindowAtom) - xw->closeEvent(); -#ifdef MYX11_DEBUG - qDebug() << "ClientMessage WM_PROTOCOLS" << a; -#endif - } -#ifdef MYX11_DEBUG - else - qDebug() << "ClientMessage" << xe->xclient.format << xe->xclient.message_type; -#endif - break; - - case Expose: - if (xw) - if (xe->xexpose.count == 0) - xw->paintEvent(); - break; - case ConfigureNotify: - if (xw) - xw->resizeEvent(&xe->xconfigure); - break; - - case ButtonPress: - xw->mousePressEvent(&xe->xbutton); - break; - - case ButtonRelease: - xw->mouseReleaseEvent(&xe->xbutton); - break; - - case MotionNotify: - xw->mouseMoveEvent(&xe->xbutton); - break; - - case XKeyPress: - xw->keyPressEvent(&xe->xkey); - break; - - case XKeyRelease: - xw->keyReleaseEvent(&xe->xkey); - break; - - case EnterNotify: - xw->enterEvent(&xe->xcrossing); - break; - - case LeaveNotify: - xw->leaveEvent(&xe->xcrossing); - break; - - default: -#ifdef MYX11_DEBUG - qDebug() << hex << xe->xany.window << "Other X event" << xe->type; -#endif - break; - } - return quit; -}; - - - -MyDisplay::MyDisplay() -{ - char *display_name = getenv("DISPLAY"); - display = XOpenDisplay(display_name); - if (!display) { - fprintf(stderr, "Cannot connect to X server: %s\n", - display_name); - exit(1); - } - -#ifndef DONT_USE_MIT_SHM - Status MIT_SHM_extension_supported = XShmQueryExtension (display); - Q_ASSERT(MIT_SHM_extension_supported == True); -#endif - original_x_errhandler = XSetErrorHandler(qt_x_errhandler); - - if (qgetenv("DO_X_SYNCHRONIZE").toInt()) - XSynchronize(display, true); - - screen = DefaultScreen(display); - width = DisplayWidth(display, screen); - height = DisplayHeight(display, screen); - physicalWidth = DisplayWidthMM(display, screen); - physicalHeight = DisplayHeightMM(display, screen); - - int xSocketNumber = XConnectionNumber(display); -#ifdef MYX11_DEBUG - qDebug() << "X socket:"<< xSocketNumber; -#endif - QSocketNotifier *sock = new QSocketNotifier(xSocketNumber, QSocketNotifier::Read, this); - connect(sock, SIGNAL(activated(int)), this, SLOT(eventDispatcher())); - - wmProtocolsAtom = XInternAtom (display, "WM_PROTOCOLS", False); - wmDeleteWindowAtom = XInternAtom (display, "WM_DELETE_WINDOW", False); - - cursors = new MyX11Cursors(display); -} - - -MyDisplay::~MyDisplay() -{ - XCloseDisplay(display); -} - - -void MyDisplay::eventDispatcher() -{ -// qDebug() << "eventDispatcher"; - - - ulong marker = XNextRequest(display); -// int i = 0; - while (XPending(display)) { - XEvent event; - XNextEvent(display, &event); - /* done = */ - handleEvent(&event); - - if (event.xany.serial >= marker) { -#ifdef MYX11_DEBUG - qDebug() << "potential livelock averted"; -#endif -#if 0 - if (XEventsQueued(display, QueuedAfterFlush)) { - qDebug() << " with events queued"; - QTimer::singleShot(0, this, SLOT(eventDispatcher())); - } -#endif - break; - } - } -} - - -QImage MyDisplay::grabWindow(Window window, int x, int y, int w, int h) -{ - if (w == 0 || h ==0) - return QImage(); - - //WinId 0 means the desktop widget - if (!window) - window = rootWindow(); - - XWindowAttributes window_attr; - if (!XGetWindowAttributes(display, window, &window_attr)) - return QImage(); - - if (w < 0) - w = window_attr.width - x; - if (h < 0) - h = window_attr.height - y; - - // Ideally, we should also limit ourselves to the screen area, but the Qt docs say - // that it's "unsafe" to go outside the screen, so we can ignore that problem. - - //We're definitely not optimizing for speed... - XImage *xi = XGetImage(display, window, x, y, w, h, AllPlanes, ZPixmap); - - if (!xi) - return QImage(); - - //taking a copy to make sure we have ownership -- not fast - QImage result = QImage( (uchar*) xi->data, xi->width, xi->height, xi->bytes_per_line, QImage::Format_RGB32 ).copy(); - - XDestroyImage(xi); - - return result; -} - - - - -struct MyShmImageInfo { - MyShmImageInfo(Display *xdisplay) : image(0), display(xdisplay) {} - ~MyShmImageInfo() { destroy(); } - - void destroy(); - - XShmSegmentInfo shminfo; - XImage *image; - Display *display; -}; - -MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) -{ - xd = display; - - xd->windowList.append(this); - - window = XCreateSimpleWindow(xd->display, xd->rootWindow(), - x, y, w, h, 0 /*border_width*/, - xd->blackPixel(), xd->whitePixel()); - - -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::MyWindow" << hex << window; -#endif - - - width = -1; - height = -1; - xpos = -1; - ypos = -1; - - XSetWindowBackgroundPixmap(xd->display, window, XNone); - - XSelectInput(xd->display, window, ExposureMask | KeyPressMask | KeyReleaseMask | - EnterWindowMask | LeaveWindowMask | FocusChangeMask | - PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | - StructureNotifyMask); - - gc = createGC(); - - XChangeProperty (xd->display, window, - wmProtocolsAtom, - XA_ATOM, 32, PropModeAppend, - (unsigned char *) &wmDeleteWindowAtom, 1); - - - setWindowTitle(QLatin1String("Qt Lighthouse")); - - currentCursor = -1; - - image_info = 0; - painted = false; -} - - -void MyWindow::setWindowTitle(const QString &title) - -{ - QByteArray ba = title.toLatin1(); //We're not making a general solution here... - XTextProperty windowName; - windowName.value = (unsigned char *)ba.constData(); - windowName.encoding = XA_STRING; - windowName.format = 8; - windowName.nitems = ba.length(); - - XSetWMName(xd->display, window, &windowName); -} - -MyWindow::~MyWindow() -{ -#ifdef MYX11_DEBUG - qDebug() << "~MyWindow" << hex << window; -#endif - XFreeGC(xd->display, gc); - XDestroyWindow(xd->display, window); - - xd->windowList.removeAll(this); - - delete image_info; -} - -GC MyWindow::createGC() -{ - GC gc; - - gc = XCreateGC(xd->display, window, 0, 0); - if (gc < 0) { - qWarning("MyWindow::createGC() could not create GC"); - } - return gc; -} - -void MyWindow::closeEvent() -{ - windowSurface->handleCloseEvent(); -} - -void MyWindow::paintEvent() -{ -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::paintEvent" << shm_img.size() << painted; -#endif - if (!painted) - return; - -#ifdef DONT_USE_MIT_SHM - // just convert the image every time... - if (!shm_img.isNull()) { - Visual *visual = DefaultVisual(xd->display, xd->screen); - - QImage image = shm_img; - //img.convertToFormat( - XImage *xi = XCreateImage(xd->display, visual, 24, ZPixmap, - 0, (char *) image.scanLine(0), image.width(), image.height(), - 32, image.bytesPerLine()); - - int x = 0; - int y = 0; - - /*int r =*/ XPutImage(xd->display, window, gc, xi, 0, 0, x, y, image.width(), image.height()); - - xi->data = 0; // QImage owns these bits - XDestroyImage(xi); - } -#else - // Use MIT_SHM - if (image_info->image) { - //qDebug() << "Here we go" << image_info->image->width << image_info->image->height; - int x = 0; - int y = 0; - - // We could set send_event to true, and then use the ShmCompletion to synchronize, - // but let's do like Qt/11 and just use XSync - XShmPutImage (xd->display, window, gc, image_info->image, 0, 0, - x, y, image_info->image->width, image_info->image->height, - /*send_event*/ False); - - XSync(xd->display, False); - } -#endif -} - -#ifndef DONT_USE_MIT_SHM -void MyShmImageInfo::destroy() -{ - XShmDetach (display, &shminfo); - XDestroyImage (image); - shmdt (shminfo.shmaddr); - shmctl (shminfo.shmid, IPC_RMID, 0); -} -#endif - -void MyWindow::resizeShmImage(int width, int height) -{ -#ifdef DONT_USE_MIT_SHM - shm_img = QImage(width, height, QImage::Format_RGB32); -#else - if (image_info) - image_info->destroy(); - else - image_info = new MyShmImageInfo(xd->display); - - Visual *visual = DefaultVisual(xd->display, xd->screen); - - - XImage *image = XShmCreateImage (xd->display, visual, 24, ZPixmap, 0, - &image_info->shminfo, width, height); - - - image_info->shminfo.shmid = shmget (IPC_PRIVATE, - image->bytes_per_line * image->height, IPC_CREAT|0777); - - image_info->shminfo.shmaddr = image->data = (char*)shmat (image_info->shminfo.shmid, 0, 0); - image_info->shminfo.readOnly = False; - - image_info->image = image; - - Status shm_attach_status = XShmAttach(xd->display, &image_info->shminfo); - - Q_ASSERT(shm_attach_status == True); - - shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, QImage::Format_RGB32 ); -#endif - painted = false; -} - - -void MyWindow::resizeBuffer(QSize s) -{ - if (shm_img.size() != s) - resizeShmImage(s.width(), s.height()); -} - -QSize MyWindow::bufferSize() const -{ - return shm_img.size(); -} - - -void MyWindow::resizeEvent(XConfigureEvent *e) -{ - - if ((e->width != width || e->height != height) && e->x == 0 && e->y == 0) { - //qDebug() << "resize with bogus pos" << e->x << e->y << e->width << e->height << "window"<< hex << window; - } else { - //qDebug() << "geometry change" << e->x << e->y << e->width << e->height << "window"<< hex << window; - xpos = e->x; - ypos = e->y; - } - width = e->width; - height = e->height; - -#ifdef MYX11_DEBUG - qDebug() << hex << window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height << "img:" << shm_img.size(); -#endif - - windowSurface->handleGeometryChange(xpos, ypos, width, height); -} - -#if 0 -void MyWindow::setSize(int w, int h) -{ - XResizeWindow(xd->display, window, w, h); -} -#endif - -void MyWindow::setGeometry(int x, int y, int w, int h) -{ -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::setGeometry" << hex << window << dec << x << y << w << h << "img:" << shm_img.size(); -#endif - XMoveResizeWindow(xd->display, window, x, y, w, h); -} - - -void MyWindow::enterEvent(XCrossingEvent *) -{ -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::enterEvent" << hex << window; -#endif - windowSurface->handleEnterEvent(); -} - -void MyWindow::leaveEvent(XCrossingEvent *) -{ -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::enterEvent" << hex << window; -#endif - windowSurface->handleLeaveEvent(); -} - -void MyWindow::mousePressEvent(XButtonEvent *e) -{ - static long prevTime = 0; - static Window prevWindow; - static int prevX = -999; - static int prevY = -999; - - QEvent::Type type = QEvent::MouseButtonPress; - - if (e->window == prevWindow && long(e->time) - prevTime < QApplication::doubleClickInterval() - && qAbs(e->x - prevX) < 5 && qAbs(e->y - prevY) < 5) { - type = QEvent::MouseButtonDblClick; - prevTime = e->time - QApplication::doubleClickInterval(); //no double click next time - } else { - prevTime = e->time; - } - prevWindow = e->window; - prevX = e->x; - prevY = e->y; - - windowSurface->handleMouseEvent(type, e); -} - -void MyWindow::mouseReleaseEvent(XButtonEvent *e) -{ - windowSurface->handleMouseEvent(QEvent::MouseButtonRelease, e); -} - -void MyWindow::mouseMoveEvent(XButtonEvent *e) -{ - windowSurface->handleMouseEvent(QEvent::MouseMove, e); -} - -#ifdef KeyPress -#undef KeyPress -#endif - -void MyWindow::keyPressEvent(XKeyEvent *e) -{ - windowSurface->handleKeyEvent(QEvent::KeyPress, e); -} - -#ifdef KeyRelease -#undef KeyRelease -#endif - -void MyWindow::keyReleaseEvent(XKeyEvent *e) -{ - windowSurface->handleKeyEvent(QEvent::KeyRelease, e); -} - - -// WindowFlag stuff, lots of copied code from qwidget_x11.cpp... - -//We're hacking here... - - -// MWM support -struct QtMWMHints { - ulong flags, functions, decorations; - long input_mode; - ulong status; -}; - -enum { - MWM_HINTS_FUNCTIONS = (1L << 0), - - MWM_FUNC_ALL = (1L << 0), - MWM_FUNC_RESIZE = (1L << 1), - MWM_FUNC_MOVE = (1L << 2), - MWM_FUNC_MINIMIZE = (1L << 3), - MWM_FUNC_MAXIMIZE = (1L << 4), - MWM_FUNC_CLOSE = (1L << 5), - - MWM_HINTS_DECORATIONS = (1L << 1), - - MWM_DECOR_ALL = (1L << 0), - MWM_DECOR_BORDER = (1L << 1), - MWM_DECOR_RESIZEH = (1L << 2), - MWM_DECOR_TITLE = (1L << 3), - MWM_DECOR_MENU = (1L << 4), - MWM_DECOR_MINIMIZE = (1L << 5), - MWM_DECOR_MAXIMIZE = (1L << 6), - - MWM_HINTS_INPUT_MODE = (1L << 2), - - MWM_INPUT_MODELESS = 0L, - MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L, - MWM_INPUT_FULL_APPLICATION_MODAL = 3L -}; - -static Atom mwm_hint_atom = XNone; - -static QtMWMHints GetMWMHints(Display *display, Window window) -{ - QtMWMHints mwmhints; - - Atom type; - int format; - ulong nitems, bytesLeft; - uchar *data = 0; - if ((XGetWindowProperty(display, window, mwm_hint_atom, 0, 5, false, - mwm_hint_atom, &type, &format, &nitems, &bytesLeft, - &data) == Success) - && (type == mwm_hint_atom - && format == 32 - && nitems >= 5)) { - mwmhints = *(reinterpret_cast(data)); - } else { - mwmhints.flags = 0L; - mwmhints.functions = MWM_FUNC_ALL; - mwmhints.decorations = MWM_DECOR_ALL; - mwmhints.input_mode = 0L; - mwmhints.status = 0L; - } - - if (data) - XFree(data); - - return mwmhints; -} - -static void SetMWMHints(Display *display, Window window, const QtMWMHints &mwmhints) -{ - if (mwmhints.flags != 0l) { - XChangeProperty(display, window, mwm_hint_atom, mwm_hint_atom, 32, - PropModeReplace, (unsigned char *) &mwmhints, 5); - } else { - XDeleteProperty(display, window, mwm_hint_atom); - } -} - -// 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)); -} - - - -Qt::WindowFlags MyWindow::setWindowFlags(Qt::WindowFlags flags) -{ - - if (mwm_hint_atom == XNone) { - mwm_hint_atom = XInternAtom(xd->display, "_MOTIF_WM_HINTS\0", False); - } - -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::setWindowFlags" << hex << window << "flags" << flags; -#endif - Qt::WindowType type = static_cast(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); - - bool tooltip = (type == Qt::ToolTip); - - XSetWindowAttributes wsa; - - QtMWMHints mwmhints; - mwmhints.flags = 0L; - mwmhints.functions = 0L; - mwmhints.decorations = 0; - mwmhints.input_mode = 0L; - mwmhints.status = 0L; - - - ulong wsa_mask = 0; - if (type != Qt::SplashScreen) { // && customize) { - 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 (tool) { - wsa.save_under = True; - wsa_mask |= CWSaveUnder; - } - - if (flags & Qt::X11BypassWindowManagerHint) { - wsa.override_redirect = True; - wsa_mask |= CWOverrideRedirect; - } -#if 0 - if (wsa_mask && initializeWindow) { - Q_ASSERT(id); - XChangeWindowAttributes(dpy, id, wsa_mask, &wsa); - } -#endif - 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; - } - - SetMWMHints(xd->display, window, mwmhints); - -//##### only if initializeWindow??? - - if (popup || tooltip) { // popup widget -#ifdef MYX11_DEBUG - qDebug() << "Doing XChangeWindowAttributes for popup" << wsa.override_redirect; -#endif - // set EWMH window types - // setNetWmWindowTypes(); - - wsa.override_redirect = True; - wsa.save_under = True; - XChangeWindowAttributes(xd->display, window, CWOverrideRedirect | CWSaveUnder, - &wsa); - } else { -#ifdef MYX11_DEBUG - qDebug() << "Doing XChangeWindowAttributes for non-popup"; -#endif - } - - return flags; -} - -void MyWindow::setVisible(bool visible) -{ -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::setVisible" << visible << hex << window; -#endif - if (visible) - XMapWindow(xd->display, window); - else - XUnmapWindow(xd->display, window); -} - -MyX11Cursors::MyX11Cursors(Display * d) : firstExpired(0), lastExpired(0), display(d), removalDelay(3) -{ - connect(&timer, SIGNAL(timeout()), this, SLOT(timeout())); -} - -void MyX11Cursors::insertNode(MyX11CursorNode * node) -{ - QDateTime now = QDateTime::currentDateTime(); - QDateTime timeout = now.addSecs(removalDelay); - node->setExpiration(timeout); - node->setPost(0); - if (lastExpired) { - lastExpired->setPost(node); - node->setAnte(lastExpired); - } - lastExpired = node; - if (!firstExpired) { - firstExpired = node; - node->setAnte(0); - int interval = removalDelay * 1000; - timer.setInterval(interval); - timer.start(); - } -} - -void MyX11Cursors::removeNode(MyX11CursorNode * node) -{ - MyX11CursorNode *pre = node->ante(); - MyX11CursorNode *post = node->post(); - if (pre) - pre->setPost(post); - if (post) - post->setAnte(pre); - if (node == lastExpired) - lastExpired = pre; - if (node == firstExpired) { - firstExpired = post; - if (!firstExpired) { - timer.stop(); - return; - } - int interval = QDateTime::currentDateTime().secsTo(firstExpired->expiration()) * 1000; - timer.stop(); - timer.setInterval(interval); - timer.start(); - } -} - -void MyX11Cursors::incrementUseCount(int id) -{ - MyX11CursorNode * node = lookupMap.value(id); - Q_ASSERT(node); - if (!node->refCount) - removeNode(node); - node->refCount++; -} - -void MyX11Cursors::decrementUseCount(int id) -{ - MyX11CursorNode * node = lookupMap.value(id); - Q_ASSERT(node); - node->refCount--; - if (!node->refCount) - insertNode(node); -} - -void MyX11Cursors::createNode(int id, Cursor c) -{ - MyX11CursorNode * node = new MyX11CursorNode(id, c); - lookupMap.insert(id, node); -} - -void MyX11Cursors::timeout() -{ - MyX11CursorNode * node; - node = firstExpired; - QDateTime now = QDateTime::currentDateTime(); - while (node && now.secsTo(node->expiration()) < 1) { - Cursor c = node->cursor(); - int id = node->id(); - lookupMap.take(id); - MyX11CursorNode * tmp = node; - node = node->post(); - delete tmp; - XFreeCursor(display, c); - } - firstExpired = node; - if (node == 0) { - timer.stop(); - lastExpired = 0; - } - else { - int interval = QDateTime::currentDateTime().secsTo(firstExpired->expiration()) * 1000; - timer.setInterval(interval); - timer.start(); - } -} - -Cursor MyX11Cursors::cursor(int id) -{ - MyX11CursorNode * node = lookupMap.value(id); - Q_ASSERT(node); - return node->cursor(); -} - -void MyWindow::setCursor(QCursor * cursor) -{ - int id = cursor->handle(); - if (id == currentCursor) - return; - Cursor c; - if (!xd->cursors->exists(id)) { - if (cursor->shape() == Qt::BitmapCursor) - c = createCursorBitmap(cursor); - else - c = createCursorShape(cursor->shape()); - if (!c) { - return; - } - xd->cursors->createNode(id, c); - } else { - xd->cursors->incrementUseCount(id); - c = xd->cursors->cursor(id); - } - - if (currentCursor != -1) - xd->cursors->decrementUseCount(currentCursor); - currentCursor = id; - - XDefineCursor(xd->display, window, c); - XFlush(xd->display); -} - -Cursor MyWindow::createCursorBitmap(QCursor * cursor) -{ - XColor bg, fg; - bg.red = 255 << 8; - bg.green = 255 << 8; - bg.blue = 255 << 8; - fg.red = 0; - fg.green = 0; - fg.blue = 0; - QPoint spot = cursor->hotSpot(); - Window rootwin = window; - - QImage mapImage = cursor->bitmap()->toImage().convertToFormat(QImage::Format_MonoLSB); - QImage maskImage = cursor->mask()->toImage().convertToFormat(QImage::Format_MonoLSB); - - int width = cursor->bitmap()->width(); - int height = cursor->bitmap()->height(); - int bytesPerLine = mapImage.bytesPerLine(); - int destLineSize = width / 8; - if (width % 8) - destLineSize++; - - const uchar * map = mapImage.bits(); - const uchar * mask = maskImage.bits(); - - char * mapBits = new char[height * destLineSize]; - char * maskBits = new char[height * destLineSize]; - for (int i = 0; i < height; i++) { - memcpy(mapBits + (destLineSize * i),map + (bytesPerLine * i), destLineSize); - memcpy(maskBits + (destLineSize * i),mask + (bytesPerLine * i), destLineSize); - } - - Pixmap cp = XCreateBitmapFromData(xd->display, rootwin, mapBits, width, height); - Pixmap mp = XCreateBitmapFromData(xd->display, rootwin, maskBits, width, height); - Cursor c = XCreatePixmapCursor(xd->display, cp, mp, &fg, &bg, spot.x(), spot.y()); - XFreePixmap(xd->display, cp); - XFreePixmap(xd->display, mp); - delete[] mapBits; - delete[] maskBits; - - return c; -} - -Cursor MyWindow::createCursorShape(int cshape) -{ - Cursor cursor = 0; - - if (cshape < 0 || cshape > Qt::LastCursor) - return 0; - - switch (cshape) { - case Qt::ArrowCursor: - cursor = XCreateFontCursor(xd->display, XC_left_ptr); - break; - case Qt::UpArrowCursor: - cursor = XCreateFontCursor(xd->display, XC_center_ptr); - break; - case Qt::CrossCursor: - cursor = XCreateFontCursor(xd->display, XC_crosshair); - break; - case Qt::WaitCursor: - cursor = XCreateFontCursor(xd->display, XC_watch); - break; - case Qt::IBeamCursor: - cursor = XCreateFontCursor(xd->display, XC_xterm); - break; - case Qt::SizeAllCursor: - cursor = XCreateFontCursor(xd->display, XC_fleur); - break; - case Qt::PointingHandCursor: - cursor = XCreateFontCursor(xd->display, XC_hand2); - break; - case Qt::SizeBDiagCursor: - cursor = XCreateFontCursor(xd->display, XC_top_right_corner); - break; - case Qt::SizeFDiagCursor: - cursor = XCreateFontCursor(xd->display, XC_bottom_right_corner); - break; - case Qt::SizeVerCursor: - case Qt::SplitVCursor: - cursor = XCreateFontCursor(xd->display, XC_sb_v_double_arrow); - break; - case Qt::SizeHorCursor: - case Qt::SplitHCursor: - cursor = XCreateFontCursor(xd->display, XC_sb_h_double_arrow); - break; - case Qt::WhatsThisCursor: - cursor = XCreateFontCursor(xd->display, XC_question_arrow); - break; - case Qt::ForbiddenCursor: - cursor = XCreateFontCursor(xd->display, XC_circle); - break; - case Qt::BusyCursor: - cursor = XCreateFontCursor(xd->display, XC_watch); - break; - - default: //default cursor for all the rest - break; - } - return cursor; -} - - -#if 0 - - - switch (cshape) { // map Q cursor to X cursor - case Qt::BlankCursor: - XColor bg, fg; - bg.red = 255 << 8; - bg.green = 255 << 8; - bg.blue = 255 << 8; - fg.red = 0; - fg.green = 0; - fg.blue = 0; - pm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16); - pmm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16); - hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8); - return; - break; - default: - qWarning("QCursor::update: Invalid cursor shape %d", cshape); - return; - } -#endif diff --git a/src/plugins/graphicssystems/testlite/x11util.h b/src/plugins/graphicssystems/testlite/x11util.h deleted file mode 100644 index 79e7461..0000000 --- a/src/plugins/graphicssystems/testlite/x11util.h +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MYX11UTIL_H -#define MYX11UTIL_H - -#include -#include -#include -#include - -#include - -#include -#include - - -class MyWindow; -class MyX11Cursors; - -class MyDisplay : public QObject -{ - Q_OBJECT; -public: - MyDisplay(); - ~MyDisplay(); - - Window rootWindow() { return RootWindow(display, screen); } - unsigned long blackPixel() { return BlackPixel(display, screen); } - unsigned long whitePixel() { return WhitePixel(display, screen); } - - bool handleEvent(XEvent *xe); - QImage grabWindow(Window window, int x, int y, int w, int h); - -public slots: - void eventDispatcher(); - -public: //### - Display * display; - int screen; - int width, height; - int physicalWidth; - int physicalHeight; - - QList windowList; - - MyX11Cursors * cursors; -}; - -class QTestLiteWindowSurface; //### abstract callback interface, anyone? - -struct MyShmImageInfo; - -class MyWindow : public QObject -{ - Q_OBJECT; -public: - MyWindow(MyDisplay *xd, int x, int y, int w, int h); - ~MyWindow(); - - - void mousePressEvent(XButtonEvent*); - void mouseReleaseEvent(XButtonEvent*); - void mouseMoveEvent(XButtonEvent*); - - void keyPressEvent(XKeyEvent*); - void keyReleaseEvent(XKeyEvent*); - - void enterEvent(XCrossingEvent*); - void leaveEvent(XCrossingEvent*); - - void closeEvent(); - void paintEvent(); - void resizeEvent(XConfigureEvent *configure_event); -// void setSize(int w, int h); - void setGeometry(int x, int y, int w, int h); - - GC createGC(); - - Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); - void setVisible(bool visible); - void setCursor(QCursor * cursor); - Cursor createCursorShape(int cshape); - Cursor createCursorBitmap(QCursor * cursor); - - void setWindowTitle(const QString &title); - - QImage *image() { return &shm_img; } - -public: //### - - int xpos, ypos; - int width, height; - Window window; - MyDisplay *xd; - GC gc; - - QTestLiteWindowSurface *windowSurface; - - int currentCursor; - bool painted; - void resizeBuffer(QSize); - QSize bufferSize() const; - -private: - void resizeShmImage(int width, int height); - - QImage shm_img; - MyShmImageInfo *image_info; -}; - -class MyX11CursorNode -{ -public: - MyX11CursorNode(int id, Cursor c) { idValue = id; cursorValue = c; refCount = 1; } - QDateTime expiration() { return t; } - void setExpiration(QDateTime val) { t = val; } - MyX11CursorNode * ante() { return before; } - void setAnte(MyX11CursorNode *node) { before = node; } - MyX11CursorNode * post() { return after; } - void setPost(MyX11CursorNode *node) { after = node; } - Cursor cursor() { return cursorValue; } - int id() { return idValue; } - unsigned int refCount; - -private: - MyX11CursorNode *before; - MyX11CursorNode *after; - QDateTime t; - Cursor cursorValue; - int idValue; - - Display * display; -}; - -class MyX11Cursors : public QObject -{ - Q_OBJECT -public: - MyX11Cursors(Display * d); - ~MyX11Cursors() { timer.stop(); } - void incrementUseCount(int id); - void decrementUseCount(int id); - void createNode(int id, Cursor c); - bool exists(int id) { return lookupMap.contains(id); } - Cursor cursor(int id); -public slots: - void timeout(); - -private: - void removeNode(MyX11CursorNode *node); - void insertNode(MyX11CursorNode *node); - - // linked list of cursors currently not assigned to any window - MyX11CursorNode *firstExpired; - MyX11CursorNode *lastExpired; - - QHash lookupMap; - QTimer timer; - - Display *display; - - int removalDelay; -}; - -#endif // MYX11UTIL_H diff --git a/src/plugins/graphicssystems/vnc/main.cpp b/src/plugins/graphicssystems/vnc/main.cpp deleted file mode 100644 index f10748a..0000000 --- a/src/plugins/graphicssystems/vnc/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qgraphicssystem_vnc.h" -#include - -QT_BEGIN_NAMESPACE - -class QVNCGraphicsSystemPlugin : public QGraphicsSystemPlugin -{ -public: - QStringList keys() const; - QGraphicsSystem *create(const QString&); -}; - -QStringList QVNCGraphicsSystemPlugin::keys() const -{ - QStringList list; - list << "VNC"; - return list; -} - -QGraphicsSystem* QVNCGraphicsSystemPlugin::create(const QString& system) -{ - if (system.toLower() == "vnc") - return new QVNCGraphicsSystem; - - return 0; -} - -Q_EXPORT_PLUGIN2(vnc, QVNCGraphicsSystemPlugin) - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp deleted file mode 100644 index 7815f24..0000000 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_vnc.h" -#include "../fb_base/fb_base.h" -#include -#include -#include - -#include -#include - -#include - - -QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() - : QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() -{ - int w = 800; - int h = 600; - int ew, eh; - const char *str; - if ((str=::getenv("QT_VNC_SIZE")) && sscanf(str,"%dx%d",&ew,&eh)==2) { - w = ew; - h = eh; - } - - setGeometry(QRect(0,0,w, h)); - setDepth(32); - setFormat(QImage::Format_RGB32); - setPhysicalSize((geometry().size()*254)/720); - - - d_ptr = new QVNCGraphicsSystemScreenPrivate(this); - - cursor = new QVNCCursor(d_ptr->vncServer, this); - d_ptr->vncServer->setCursor(static_cast(cursor)); -} - -QVNCDirtyMap *QVNCGraphicsSystemScreen::dirtyMap() -{ - return d_ptr->dirty; -} - -QRegion QVNCGraphicsSystemScreen::doRedraw() -{ - QRegion touched; - touched = QGraphicsSystemFbScreen::doRedraw(); - - QVector rects = touched.rects(); - for (int i = 0; i < rects.size(); i++) - d_ptr->setDirty(rects[i]); - return touched; -} - - -QVNCGraphicsSystem::QVNCGraphicsSystem() -{ - mPrimaryScreen = new QVNCGraphicsSystemScreen(); - - mScreens.append(mPrimaryScreen); -} - -QPixmapData *QVNCGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -QWindowSurface *QVNCGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - if (widget->windowType() == Qt::Desktop) - return 0; // Don't create an explicit window surface for the destkop. - QGraphicsSystemFbWindowSurface * surface; - surface = new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); - mPrimaryScreen->addWindowSurface(surface); - return surface; -} diff --git a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h b/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h deleted file mode 100644 index b3349b7..0000000 --- a/src/plugins/graphicssystems/vnc/qgraphicssystem_vnc.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_VNC_H -#define QGRAPHICSSYSTEM_VNC_H - -#include -#include "qvnccursor.h" -#include "../fb_base/fb_base.h" - -QT_BEGIN_NAMESPACE - -class QVNCServer; -class QVNCDirtyMap; - -class QVNCGraphicsSystemScreenPrivate; - -class QVNCGraphicsSystemScreen : public QGraphicsSystemFbScreen -{ -public: - QVNCGraphicsSystemScreen(); - - int linestep() const { return image() ? image()->bytesPerLine() : 0; } - uchar *base() const { return image() ? image()->bits() : 0; } - QVNCDirtyMap *dirtyMap(); - -public: - QVNCGraphicsSystemScreenPrivate *d_ptr; - -private: - QVNCServer *server; - QRegion doRedraw(); -}; - -class QVNCGraphicsSystemPrivate; - - -class QVNCGraphicsSystem : public QGraphicsSystem -{ -public: - QVNCGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - - QList screens() const { return mScreens; } - - -private: - QVNCGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; -}; - - - -QT_END_NAMESPACE - -#endif //QGRAPHICSSYSTEM_VNC_H - diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.cpp b/src/plugins/graphicssystems/vnc/qvnccursor.cpp deleted file mode 100644 index fb214d8..0000000 --- a/src/plugins/graphicssystems/vnc/qvnccursor.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -#include - -#include "qvnccursor.h" -#include "qvncserver.h" -#include "qgraphicssystem_vnc.h" - -QT_BEGIN_NAMESPACE - -QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCGraphicsSystemScreen *scr ) - :QGraphicsSystemSoftwareCursor(scr), useVncCursor(false), server(srvr) -{ -} - -void QVNCCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) -{ - QGraphicsSystemSoftwareCursor::changeCursor(widgetCursor, widget); - if (useVncCursor) { - server->setDirtyCursor(); - } else { - screen->setDirty(QRect(0,0,1,1)); - } -} - -void QVNCCursor::setCursorMode(bool vnc) -{ - if (vnc) { - screen->setDirty(dirtyRect()); - server->setDirtyCursor(); - } else { - server->setDirtyCursor(); - } - useVncCursor = vnc; -} - -QRect QVNCCursor::drawCursor(QPainter & painter) -{ - if (useVncCursor) - return QRect(); - - return QGraphicsSystemSoftwareCursor::drawCursor(painter); -} - -void QVNCCursor::clearClientCursor() -{ - QTcpSocket *socket = server->clientSocket(); - if (!socket) { - return; - } - // FramebufferUpdate header - { - const quint16 tmp[6] = { htons(0), - htons(1), - htons(0), htons(0), - htons(0), - htons(0) }; - socket->write((char*)tmp, sizeof(tmp)); - - const quint32 encoding = htonl(-239); - socket->write((char*)(&encoding), sizeof(encoding)); - } -} - -void QVNCCursor::sendClientCursor() -{ - if (useVncCursor == false) { - clearClientCursor(); - return; - } - QImage *image = graphic->image(); - if (image->isNull()) - return; - QTcpSocket *socket = server->clientSocket(); - if (!socket) { - return; - } - // FramebufferUpdate header - { - const quint16 tmp[6] = { htons(0), - htons(1), - htons(graphic->hotspot().x()), htons(graphic->hotspot().y()), - htons(image->width()), - htons(image->height()) }; - socket->write((char*)tmp, sizeof(tmp)); - - const quint32 encoding = htonl(-239); - socket->write((char*)(&encoding), sizeof(encoding)); - } - - // write pixels - //Q_ASSERT(cursor->hasAlphaChannel()); - const QImage img = image->convertToFormat(QImage::Format_RGB32); - const int n = server->clientBytesPerPixel() * img.width(); - char *buffer = new char[n]; - for (int i = 0; i < img.height(); ++i) { - server->convertPixels(buffer, (const char*)img.scanLine(i), img.width()); - socket->write(buffer, n); - } - delete[] buffer; - - // write mask - const QImage bitmap = image->createAlphaMask().convertToFormat(QImage::Format_Mono); - Q_ASSERT(bitmap.depth() == 1); - Q_ASSERT(bitmap.size() == img.size()); - const int width = (bitmap.width() + 7) / 8; - for (int i = 0; i < bitmap.height(); ++i) - socket->write((const char*)bitmap.scanLine(i), width); -} - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/vnc/qvnccursor.h b/src/plugins/graphicssystems/vnc/qvnccursor.h deleted file mode 100644 index 8ea0f45..0000000 --- a/src/plugins/graphicssystems/vnc/qvnccursor.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QVNCCURSOR_H -#define QVNCCURSOR_H - -#include "../fb_base/fb_base.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QVNCGraphicsSystemScreen; -class QVNCServer; - -class QVNCCursor : public QGraphicsSystemSoftwareCursor { -public: - QVNCCursor(QVNCServer *, QVNCGraphicsSystemScreen *); - - // input methods - void setCursorMode(bool vnc); - void changeCursor(QCursor * widgetCursor, QWidget * widget); - - // output methods - QRect drawCursor(QPainter &); - - // VNC client communication - void sendClientCursor(); - void clearClientCursor(); -private: - bool useVncCursor; // VNC or local - - QVNCServer * server; // VNC server to get events from -}; - -QT_END_NAMESPACE - -#endif // QVNCCURSOR_H diff --git a/src/plugins/graphicssystems/vnc/qvncserver.cpp b/src/plugins/graphicssystems/vnc/qvncserver.cpp deleted file mode 100644 index ea576d4..0000000 --- a/src/plugins/graphicssystems/vnc/qvncserver.cpp +++ /dev/null @@ -1,1935 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvncserver.h" - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include - - -#define QT_QWS_VNC_DEBUG -#define QT_NO_QWS_CURSOR //### - - -QT_BEGIN_NAMESPACE - - - -//copied from qscreen_qws.h -#ifndef QT_QWS_DEPTH16_RGB -#define QT_QWS_DEPTH16_RGB 565 -#endif -static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100); -static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10); -static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10); -static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits); -static const int qt_green_shift = qt_bbits-(8-qt_gbits); -static const int qt_neg_blue_shift = 8-qt_bbits; -static const int qt_blue_mask = (1<> qt_red_shift | r >> qt_red_rounding_shift; - const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift; - const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift; - - return qRgb(tr,tg,tb); -} - - - -//=========================================================================== - -static const struct { - int keysym; - int keycode; -} keyMap[] = { - { 0xff08, Qt::Key_Backspace }, - { 0xff09, Qt::Key_Tab }, - { 0xff0d, Qt::Key_Return }, - { 0xff1b, Qt::Key_Escape }, - { 0xff63, Qt::Key_Insert }, - { 0xffff, Qt::Key_Delete }, - { 0xff50, Qt::Key_Home }, - { 0xff57, Qt::Key_End }, - { 0xff55, Qt::Key_PageUp }, - { 0xff56, Qt::Key_PageDown }, - { 0xff51, Qt::Key_Left }, - { 0xff52, Qt::Key_Up }, - { 0xff53, Qt::Key_Right }, - { 0xff54, Qt::Key_Down }, - { 0xffbe, Qt::Key_F1 }, - { 0xffbf, Qt::Key_F2 }, - { 0xffc0, Qt::Key_F3 }, - { 0xffc1, Qt::Key_F4 }, - { 0xffc2, Qt::Key_F5 }, - { 0xffc3, Qt::Key_F6 }, - { 0xffc4, Qt::Key_F7 }, - { 0xffc5, Qt::Key_F8 }, - { 0xffc6, Qt::Key_F9 }, - { 0xffc7, Qt::Key_F10 }, - { 0xffc8, Qt::Key_F11 }, - { 0xffc9, Qt::Key_F12 }, - { 0xffe1, Qt::Key_Shift }, - { 0xffe2, Qt::Key_Shift }, - { 0xffe3, Qt::Key_Control }, - { 0xffe4, Qt::Key_Control }, - { 0xffe7, Qt::Key_Meta }, - { 0xffe8, Qt::Key_Meta }, - { 0xffe9, Qt::Key_Alt }, - { 0xffea, Qt::Key_Alt }, - { 0, 0 } -}; - -void QRfbRect::read(QTcpSocket *s) -{ - quint16 buf[4]; - s->read((char*)buf, 8); - x = ntohs(buf[0]); - y = ntohs(buf[1]); - w = ntohs(buf[2]); - h = ntohs(buf[3]); -} - -void QRfbRect::write(QTcpSocket *s) const -{ - quint16 buf[4]; - buf[0] = htons(x); - buf[1] = htons(y); - buf[2] = htons(w); - buf[3] = htons(h); - s->write((char*)buf, 8); -} - -void QRfbPixelFormat::read(QTcpSocket *s) -{ - char buf[16]; - s->read(buf, 16); - bitsPerPixel = buf[0]; - depth = buf[1]; - bigEndian = buf[2]; - trueColor = buf[3]; - - quint16 a = ntohs(*(quint16 *)(buf + 4)); - redBits = 0; - while (a) { a >>= 1; redBits++; } - - a = ntohs(*(quint16 *)(buf + 6)); - greenBits = 0; - while (a) { a >>= 1; greenBits++; } - - a = ntohs(*(quint16 *)(buf + 8)); - blueBits = 0; - while (a) { a >>= 1; blueBits++; } - - redShift = buf[10]; - greenShift = buf[11]; - blueShift = buf[12]; -} - -void QRfbPixelFormat::write(QTcpSocket *s) -{ - char buf[16]; - buf[0] = bitsPerPixel; - buf[1] = depth; - buf[2] = bigEndian; - buf[3] = trueColor; - - quint16 a = 0; - for (int i = 0; i < redBits; i++) a = (a << 1) | 1; - *(quint16 *)(buf + 4) = htons(a); - - a = 0; - for (int i = 0; i < greenBits; i++) a = (a << 1) | 1; - *(quint16 *)(buf + 6) = htons(a); - - a = 0; - for (int i = 0; i < blueBits; i++) a = (a << 1) | 1; - *(quint16 *)(buf + 8) = htons(a); - - buf[10] = redShift; - buf[11] = greenShift; - buf[12] = blueShift; - s->write(buf, 16); -} - - -void QRfbServerInit::setName(const char *n) -{ - delete[] name; - name = new char [strlen(n) + 1]; - strcpy(name, n); -} - -void QRfbServerInit::read(QTcpSocket *s) -{ - s->read((char *)&width, 2); - width = ntohs(width); - s->read((char *)&height, 2); - height = ntohs(height); - format.read(s); - - quint32 len; - s->read((char *)&len, 4); - len = ntohl(len); - - name = new char [len + 1]; - s->read(name, len); - name[len] = '\0'; -} - -void QRfbServerInit::write(QTcpSocket *s) -{ - quint16 t = htons(width); - s->write((char *)&t, 2); - t = htons(height); - s->write((char *)&t, 2); - format.write(s); - quint32 len = strlen(name); - len = htonl(len); - s->write((char *)&len, 4); - s->write(name, strlen(name)); -} - -bool QRfbSetEncodings::read(QTcpSocket *s) -{ - if (s->bytesAvailable() < 3) - return false; - - char tmp; - s->read(&tmp, 1); // padding - s->read((char *)&count, 2); - count = ntohs(count); - - return true; -} - -bool QRfbFrameBufferUpdateRequest::read(QTcpSocket *s) -{ - if (s->bytesAvailable() < 9) - return false; - - s->read(&incremental, 1); - rect.read(s); - - return true; -} - -bool QRfbKeyEvent::read(QTcpSocket *s) -{ - if (s->bytesAvailable() < 7) - return false; - - s->read(&down, 1); - quint16 tmp; - s->read((char *)&tmp, 2); // padding - - quint32 key; - s->read((char *)&key, 4); - key = ntohl(key); - - unicode = 0; - keycode = 0; - int i = 0; - while (keyMap[i].keysym && !keycode) { - if (keyMap[i].keysym == (int)key) - keycode = keyMap[i].keycode; - i++; - } - if (!keycode) { - if (key <= 0xff) { - unicode = key; - if (key >= 'a' && key <= 'z') - keycode = Qt::Key_A + key - 'a'; - else if (key >= ' ' && key <= '~') - keycode = Qt::Key_Space + key - ' '; - } - } - - return true; -} - -bool QRfbPointerEvent::read(QTcpSocket *s) -{ - if (s->bytesAvailable() < 5) - return false; - - char buttonMask; - s->read(&buttonMask, 1); - - buttons = Qt::NoButton; - wheelDirection = WheelNone; - if (buttonMask & 1) - buttons |= Qt::LeftButton; - if (buttonMask & 2) - buttons |= Qt::MidButton; - if (buttonMask & 4) - buttons |= Qt::RightButton; - if (buttonMask & 8) - wheelDirection = WheelUp; - if (buttonMask & 16) - wheelDirection = WheelDown; - if (buttonMask & 32) - wheelDirection = WheelLeft; - if (buttonMask & 64) - wheelDirection = WheelRight; - - quint16 tmp; - s->read((char *)&tmp, 2); - x = ntohs(tmp); - s->read((char *)&tmp, 2); - y = ntohs(tmp); - - return true; -} - -bool QRfbClientCutText::read(QTcpSocket *s) -{ - if (s->bytesAvailable() < 7) - return false; - - char tmp[3]; - s->read(tmp, 3); // padding - s->read((char *)&length, 4); - length = ntohl(length); - - return true; -} - -//=========================================================================== - -QVNCServer::QVNCServer(QVNCGraphicsSystemScreen *screen) - : qvnc_screen(screen), cursor(0) -{ - init(5900); -} - -QVNCServer::QVNCServer(QVNCGraphicsSystemScreen *screen, int id) - : qvnc_screen(screen), cursor(0) -{ - init(5900 + id); -} - -void QVNCServer::init(uint port) -{ - qDebug() << "QVNCServer::init" << port; - - handleMsg = false; - client = 0; - encodingsPending = 0; - cutTextPending = 0; - keymod = 0; - state = Unconnected; - dirtyCursor = false; - - refreshRate = 25; - timer = new QTimer(this); - timer->setSingleShot(true); - connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); - - serverSocket = new QTcpServer(this); - if (!serverSocket->listen(QHostAddress::Any, port)) - qDebug() << "QVNCServer could not connect:" << serverSocket->errorString(); - else - qDebug("QVNCServer created on port %d", port); - - connect(serverSocket, SIGNAL(newConnection()), this, SLOT(newConnection())); - -#ifndef QT_NO_QWS_CURSOR - qvnc_cursor = 0; -#endif - encoder = 0; -} - -QVNCServer::~QVNCServer() -{ - delete encoder; - encoder = 0; - delete client; - client = 0; -#ifndef QT_NO_QWS_CURSOR - delete qvnc_cursor; - qvnc_cursor = 0; -#endif -} - -void QVNCServer::setDirty() -{ - if (state == Connected && !timer->isActive() && - ((dirtyMap()->numDirty > 0) || dirtyCursor)) { - timer->start(); - } -} - -void QVNCServer::newConnection() -{ - if (client) - delete client; - - client = serverSocket->nextPendingConnection(); - connect(client,SIGNAL(readyRead()),this,SLOT(readClient())); - connect(client,SIGNAL(disconnected()),this,SLOT(discardClient())); - handleMsg = false; - encodingsPending = 0; - cutTextPending = 0; - supportHextile = false; - wantUpdate = false; - - timer->start(1000 / refreshRate); - dirtyMap()->reset(); - - // send protocol version - const char *proto = "RFB 003.003\n"; - client->write(proto, 12); - state = Protocol; - -// if (!qvnc_screen->screen()) -// QWSServer::instance()->enablePainting(true); -} - -void QVNCServer::readClient() -{ - switch (state) { - case Protocol: - if (client->bytesAvailable() >= 12) { - char proto[13]; - client->read(proto, 12); - proto[12] = '\0'; - qDebug("Client protocol version %s", proto); - // No authentication - quint32 auth = htonl(1); - client->write((char *) &auth, sizeof(auth)); - state = Init; - } - break; - - case Init: - if (client->bytesAvailable() >= 1) { - quint8 shared; - client->read((char *) &shared, 1); - - // Server Init msg - QRfbServerInit sim; - QRfbPixelFormat &format = sim.format; - switch (qvnc_screen->depth()) { - case 32: - format.bitsPerPixel = 32; - format.depth = 32; - format.bigEndian = 0; - format.trueColor = true; - format.redBits = 8; - format.greenBits = 8; - format.blueBits = 8; - format.redShift = 16; - format.greenShift = 8; - format.blueShift = 0; - break; - - case 24: - format.bitsPerPixel = 24; - format.depth = 24; - format.bigEndian = 0; - format.trueColor = true; - format.redBits = 8; - format.greenBits = 8; - format.blueBits = 8; - format.redShift = 16; - format.greenShift = 8; - format.blueShift = 0; - break; - - case 18: - format.bitsPerPixel = 24; - format.depth = 18; - format.bigEndian = 0; - format.trueColor = true; - format.redBits = 6; - format.greenBits = 6; - format.blueBits = 6; - format.redShift = 12; - format.greenShift = 6; - format.blueShift = 0; - break; - - case 16: - format.bitsPerPixel = 16; - format.depth = 16; - format.bigEndian = 0; - format.trueColor = true; - format.redBits = 5; - format.greenBits = 6; - format.blueBits = 5; - format.redShift = 11; - format.greenShift = 5; - format.blueShift = 0; - break; - - case 15: - format.bitsPerPixel = 16; - format.depth = 15; - format.bigEndian = 0; - format.trueColor = true; - format.redBits = 5; - format.greenBits = 5; - format.blueBits = 5; - format.redShift = 10; - format.greenShift = 5; - format.blueShift = 0; - break; - - case 12: - format.bitsPerPixel = 16; - format.depth = 12; - format.bigEndian = 0; - format.trueColor = true; - format.redBits = 4; - format.greenBits = 4; - format.blueBits = 4; - format.redShift = 8; - format.greenShift = 4; - format.blueShift = 0; - break; - - case 8: - case 4: - format.bitsPerPixel = 8; - format.depth = 8; - format.bigEndian = 0; - format.trueColor = false; - format.redBits = 0; - format.greenBits = 0; - format.blueBits = 0; - format.redShift = 0; - format.greenShift = 0; - format.blueShift = 0; - break; - - default: - qDebug("QVNC cannot drive depth %d", qvnc_screen->depth()); - discardClient(); - return; - } - sim.width = qvnc_screen->geometry().width(); - sim.height = qvnc_screen->geometry().height(); - sim.setName("Qt for Embedded Linux VNC Server"); - sim.write(client); - state = Connected; - } - break; - - case Connected: - do { - if (!handleMsg) { - client->read((char *)&msgType, 1); - handleMsg = true; - } - if (handleMsg) { - switch (msgType ) { - case SetPixelFormat: - setPixelFormat(); - break; - case FixColourMapEntries: - qDebug("Not supported: FixColourMapEntries"); - handleMsg = false; - break; - case SetEncodings: - setEncodings(); - break; - case FramebufferUpdateRequest: - frameBufferUpdateRequest(); - break; - case KeyEvent: - keyEvent(); - break; - case PointerEvent: - pointerEvent(); - break; - case ClientCutText: - clientCutText(); - break; - default: - qDebug("Unknown message type: %d", (int)msgType); - handleMsg = false; - } - } - } while (!handleMsg && client->bytesAvailable()); - break; - default: - break; - } -} - -#if 0//Q_BYTE_ORDER == Q_BIG_ENDIAN -bool QVNCGraphicsSystemScreen::swapBytes() const -{ - if (depth() != 16) - return false; - - if (screen()) - return screen()->frameBufferLittleEndian(); - return frameBufferLittleEndian(); -} -#endif - -void QVNCServer::setPixelFormat() -{ - if (client->bytesAvailable() >= 19) { - char buf[3]; - client->read(buf, 3); // just padding - pixelFormat.read(client); -#ifdef QT_QWS_VNC_DEBUG - qDebug("Want format: %d %d %d %d %d %d %d %d %d %d", - int(pixelFormat.bitsPerPixel), - int(pixelFormat.depth), - int(pixelFormat.bigEndian), - int(pixelFormat.trueColor), - int(pixelFormat.redBits), - int(pixelFormat.greenBits), - int(pixelFormat.blueBits), - int(pixelFormat.redShift), - int(pixelFormat.greenShift), - int(pixelFormat.blueShift)); -#endif - if (!pixelFormat.trueColor) { - qDebug("Can only handle true color clients"); - discardClient(); - } - handleMsg = false; - sameEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) == !!pixelFormat.bigEndian; - needConversion = pixelConversionNeeded(); -#if Q_BYTE_ORDER == Q_BIG_ENDIAN - swapBytes = qvnc_screen->swapBytes(); -#endif - } -} - -void QVNCServer::setEncodings() -{ - QRfbSetEncodings enc; - - if (!encodingsPending && enc.read(client)) { - encodingsPending = enc.count; - if (!encodingsPending) - handleMsg = false; - } - - if (encoder) { - delete encoder; - encoder = 0; - } - - enum Encodings { - Raw = 0, - CopyRect = 1, - RRE = 2, - CoRRE = 4, - Hextile = 5, - ZRLE = 16, - Cursor = -239, - DesktopSize = -223 - }; - - supportCursor = false; - - if (encodingsPending && (unsigned)client->bytesAvailable() >= - encodingsPending * sizeof(quint32)) { - for (int i = 0; i < encodingsPending; ++i) { - qint32 enc; - client->read((char *)&enc, sizeof(qint32)); - enc = ntohl(enc); -#ifdef QT_QWS_VNC_DEBUG - qDebug("QVNCServer::setEncodings: %d", enc); -#endif - switch (enc) { - case Raw: - if (!encoder) { - encoder = new QRfbRawEncoder(this); -#ifdef QT_QWS_VNC_DEBUG - qDebug("QVNCServer::setEncodings: using raw"); -#endif - } - break; - case CopyRect: - supportCopyRect = true; - break; - case RRE: - supportRRE = true; - break; - case CoRRE: - supportCoRRE = true; - break; - case Hextile: - supportHextile = true; - if (encoder) - break; - switch (qvnc_screen->depth()) { -#ifdef QT_QWS_DEPTH_8 - case 8: - encoder = new QRfbHextileEncoder(this); - break; -#endif -#ifdef QT_QWS_DEPTH_12 - case 12: - encoder = new QRfbHextileEncoder(this); - break; -#endif -#ifdef QT_QWS_DEPTH_15 - case 15: - encoder = new QRfbHextileEncoder(this); - break; -#endif -#ifdef QT_QWS_DEPTH_16 - case 16: - encoder = new QRfbHextileEncoder(this); - break; -#endif -#ifdef QT_QWS_DEPTH_18 - case 18: - encoder = new QRfbHextileEncoder(this); - break; -#endif -#ifdef QT_QWS_DEPTH_24 - case 24: - encoder = new QRfbHextileEncoder(this); - break; -#endif -#ifdef QT_QWS_DEPTH_32 - case 32: - encoder = new QRfbHextileEncoder(this); - break; -#endif - default: - break; - } -#ifdef QT_QWS_VNC_DEBUG - qDebug("QVNCServer::setEncodings: using hextile"); -#endif - break; - case ZRLE: - supportZRLE = true; - break; - case Cursor: - supportCursor = true; -#ifndef QT_NO_QWS_CURSOR - if (!qvnc_screen->screen() || qt_screencursor->isAccelerated()) { - delete qvnc_cursor; - qvnc_cursor = new QVNCClientCursor(this); - } -#endif - break; - case DesktopSize: - supportDesktopSize = true; - break; - default: - break; - } - } - handleMsg = false; - encodingsPending = 0; - } - - if (!encoder) { - encoder = new QRfbRawEncoder(this); -#ifdef QT_QWS_VNC_DEBUG - qDebug("QVNCServer::setEncodings: fallback using raw"); -#endif - } - - if (cursor) - cursor->setCursorMode(supportCursor); -} - -void QVNCServer::frameBufferUpdateRequest() -{ - QRfbFrameBufferUpdateRequest ev; - - if (ev.read(client)) { - if (!ev.incremental) { - QRect r(ev.rect.x, ev.rect.y, ev.rect.w, ev.rect.h); -////### r.translate(qvnc_screen->offset()); - qvnc_screen->d_ptr->setDirty(r, true); - } - wantUpdate = true; - checkUpdate(); - handleMsg = false; - } -} - -static bool buttonChange(Qt::MouseButtons before, Qt::MouseButtons after, Qt::MouseButton *button, bool *isPress) -{ - if (before == after) - return false; - for (int b = Qt::LeftButton; b <= Qt::MidButton; b<<=1) { - if ((before & b) != (after & b)) { - *button = static_cast(b); - *isPress = (after & b); - return true; - } - } - return false; -} - -void QVNCServer::pointerEvent() -{ - QRfbPointerEvent ev; - if (ev.read(client)) { -// const QPoint offset = qvnc_screen->offset(); -// QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons); - - - //qDebug() << "pointerEvent" << ev.x << ev.y << hex << ev.buttons; - if (ev.wheelDirection == ev.WheelNone) { - QEvent::Type type = QEvent::MouseMove; - Qt::MouseButton button = Qt::NoButton; - bool isPress; - if (buttonChange(buttons, ev.buttons, &button, &isPress)) - type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - QWindowSystemInterface::handleMouseEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), ev.buttons); - } else { - // No buttons or motion reported at the same time as wheel events - Qt::Orientation orientation; - if (ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelRight) - orientation = Qt::Horizontal; - else - orientation = Qt::Vertical; - int delta = 120 * ((ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelUp) ? 1 : -1); - QWindowSystemInterface::handleWheelEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), delta, orientation); - } - handleMsg = false; - } -} - -void QVNCServer::keyEvent() -{ - QRfbKeyEvent ev; - - if (ev.read(client)) { - if (ev.keycode == Qt::Key_Shift) - keymod = ev.down ? keymod | Qt::ShiftModifier : - keymod & ~Qt::ShiftModifier; - else if (ev.keycode == Qt::Key_Control) - keymod = ev.down ? keymod | Qt::ControlModifier : - keymod & ~Qt::ControlModifier; - else if (ev.keycode == Qt::Key_Alt) - keymod = ev.down ? keymod | Qt::AltModifier : - keymod & ~Qt::AltModifier; - if (ev.unicode || ev.keycode) { -// qDebug() << "keyEvent" << hex << ev.unicode << ev.keycode << keymod << ev.down; - QEvent::Type type = ev.down ? QEvent::KeyPress : QEvent::KeyRelease; - QString str; - if (ev.unicode && ev.unicode != 0xffff) - str = QString(ev.unicode); - QWindowSystemInterface::handleKeyEvent(0, type, ev.keycode, keymod, str); - } - handleMsg = false; - } -} - -void QVNCServer::clientCutText() -{ - QRfbClientCutText ev; - - if (ev.read(client)) { - cutTextPending = ev.length; - if (!cutTextPending) - handleMsg = false; - } - - if (cutTextPending && client->bytesAvailable() >= cutTextPending) { - char *text = new char [cutTextPending+1]; - client->read(text, cutTextPending); - delete [] text; - cutTextPending = 0; - handleMsg = false; - } -} - -// stride in bytes -template -bool QRfbSingleColorHextile::read(const uchar *data, - int width, int height, int stride) -{ - const int depth = encoder->server->screen()->depth(); - if (width % (depth / 8)) // hw: should rather fallback to simple loop - return false; - - static int alwaysFalse = qgetenv("QT_VNC_NOCHECKFILL").toInt(); - if (alwaysFalse) - return false; - - switch (depth) { - case 4: { - const quint8 *data8 = reinterpret_cast(data); - if ((data8[0] & 0xf) != (data8[0] >> 4)) - return false; - width /= 2; - } // fallthrough - case 8: { - const quint8 *data8 = reinterpret_cast(data); - if (data8[0] != data8[1]) - return false; - width /= 2; - } // fallthrough - case 12: - case 15: - case 16: { - const quint16 *data16 = reinterpret_cast(data); - if (data16[0] != data16[1]) - return false; - width /= 2; - } // fallthrough - case 18: - case 24: - case 32: { - const quint32 *data32 = reinterpret_cast(data); - const quint32 first = data32[0]; - const int linestep = (stride / sizeof(quint32)) - width; - for (int y = 0; y < height; ++y) { - for (int x = 0; x < width; ++x) { - if (*(data32++) != first) - return false; - } - data32 += linestep; - } - break; - } - default: - return false; - } - - SRC color = reinterpret_cast(data)[0]; - encoder->newBg |= (color != encoder->bg); - encoder->bg = color; - return true; -} - -template -void QRfbSingleColorHextile::write(QTcpSocket *socket) const -{ - if (true || encoder->newBg) { - const int bpp = encoder->server->clientBytesPerPixel(); - const int padding = 3; - QVarLengthArray buffer(padding + 1 + bpp); - buffer[padding] = 2; // BackgroundSpecified - encoder->server->convertPixels(buffer.data() + padding + 1, - reinterpret_cast(&encoder->bg), - 1); - socket->write(buffer.data() + padding, bpp + 1); -// encoder->newBg = false; - } else { - char subenc = 0; - socket->write(&subenc, 1); - } -} - -template -bool QRfbDualColorHextile::read(const uchar *data, - int width, int height, int stride) -{ - const SRC *ptr = reinterpret_cast(data); - const int linestep = (stride / sizeof(SRC)) - width; - - SRC c1; - SRC c2 = 0; - int n1 = 0; - int n2 = 0; - int x = 0; - int y = 0; - - c1 = *ptr; - - // find second color - while (y < height) { - while (x < width) { - if (*ptr == c1) { - ++n1; - } else { - c2 = *ptr; - goto found_second_color; - } - ++ptr; - ++x; - } - x = 0; - ptr += linestep; - ++y; - } - -found_second_color: - // finish counting - while (y < height) { - while (x < width) { - if (*ptr == c1) { - ++n1; - } else if (*ptr == c2) { - ++n2; - } else { - return false; - } - ++ptr; - ++x; - } - x = 0; - ptr += linestep; - ++y; - } - - if (n2 > n1) { - const quint32 tmpC = c1; - c1 = c2; - c2 = tmpC; - } - - encoder->newBg |= (c1 != encoder->bg); - encoder->newFg |= (c2 != encoder->fg); - - encoder->bg = c1; - encoder->fg = c2; - - // create map - bool inRect = false; - numRects = 0; - ptr = reinterpret_cast(data); - for (y = 0; y < height; ++y) { - for (x = 0; x < width; ++x) { - if (inRect && *ptr == encoder->bg) { - // rect finished - setWidth(x - lastx()); - next(); - inRect = false; - } else if (!inRect && *ptr == encoder->fg) { - // rect start - setX(x); - setY(y); - setHeight(1); - inRect = true; - } - ++ptr; - } - if (inRect) { - // finish rect - setWidth(width - lastx()); - next(); - inRect = false; - } - ptr += linestep; - } - - return true; -} - -template -void QRfbDualColorHextile::write(QTcpSocket *socket) const -{ - const int bpp = encoder->server->clientBytesPerPixel(); - const int padding = 3; - QVarLengthArray buffer(padding + 2 * bpp + sizeof(char) + sizeof(numRects)); - char &subenc = buffer[padding]; - int n = padding + sizeof(subenc); - - subenc = 0x8; // AnySubrects - - if (encoder->newBg) { - subenc |= 0x2; // Background - encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->bg, 1); - n += bpp; -// encoder->newBg = false; - } - - if (encoder->newFg) { - subenc |= 0x4; // Foreground - encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->fg, 1); - n += bpp; -// encoder->newFg = false; - } - buffer[n] = numRects; - n += sizeof(numRects); - - socket->write(buffer.data() + padding, n - padding); - socket->write((char*)rects, numRects * sizeof(Rect)); -} - -template -void QRfbDualColorHextile::next() -{ - for (int r = numRects - 1; r >= 0; --r) { - if (recty(r) == lasty()) - continue; - if (recty(r) < lasty() - 1) // only search previous scanline - break; - if (rectx(r) == lastx() && width(r) == width(numRects)) { - ++rects[r].wh; - return; - } - } - ++numRects; -} - -template -inline void QRfbMultiColorHextile::setColor(SRC color) -{ - encoder->server->convertPixels(reinterpret_cast(rect(numRects)), - (const char*)&color, 1); -} - -template -inline bool QRfbMultiColorHextile::beginRect() -{ - if ((rects.size() + bpp + 2) > maxRectsSize) - return false; - rects.resize(rects.size() + bpp + 2); - return true; -} - -template -inline void QRfbMultiColorHextile::endRect() -{ - setHeight(numRects, 1); - ++numRects; -} - -template -bool QRfbMultiColorHextile::read(const uchar *data, - int width, int height, int stride) -{ - const SRC *ptr = reinterpret_cast(data); - const int linestep = (stride / sizeof(SRC)) - width; - - bpp = encoder->server->clientBytesPerPixel(); - - if (encoder->newBg) - encoder->bg = ptr[0]; - - const SRC bg = encoder->bg; - SRC color = bg; - bool inRect = false; - - numRects = 0; - rects.clear(); - - for (int y = 0; y < height; ++y) { - for (int x = 0; x < width; ++x) { - if (inRect && *ptr != color) { // end rect - setWidth(numRects, x - rectx(numRects)); - endRect(); - inRect = false; - } - - if (!inRect && *ptr != bg) { // begin rect - if (!beginRect()) - return false; - inRect = true; - color = *ptr; - setColor(color); - setX(numRects, x); - setY(numRects, y); - } - ++ptr; - } - if (inRect) { // end rect - setWidth(numRects, width - rectx(numRects)); - endRect(); - inRect = false; - } - ptr += linestep; - } - - return true; -} - -template -void QRfbMultiColorHextile::write(QTcpSocket *socket) const -{ - const int padding = 3; - QVarLengthArray buffer(bpp + padding + sizeof(quint8) + sizeof(numRects)); - - quint8 &subenc = buffer[padding]; - int n = padding + sizeof(quint8); - - subenc = 8 | 16; // AnySubrects | SubrectsColoured - - if (encoder->newBg) { - subenc |= 0x2; // Background - encoder->server->convertPixels(reinterpret_cast(buffer.data() + n), - reinterpret_cast(&encoder->bg), - 1); - n += bpp; -// encoder->newBg = false; - } - - buffer[n] = numRects; - n += sizeof(numRects); - - socket->write(reinterpret_cast(buffer.data() + padding), - n - padding); - socket->write(reinterpret_cast(rects.constData()), - rects.size()); -} - -bool QVNCServer::pixelConversionNeeded() const -{ - if (!sameEndian) - return true; - -#if Q_BYTE_ORDER == Q_BIG_ENDIAN - if (qvnc_screen->swapBytes()) - return true; -#endif - - const int screendepth = qvnc_screen->depth(); - if (screendepth != pixelFormat.bitsPerPixel) - return true; - - switch (screendepth) { - case 32: - case 24: - return false; - case 18: - return (pixelFormat.redBits == 6 - && pixelFormat.greenBits == 6 - && pixelFormat.blueBits == 6); - case 16: - return (pixelFormat.redBits == 5 - && pixelFormat.greenBits == 6 - && pixelFormat.blueBits == 5); - case 15: - return (pixelFormat.redBits == 5 - && pixelFormat.greenBits == 5 - && pixelFormat.blueBits == 5); - case 12: - return (pixelFormat.redBits == 4 - && pixelFormat.greenBits == 4 - && pixelFormat.blueBits == 4); - } - return true; -} - -// count: number of pixels -void QVNCServer::convertPixels(char *dst, const char *src, int count) const -{ - const int screendepth = qvnc_screen->depth(); - const bool isBgr = false; //### qvnc_screen->pixelType() == QScreen::BGRPixel; - - // cutoffs -#if Q_BYTE_ORDER == Q_BIG_ENDIAN - if (!swapBytes) -#endif - if (sameEndian) { - if (screendepth == pixelFormat.bitsPerPixel) { // memcpy cutoffs - - switch (screendepth) { - case 32: - memcpy(dst, src, count * sizeof(quint32)); - return; - case 16: - if (pixelFormat.redBits == 5 - && pixelFormat.greenBits == 6 - && pixelFormat.blueBits == 5) - { - memcpy(dst, src, count * sizeof(quint16)); - return; - } - } - } else if (screendepth == 16 && pixelFormat.bitsPerPixel == 32) { -#if defined(__i386__) // Currently fails on ARM if dst is not 4 byte aligned - const quint32 *src32 = reinterpret_cast(src); - quint32 *dst32 = reinterpret_cast(dst); - int count32 = count * sizeof(quint16) / sizeof(quint32); - while (count32--) { - const quint32 s = *src32++; - quint32 result1; - quint32 result2; - - // red - result1 = ((s & 0xf8000000) | ((s & 0xe0000000) >> 5)) >> 8; - result2 = ((s & 0x0000f800) | ((s & 0x0000e000) >> 5)) << 8; - - // green - result1 |= ((s & 0x07e00000) | ((s & 0x06000000) >> 6)) >> 11; - result2 |= ((s & 0x000007e0) | ((s & 0x00000600) >> 6)) << 5; - - // blue - result1 |= ((s & 0x001f0000) | ((s & 0x001c0000) >> 5)) >> 13; - result2 |= ((s & 0x0000001f) | ((s & 0x0000001c) >> 5)) << 3; - - *dst32++ = result2; - *dst32++ = result1; - } - if (count & 0x1) { - const quint16 *src16 = reinterpret_cast(src); - dst32[count - 1] = qt_conv16ToRgb(src16[count - 1]); - } - return; -#endif - } - } - - const int bytesPerPixel = (pixelFormat.bitsPerPixel + 7) / 8; - -// nibble = 0; - - for (int i = 0; i < count; ++i) { - int r, g, b; - - switch (screendepth) { -#if 0 - case 4: { - if (!nibble) { - r = ((*src) & 0x0f) << 4; - } else { - r = (*src) & 0xf0; - src++; - } - nibble = !nibble; - g = b = r; - break; - } -#endif -#if 0 - case 8: { - QRgb rgb = qvnc_screen->clut()[int(*src)]; - r = qRed(rgb); - g = qGreen(rgb); - b = qBlue(rgb); - src++; - break; - } -#endif -#ifdef QT_QWS_DEPTH_12 - case 12: { - quint32 p = quint32(*reinterpret_cast(src)); - r = qRed(p); - g = qGreen(p); - b = qBlue(p); - src += sizeof(qrgb444); - break; - } -#endif -#ifdef QT_QWS_DEPTH_15 - case 15: { - quint32 p = quint32(*reinterpret_cast(src)); - r = qRed(p); - g = qGreen(p); - b = qBlue(p); - src += sizeof(qrgb555); - break; - } -#endif - case 16: { - quint16 p = *reinterpret_cast(src); -#if Q_BYTE_ORDER == Q_BIG_ENDIAN - if (swapBytes) - p = ((p & 0xff) << 8) | ((p & 0xff00) >> 8); -#endif - r = (p >> 11) & 0x1f; - g = (p >> 5) & 0x3f; - b = p & 0x1f; - r <<= 3; - g <<= 2; - b <<= 3; - src += sizeof(quint16); - break; - } -#ifdef QT_QWS_DEPTH_18 - case 18: { - quint32 p = quint32(*reinterpret_cast(src)); - r = qRed(p); - g = qGreen(p); - b = qBlue(p); - src += sizeof(qrgb666); - break; - } -#endif -#ifdef QT_QWS_DEPTH_24 - case 24: { - quint32 p = quint32(*reinterpret_cast(src)); - r = qRed(p); - g = qGreen(p); - b = qBlue(p); - src += sizeof(qrgb888); - break; - } -#endif - case 32: { - quint32 p = *reinterpret_cast(src); - r = (p >> 16) & 0xff; - g = (p >> 8) & 0xff; - b = p & 0xff; - src += sizeof(quint32); - break; - } - default: { - r = g = b = 0; - qDebug("QVNCServer: don't support %dbpp display", screendepth); - return; - } - } - -#if Q_BYTE_ORDER == Q_BIG_ENDIAN - if (swapBytes ^ isBgr) -#else - if (isBgr) -#endif - qSwap(r, b); - - r >>= (8 - pixelFormat.redBits); - g >>= (8 - pixelFormat.greenBits); - b >>= (8 - pixelFormat.blueBits); - - int pixel = (r << pixelFormat.redShift) | - (g << pixelFormat.greenShift) | - (b << pixelFormat.blueShift); - - if (sameEndian || pixelFormat.bitsPerPixel == 8) { - memcpy(dst, &pixel, bytesPerPixel); // XXX: do a simple for-loop instead? - dst += bytesPerPixel; - continue; - } - - - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - switch (pixelFormat.bitsPerPixel) { - case 16: - pixel = (((pixel & 0x0000ff00) << 8) | - ((pixel & 0x000000ff) << 24)); - break; - case 32: - pixel = (((pixel & 0xff000000) >> 24) | - ((pixel & 0x00ff0000) >> 8) | - ((pixel & 0x0000ff00) << 8) | - ((pixel & 0x000000ff) << 24)); - break; - default: - qDebug("Cannot handle %d bpp client", pixelFormat.bitsPerPixel); - } - } else { // QSysInfo::ByteOrder == QSysInfo::LittleEndian - switch (pixelFormat.bitsPerPixel) { - case 16: - pixel = (((pixel & 0xff000000) >> 8) | - ((pixel & 0x00ff0000) << 8)); - break; - case 32: - pixel = (((pixel & 0xff000000) >> 24) | - ((pixel & 0x00ff0000) >> 8) | - ((pixel & 0x0000ff00) << 8) | - ((pixel & 0x000000ff) << 24)); - break; - default: - qDebug("Cannot handle %d bpp client", - pixelFormat.bitsPerPixel); - break; - } - } - memcpy(dst, &pixel, bytesPerPixel); // XXX: simple for-loop instead? - dst += bytesPerPixel; - } -} - -#ifndef QT_NO_QWS_CURSOR -static void blendCursor(QImage &image, const QRect &imageRect) -{ - const QRect cursorRect = qt_screencursor->boundingRect(); - const QRect intersection = (cursorRect & imageRect); - const QRect destRect = intersection.translated(-imageRect.topLeft()); - const QRect srcRect = intersection.translated(-cursorRect.topLeft()); - - QPainter painter(&image); - painter.drawImage(destRect, qt_screencursor->image(), srcRect); - painter.end(); -} -#endif // QT_NO_QWS_CURSOR - -QVNCDirtyMap::QVNCDirtyMap(QVNCGraphicsSystemScreen *s) - : bytesPerPixel(0), numDirty(0), screen(s) -{ - bytesPerPixel = (screen->depth() + 7) / 8; - QSize screenSize = screen->geometry().size(); - bufferWidth = screenSize.width(); - bufferHeight = screenSize.height(); - bufferStride = bufferWidth * bytesPerPixel; - buffer = new uchar[bufferHeight * bufferStride]; - - mapWidth = (bufferWidth + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE; - mapHeight = (bufferHeight + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE; - numTiles = mapWidth * mapHeight; - map = new uchar[numTiles]; -} - -QVNCDirtyMap::~QVNCDirtyMap() -{ - delete[] map; - delete[] buffer; -} - -void QVNCDirtyMap::reset() -{ - memset(map, 1, numTiles); - memset(buffer, 0, bufferHeight * bufferStride); - numDirty = numTiles; -} - -inline bool QVNCDirtyMap::dirty(int x, int y) const -{ - return map[y * mapWidth + x]; -} - -inline void QVNCDirtyMap::setClean(int x, int y) -{ - map[y * mapWidth + x] = 0; - --numDirty; -} - -template -void QVNCDirtyMapOptimized::setDirty(int tileX, int tileY, bool force) -{ - static bool alwaysForce = qgetenv("QT_VNC_NO_COMPAREBUFFER").toInt(); - if (alwaysForce) - force = true; - - bool changed = false; - - if (!force) { - const int lstep = screen->linestep(); - const int startX = tileX * MAP_TILE_SIZE; - const int startY = tileY * MAP_TILE_SIZE; - const uchar *scrn = screen->base() - + startY * lstep + startX * bytesPerPixel; - uchar *old = buffer + startY * bufferStride + startX * sizeof(T); - - const int tileHeight = (startY + MAP_TILE_SIZE > bufferHeight ? - bufferHeight - startY : MAP_TILE_SIZE); - const int tileWidth = (startX + MAP_TILE_SIZE > bufferWidth ? - bufferWidth - startX : MAP_TILE_SIZE); - const bool doInlines = (tileWidth == MAP_TILE_SIZE); - - int y = tileHeight; - - if (doInlines) { // hw: memcmp/memcpy is inlined when using constants - while (y) { - if (memcmp(old, scrn, sizeof(T) * MAP_TILE_SIZE)) { - changed = true; - break; - } - scrn += lstep; - old += bufferStride; - --y; - } - - while (y) { - memcpy(old, scrn, sizeof(T) * MAP_TILE_SIZE); - scrn += lstep; - old += bufferStride; - --y; - } - } else { - while (y) { - if (memcmp(old, scrn, sizeof(T) * tileWidth)) { - changed = true; - break; - } - scrn += lstep; - old += bufferStride; - --y; - } - - while (y) { - memcpy(old, scrn, sizeof(T) * tileWidth); - scrn += lstep; - old += bufferStride; - --y; - } - } - } - - const int mapIndex = tileY * mapWidth + tileX; - if ((force || changed) && !map[mapIndex]) { - map[mapIndex] = 1; - ++numDirty; - } -} - -template -QRfbHextileEncoder::QRfbHextileEncoder(QVNCServer *s) - : QRfbEncoder(s), - singleColorHextile(this), dualColorHextile(this), multiColorHextile(this) -{ -} - -/* - \internal - Send dirty rects using hextile encoding. -*/ -template -void QRfbHextileEncoder::write() -{ -// QWSDisplay::grab(true); - - QVNCDirtyMap *map = server->dirtyMap(); - QTcpSocket *socket = server->clientSocket(); - - const quint32 encoding = htonl(5); // hextile encoding - const int bytesPerPixel = server->clientBytesPerPixel(); - - { - const char tmp[2] = { 0, 0 }; // msg type, padding - socket->write(tmp, sizeof(tmp)); - } - { - const quint16 count = htons(map->numDirty); - socket->write((char *)&count, sizeof(count)); - } - - if (map->numDirty <= 0) { -// QWSDisplay::ungrab(); - return; - } - - newBg = true; - newFg = true; - - const QImage screenImage = server->screenImage(); - QRfbRect rect(0, 0, MAP_TILE_SIZE, MAP_TILE_SIZE); - - QSize screenSize = server->screen()->geometry().size(); - - for (int y = 0; y < map->mapHeight; ++y) { - if (rect.y + MAP_TILE_SIZE > screenSize.height()) - rect.h = screenSize.height() - rect.y; - rect.w = MAP_TILE_SIZE; - for (int x = 0; x < map->mapWidth; ++x) { - if (!map->dirty(x, y)) - continue; - map->setClean(x, y); - - rect.x = x * MAP_TILE_SIZE; - if (rect.x + MAP_TILE_SIZE > screenSize.width()) //###deviceWidth ??? - rect.w = screenSize.width() - rect.x; - rect.write(socket); - - socket->write((char *)&encoding, sizeof(encoding)); - - const uchar *screendata = screenImage.scanLine(rect.y) - + rect.x * screenImage.depth() / 8; - int linestep = screenImage.bytesPerLine(); - -#ifndef QT_NO_QWS_CURSOR - // hardware cursors must be blended with the screen memory - const bool doBlendCursor = qt_screencursor - && !server->hasClientCursor() - && qt_screencursor->isAccelerated(); - QImage tileImage; - if (doBlendCursor) { - const QRect tileRect(rect.x, rect.y, rect.w, rect.h); - const QRect cursorRect = qt_screencursor->boundingRect() - .translated(-server->screen()->offset()); - if (tileRect.intersects(cursorRect)) { - tileImage = screenImage.copy(tileRect); - blendCursor(tileImage, - tileRect.translated(server->screen()->offset())); - screendata = tileImage.bits(); - linestep = tileImage.bytesPerLine(); - } - } -#endif // QT_NO_QWS_CURSOR - - if (singleColorHextile.read(screendata, rect.w, rect.h, linestep)) { - singleColorHextile.write(socket); - } else if (dualColorHextile.read(screendata, rect.w, rect.h, linestep)) { - dualColorHextile.write(socket); - } else if (multiColorHextile.read(screendata, rect.w, rect.h, linestep)) { - multiColorHextile.write(socket); - } else if (server->doPixelConversion()) { - const int bufferSize = rect.w * rect.h * bytesPerPixel + 1; - const int padding = sizeof(quint32) - sizeof(char); - buffer.resize(bufferSize + padding); - - buffer[padding] = 1; // Raw subencoding - - // convert pixels - char *b = buffer.data() + padding + 1; - const int bstep = rect.w * bytesPerPixel; - for (int i = 0; i < rect.h; ++i) { - server->convertPixels(b, (const char*)screendata, rect.w); - screendata += linestep; - b += bstep; - } - socket->write(buffer.constData() + padding, bufferSize); - } else { - quint8 subenc = 1; // Raw subencoding - socket->write((char *)&subenc, 1); - - // send pixels - for (int i = 0; i < rect.h; ++i) { - socket->write((const char*)screendata, - rect.w * bytesPerPixel); - screendata += linestep; - } - } - } - if (socket->state() == QAbstractSocket::UnconnectedState) - break; - rect.y += MAP_TILE_SIZE; - } - socket->flush(); - Q_ASSERT(map->numDirty == 0); - -// QWSDisplay::ungrab(); -} - -void QRfbRawEncoder::write() -{ -// QWSDisplay::grab(false); - - QVNCDirtyMap *map = server->dirtyMap(); - QTcpSocket *socket = server->clientSocket(); - - const int bytesPerPixel = server->clientBytesPerPixel(); - QSize screenSize = server->screen()->geometry().size(); - - // create a region from the dirty rects and send the region's merged rects. - QRegion rgn; - if (map) { - for (int y = 0; y < map->mapHeight; ++y) { - for (int x = 0; x < map->mapWidth; ++x) { - if (!map->dirty(x, y)) - continue; - rgn += QRect(x * MAP_TILE_SIZE, y * MAP_TILE_SIZE, - MAP_TILE_SIZE, MAP_TILE_SIZE); - map->setClean(x, y); - } - } - - rgn &= QRect(0, 0, screenSize.width(), - screenSize.height()); - } - const QVector rects = rgn.rects(); - - { - const char tmp[2] = { 0, 0 }; // msg type, padding - socket->write(tmp, sizeof(tmp)); - } - - { - const quint16 count = htons(rects.size()); - socket->write((char *)&count, sizeof(count)); - } - - if (rects.size() <= 0) { -// QWSDisplay::ungrab(); - return; - } - - const QImage *screenImage = server->screenImage(); - - for (int i = 0; i < rects.size(); ++i) { - const QRect tileRect = rects.at(i); - const QRfbRect rect(tileRect.x(), tileRect.y(), - tileRect.width(), tileRect.height()); - rect.write(socket); - - const quint32 encoding = htonl(0); // raw encoding - socket->write((char *)&encoding, sizeof(encoding)); - - int linestep = screenImage->bytesPerLine(); - const uchar *screendata = screenImage->scanLine(rect.y) - + rect.x * screenImage->depth() / 8; - -#ifndef QT_NO_QWS_CURSOR - // hardware cursors must be blended with the screen memory - const bool doBlendCursor = qt_screencursor - && !server->hasClientCursor() - && qt_screencursor->isAccelerated(); - QImage tileImage; - if (doBlendCursor) { - const QRect cursorRect = qt_screencursor->boundingRect() - .translated(-server->screen()->offset()); - if (tileRect.intersects(cursorRect)) { - tileImage = screenImage->copy(tileRect); - blendCursor(tileImage, - tileRect.translated(server->screen()->offset())); - screendata = tileImage.bits(); - linestep = tileImage.bytesPerLine(); - } - } -#endif // QT_NO_QWS_CURSOR - - if (server->doPixelConversion()) { - const int bufferSize = rect.w * rect.h * bytesPerPixel; - if (bufferSize > buffer.size()) - buffer.resize(bufferSize); - - // convert pixels - char *b = buffer.data(); - const int bstep = rect.w * bytesPerPixel; - for (int i = 0; i < rect.h; ++i) { - server->convertPixels(b, (const char*)screendata, rect.w); - screendata += linestep; - b += bstep; - } - socket->write(buffer.constData(), bufferSize); - } else { - for (int i = 0; i < rect.h; ++i) { - socket->write((const char*)screendata, rect.w * bytesPerPixel); - screendata += linestep; - } - } - if (socket->state() == QAbstractSocket::UnconnectedState) - break; - } - socket->flush(); - -// QWSDisplay::ungrab(); -} - -inline QImage *QVNCServer::screenImage() const -{ - return qvnc_screen->image(); -} - -void QVNCServer::checkUpdate() -{ - if (!wantUpdate) - return; - - if (dirtyCursor) { -#ifndef QT_NO_QWS_CURSOR - Q_ASSERT(qvnc_cursor); - qvnc_cursor->write(); -#endif - cursor->sendClientCursor(); - dirtyCursor = false; - wantUpdate = false; - return; - } - - if (dirtyMap()->numDirty > 0) { - if (encoder) - encoder->write(); - wantUpdate = false; - } -} - -void QVNCServer::discardClient() -{ - timer->stop(); - state = Unconnected; - delete encoder; - encoder = 0; -#ifndef QT_NO_QWS_CURSOR - delete qvnc_cursor; - qvnc_cursor = 0; -#endif -// if (!qvnc_screen->screen()) -// QWSServer::instance()->enablePainting(false); -} - - - -QVNCGraphicsSystemScreenPrivate::QVNCGraphicsSystemScreenPrivate(QVNCGraphicsSystemScreen *parent) - : dpiX(72), dpiY(72), doOnScreenSurface(false), refreshRate(25), - vncServer(0), q_ptr(parent) -{ -#if 0//ndef QT_NO_QWS_SIGNALHANDLER - QWSSignalHandler::instance()->addObject(this); -#endif - - vncServer = new QVNCServer(q_ptr); - vncServer->setRefreshRate(refreshRate); - - - Q_ASSERT(q_ptr->depth() == 32); - - dirty = new QVNCDirtyMapOptimized(q_ptr); -} - -QVNCGraphicsSystemScreenPrivate::~QVNCGraphicsSystemScreenPrivate() -{ -} - - -void QVNCGraphicsSystemScreenPrivate::setDirty(const QRect& rect, bool force) -{ - if (rect.isEmpty()) - return; - -// if (q_ptr->screen()) -// q_ptr->screen()->setDirty(rect); - - if (!vncServer || !vncServer->isConnected()) { -// qDebug() << "QVNCGraphicsSystemScreenPrivate::setDirty() - Not connected"; - return; - } - const QRect r = rect; // .translated(-q_ptr->offset()); - const int x1 = r.x() / MAP_TILE_SIZE; - int y = r.y() / MAP_TILE_SIZE; - for (; (y <= r.bottom() / MAP_TILE_SIZE) && y < dirty->mapHeight; y++) - for (int x = x1; (x <= r.right() / MAP_TILE_SIZE) && x < dirty->mapWidth; x++) - dirty->setDirty(x, y, force); - - vncServer->setDirty(); -} - - - - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/vnc/qvncserver.h b/src/plugins/graphicssystems/vnc/qvncserver.h deleted file mode 100644 index 4fcdbae..0000000 --- a/src/plugins/graphicssystems/vnc/qvncserver.h +++ /dev/null @@ -1,534 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSCREENVNC_P_H -#define QSCREENVNC_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of the QLibrary class. This header file may change from version to version -// without notice, or even be removed. -// -// We mean it. -// - -#include "qgraphicssystem_vnc.h" -#include "qvnccursor.h" -#define QT_NO_QWS_CURSOR - -#ifndef QT_NO_QWS_VNC - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QVNCServer; - -#ifndef QT_NO_QWS_CURSOR -class QVNCCursor : public QProxyScreenCursor -{ -public: - QVNCCursor(QVNCGraphicsSystemScreen *s); - ~QVNCCursor(); - - void hide(); - void show(); - void set(const QImage &image, int hotx, int hoty); - void move(int x, int y); - -private: - void setDirty(const QRect &r) const; - QVNCGraphicsSystemScreen *screen; -}; - -class QVNCClientCursor : public QProxyScreenCursor -{ -public: - QVNCClientCursor(QVNCServer *s); - ~QVNCClientCursor(); - - void set(const QImage &image, int hotx, int hoty); - void write() const; - -private: - QVNCServer *server; -}; -#endif // QT_NO_QWS_CURSOR - -#define MAP_TILE_SIZE 16 -#define MAP_WIDTH 1280 / MAP_TILE_SIZE -#define MAP_HEIGHT 1024 / MAP_TILE_SIZE - -class QVNCDirtyMap -{ -public: - QVNCDirtyMap(QVNCGraphicsSystemScreen *screen); - virtual ~QVNCDirtyMap(); - - void reset(); - bool dirty(int x, int y) const; - virtual void setDirty(int x, int y, bool force = false) = 0; - void setClean(int x, int y); - - int bytesPerPixel; - - int numDirty; - int mapWidth; - int mapHeight; - -protected: - uchar *map; - QVNCGraphicsSystemScreen *screen; - uchar *buffer; - int bufferWidth; - int bufferHeight; - int bufferStride; - int numTiles; -}; - -template -class QVNCDirtyMapOptimized : public QVNCDirtyMap -{ -public: - QVNCDirtyMapOptimized(QVNCGraphicsSystemScreen *screen) : QVNCDirtyMap(screen) {} - ~QVNCDirtyMapOptimized() {} - - void setDirty(int x, int y, bool force = false); -}; - -class QRfbRect -{ -public: - QRfbRect() {} - QRfbRect(quint16 _x, quint16 _y, quint16 _w, quint16 _h) { - x = _x; y = _y; w = _w; h = _h; - } - - void read(QTcpSocket *s); - void write(QTcpSocket *s) const; - - quint16 x; - quint16 y; - quint16 w; - quint16 h; -}; - -class QRfbPixelFormat -{ -public: - static int size() { return 16; } - - void read(QTcpSocket *s); - void write(QTcpSocket *s); - - int bitsPerPixel; - int depth; - bool bigEndian; - bool trueColor; - int redBits; - int greenBits; - int blueBits; - int redShift; - int greenShift; - int blueShift; -}; - -class QRfbServerInit -{ -public: - QRfbServerInit() { name = 0; } - ~QRfbServerInit() { delete[] name; } - - int size() const { return QRfbPixelFormat::size() + 8 + strlen(name); } - void setName(const char *n); - - void read(QTcpSocket *s); - void write(QTcpSocket *s); - - quint16 width; - quint16 height; - QRfbPixelFormat format; - char *name; -}; - -class QRfbSetEncodings -{ -public: - bool read(QTcpSocket *s); - - quint16 count; -}; - -class QRfbFrameBufferUpdateRequest -{ -public: - bool read(QTcpSocket *s); - - char incremental; - QRfbRect rect; -}; - -class QRfbKeyEvent -{ -public: - bool read(QTcpSocket *s); - - char down; - int keycode; - int unicode; -}; - -class QRfbPointerEvent -{ -public: - bool read(QTcpSocket *s); - - Qt::MouseButtons buttons; - enum { WheelNone, - WheelUp, - WheelDown, - WheelLeft, - WheelRight - } wheelDirection; - quint16 x; - quint16 y; -}; - -class QRfbClientCutText -{ -public: - bool read(QTcpSocket *s); - - quint32 length; -}; - -class QVNCGraphicsSystemScreenPrivate : public QObject -{ -public: - QVNCGraphicsSystemScreenPrivate(QVNCGraphicsSystemScreen *parent); - ~QVNCGraphicsSystemScreenPrivate(); - - void setDirty(const QRect &rect, bool force = false); - void configure(); - - qreal dpiX; - qreal dpiY; - bool doOnScreenSurface; - QVNCDirtyMap *dirty; - int refreshRate; - QVNCServer *vncServer; - -#if !defined(QT_NO_QWS_MULTIPROCESS) && !defined(QT_NO_SHAREDMEMORY) - QSharedMemory shm; -#endif - - QVNCGraphicsSystemScreen *q_ptr; -}; - -class QRfbEncoder -{ -public: - QRfbEncoder(QVNCServer *s) : server(s) {} - virtual ~QRfbEncoder() {} - - virtual void write() = 0; - -protected: - QVNCServer *server; -}; - -class QRfbRawEncoder : public QRfbEncoder -{ -public: - QRfbRawEncoder(QVNCServer *s) : QRfbEncoder(s) {} - - void write(); - -private: - QByteArray buffer; -}; - -template class QRfbHextileEncoder; - -template -class QRfbSingleColorHextile -{ -public: - QRfbSingleColorHextile(QRfbHextileEncoder *e) : encoder(e) {} - bool read(const uchar *data, int width, int height, int stride); - void write(QTcpSocket *socket) const; - -private: - QRfbHextileEncoder *encoder; -}; - -template -class QRfbDualColorHextile -{ -public: - QRfbDualColorHextile(QRfbHextileEncoder *e) : encoder(e) {} - bool read(const uchar *data, int width, int height, int stride); - void write(QTcpSocket *socket) const; - -private: - struct Rect { - quint8 xy; - quint8 wh; - } Q_PACKED rects[8 * 16]; - - quint8 numRects; - QRfbHextileEncoder *encoder; - -private: - inline int lastx() const { return rectx(numRects); } - inline int lasty() const { return recty(numRects); } - inline int rectx(int r) const { return rects[r].xy >> 4; } - inline int recty(int r) const { return rects[r].xy & 0x0f; } - inline int width(int r) const { return (rects[r].wh >> 4) + 1; } - inline int height(int r) const { return (rects[r].wh & 0x0f) + 1; } - - inline void setX(int r, int x) { - rects[r].xy = (x << 4) | (rects[r].xy & 0x0f); - } - inline void setY(int r, int y) { - rects[r].xy = (rects[r].xy & 0xf0) | y; - } - inline void setWidth(int r, int width) { - rects[r].wh = ((width - 1) << 4) | (rects[r].wh & 0x0f); - } - inline void setHeight(int r, int height) { - rects[r].wh = (rects[r].wh & 0xf0) | (height - 1); - } - - inline void setWidth(int width) { setWidth(numRects, width); } - inline void setHeight(int height) { setHeight(numRects, height); } - inline void setX(int x) { setX(numRects, x); } - inline void setY(int y) { setY(numRects, y); } - void next(); -}; - -template -class QRfbMultiColorHextile -{ -public: - QRfbMultiColorHextile(QRfbHextileEncoder *e) : encoder(e) {} - bool read(const uchar *data, int width, int height, int stride); - void write(QTcpSocket *socket) const; - -private: - inline quint8* rect(int r) { - return rects.data() + r * (bpp + 2); - } - inline const quint8* rect(int r) const { - return rects.constData() + r * (bpp + 2); - } - inline void setX(int r, int x) { - quint8 *ptr = rect(r) + bpp; - *ptr = (x << 4) | (*ptr & 0x0f); - } - inline void setY(int r, int y) { - quint8 *ptr = rect(r) + bpp; - *ptr = (*ptr & 0xf0) | y; - } - void setColor(SRC color); - inline int rectx(int r) const { - const quint8 *ptr = rect(r) + bpp; - return *ptr >> 4; - } - inline int recty(int r) const { - const quint8 *ptr = rect(r) + bpp; - return *ptr & 0x0f; - } - inline void setWidth(int r, int width) { - quint8 *ptr = rect(r) + bpp + 1; - *ptr = ((width - 1) << 4) | (*ptr & 0x0f); - } - inline void setHeight(int r, int height) { - quint8 *ptr = rect(r) + bpp + 1; - *ptr = (*ptr & 0xf0) | (height - 1); - } - - bool beginRect(); - void endRect(); - - static const int maxRectsSize = 16 * 16; - QVarLengthArray rects; - - quint8 bpp; - quint8 numRects; - QRfbHextileEncoder *encoder; -}; - -template -class QRfbHextileEncoder : public QRfbEncoder -{ -public: - QRfbHextileEncoder(QVNCServer *s); - void write(); - -private: - enum SubEncoding { - Raw = 1, - BackgroundSpecified = 2, - ForegroundSpecified = 4, - AnySubrects = 8, - SubrectsColoured = 16 - }; - - QByteArray buffer; - QRfbSingleColorHextile singleColorHextile; - QRfbDualColorHextile dualColorHextile; - QRfbMultiColorHextile multiColorHextile; - - SRC bg; - SRC fg; - bool newBg; - bool newFg; - - friend class QRfbSingleColorHextile; - friend class QRfbDualColorHextile; - friend class QRfbMultiColorHextile; -}; - -class QVNCServer : public QObject -{ - Q_OBJECT -public: - QVNCServer(QVNCGraphicsSystemScreen *screen); - QVNCServer(QVNCGraphicsSystemScreen *screen, int id); - ~QVNCServer(); - - void setDirty(); - void setDirtyCursor() { dirtyCursor = true; setDirty(); } - inline bool isConnected() const { return state == Connected; } - inline void setRefreshRate(int rate) { refreshRate = rate; } - - enum ClientMsg { SetPixelFormat = 0, - FixColourMapEntries = 1, - SetEncodings = 2, - FramebufferUpdateRequest = 3, - KeyEvent = 4, - PointerEvent = 5, - ClientCutText = 6 }; - - enum ServerMsg { FramebufferUpdate = 0, - SetColourMapEntries = 1 }; - - void convertPixels(char *dst, const char *src, int count) const; - - inline int clientBytesPerPixel() const { - return pixelFormat.bitsPerPixel / 8; - } - - inline QVNCGraphicsSystemScreen* screen() const { return qvnc_screen; } - inline QVNCDirtyMap* dirtyMap() const { return qvnc_screen->dirtyMap(); } - inline QTcpSocket* clientSocket() const { return client; } - QImage *screenImage() const; - inline bool doPixelConversion() const { return needConversion; } -#ifndef QT_NO_QWS_CURSOR - inline bool hasClientCursor() const { return qvnc_cursor != 0; } -#endif - - void setCursor(QVNCCursor * c) { cursor = c; } -private: - void setPixelFormat(); - void setEncodings(); - void frameBufferUpdateRequest(); - void pointerEvent(); - void keyEvent(); - void clientCutText(); - bool pixelConversionNeeded() const; - -private slots: - void newConnection(); - void readClient(); - void checkUpdate(); - void discardClient(); - void sendInputEvents(); - -private: - void init(uint port); - enum ClientState { Unconnected, Protocol, Init, Connected }; - QTimer *timer; - QTcpServer *serverSocket; - QTcpSocket *client; - ClientState state; - quint8 msgType; - bool handleMsg; - QRfbPixelFormat pixelFormat; - Qt::KeyboardModifiers keymod; - Qt::MouseButtons buttons; - int encodingsPending; - int cutTextPending; - uint supportCopyRect : 1; - uint supportRRE : 1; - uint supportCoRRE : 1; - uint supportHextile : 1; - uint supportZRLE : 1; - uint supportCursor : 1; - uint supportDesktopSize : 1; - bool wantUpdate; - bool sameEndian; - bool needConversion; -#if Q_BYTE_ORDER == Q_BIG_ENDIAN - bool swapBytes; -#endif - bool dirtyCursor; - int refreshRate; - QVNCGraphicsSystemScreen *qvnc_screen; -#ifndef QT_NO_QWS_CURSOR - QVNCClientCursor *qvnc_cursor; -#endif - - QRfbEncoder *encoder; - QVNCCursor *cursor; -}; - - -QT_END_NAMESPACE -#endif // QT_NO_QWS_VNC -#endif // QSCREENVNC_P_H diff --git a/src/plugins/graphicssystems/vnc/vnc.pro b/src/plugins/graphicssystems/vnc/vnc.pro deleted file mode 100644 index 0b73b5b..0000000 --- a/src/plugins/graphicssystems/vnc/vnc.pro +++ /dev/null @@ -1,19 +0,0 @@ -TARGET = qvncgraphicssystem -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - -SOURCES = main.cpp qgraphicssystem_vnc.cpp -HEADERS = qgraphicssystem_vnc.h - -HEADERS += qvncserver.h -SOURCES += qvncserver.cpp - -HEADERS += qvnccursor.h -SOURCES += qvnccursor.cpp - -include(../fb_base/fb_base.pri) - -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems - -INSTALLS += target diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp new file mode 100644 index 0000000..d30746a --- /dev/null +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -0,0 +1,364 @@ +#include "fb_base.h" + +#include +#include +#include +#include +#include + +QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen *scr) + : QGraphicsSystemCursor(scr), currentRect(QRect()), prevRect(QRect()) +{ + graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); + setCursor(Qt::ArrowCursor); +} + +QRect QGraphicsSystemSoftwareCursor::getCurrentRect() +{ + QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(), + -graphic->hotspot().y()); + rect.translate(QCursor::pos()); + return rect; +} + + +void QGraphicsSystemSoftwareCursor::pointerEvent(const QMouseEvent & e) +{ + Q_UNUSED(e); + currentRect = getCurrentRect(); + screen->setDirty(currentRect); +} + +QRect QGraphicsSystemSoftwareCursor::drawCursor(QPainter & painter) +{ + if (currentRect.isNull()) + return QRect(); + + prevRect = currentRect; + painter.drawImage(prevRect, *graphic->image()); + return prevRect; +} + +QRect QGraphicsSystemSoftwareCursor::dirtyRect() +{ + if (!prevRect.isNull()) { + QRect rect = prevRect; + prevRect = QRect(); + return rect; + } + return QRect(); +} + +void QGraphicsSystemSoftwareCursor::setCursor(Qt::CursorShape shape) +{ + graphic->set(shape); +} + +void QGraphicsSystemSoftwareCursor::setCursor(const QImage * image, int hotx, int hoty) +{ + graphic->set(image, hotx, hoty); +} + +void QGraphicsSystemSoftwareCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) +{ + graphic->set(data, mask, width, height, hotX, hotY); +} + +void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) +{ + Q_UNUSED(widget); + Qt::CursorShape shape = widgetCursor->shape(); + + if (shape == Qt::BitmapCursor) { + // application supplied cursor + QPoint spot = widgetCursor->hotSpot(); + setCursor(&widgetCursor->pixmap().toImage(), spot.x(), spot.y()); + } else { + // system cursor + setCursor(shape); + } + currentRect = getCurrentRect(); + screen->setDirty(currentRect); +} + +QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false) +{ + mScreenImage = new QImage(mGeometry.size(), mFormat); + redrawTimer.setSingleShot(true); + redrawTimer.setInterval(0); + QObject::connect(&redrawTimer, SIGNAL(timeout()), this, SLOT(doRedraw())); +} + +void QGraphicsSystemFbScreen::setGeometry(QRect rect) +{ + delete mScreenImage; + mGeometry = rect; + mScreenImage = new QImage(mGeometry.size(), mFormat); + delete compositePainter; + compositePainter = 0; + invalidateRectCache(); +} + +void QGraphicsSystemFbScreen::setDepth(int depth) +{ + mDepth = depth; +} + +void QGraphicsSystemFbScreen::setPhysicalSize(QSize size) +{ + mPhysicalSize = size; +} + +void QGraphicsSystemFbScreen::setFormat(QImage::Format format) +{ + mFormat = format; + delete mScreenImage; + mScreenImage = new QImage(mGeometry.size(), mFormat); + delete compositePainter; + compositePainter = 0; +} + +QGraphicsSystemFbScreen::~QGraphicsSystemFbScreen() +{ + delete compositePainter; + delete mScreenImage; +} + +void QGraphicsSystemFbScreen::setDirty(const QRect &rect) +{ + repaintRegion += rect; + if (!redrawTimer.isActive()) { + redrawTimer.start(); + } +} + +void QGraphicsSystemFbScreen::generateRects() +{ + cachedRects.clear(); + QRegion remainingScreen(mGeometry); + + for (int i = 0; i < windowStack.length(); i++) { + if (remainingScreen.isEmpty()) + break; + if (!windowStack[i]->window()->testAttribute(Qt::WA_TranslucentBackground)) { + remainingScreen -= windowStack[i]->geometry(); + QRegion windowRegion(windowStack[i]->geometry()); + windowRegion -= remainingScreen; + foreach(QRect rect, windowRegion.rects()) { + cachedRects += QPair(rect, i); + } + } + } + foreach (QRect rect, remainingScreen.rects()) + cachedRects += QPair(rect, -1); + isUpToDate = true; + return; +} + + + +QRegion QGraphicsSystemFbScreen::doRedraw() +{ + QRegion touchedRegion; + if (cursor) + repaintRegion += cursor->dirtyRect(); + if (repaintRegion.isEmpty()) + return touchedRegion; + + QVector rects = repaintRegion.rects(); + + if (!isUpToDate) + generateRects(); + + if (!compositePainter) + compositePainter = new QPainter(mScreenImage); + for (int rectIndex = 0; rectIndex < repaintRegion.numRects(); rectIndex++) { + QRegion rectRegion = rects[rectIndex]; + + for(int i = 0; i < cachedRects.length(); i++) { + QRect screenSubRect = cachedRects[i].first; + int layer = cachedRects[i].second; + QRegion intersect = rectRegion.intersected(screenSubRect); + + if (intersect.isEmpty()) + continue; + + rectRegion -= intersect; + + // we only expect one rectangle, but defensive coding... + foreach (QRect rect, intersect.rects()) { + bool firstLayer = true; + if (layer == -1) { + compositePainter->fillRect(rect, Qt::black); + firstLayer = false; + layer = windowStack.size() - 1; + } + + for (int layerIndex = layer; layerIndex != -1; layerIndex--) { + if (!windowStack[layerIndex]->visible()) + continue; + if (windowStack[layerIndex]->window()->isMinimized()) + continue; + QRect windowRect = windowStack[layerIndex]->geometry(); + QRect windowIntersect = rect.translated(-windowRect.left(), + -windowRect.top()); + compositePainter->drawImage(rect, windowStack[layerIndex]->image(), + windowIntersect); + if (firstLayer) { + firstLayer = false; + } + } + } + } + if (!rectRegion.isEmpty()) + qWarning() << "non-empty region!" << rectRegion; + // Everything on screen should be mapped to a sub-rectangle + // unless it's off the screen... + } + + QRect cursorRect; + if (cursor) { + cursorRect = cursor->drawCursor(*compositePainter); + touchedRegion += cursorRect; + } + touchedRegion += repaintRegion; + repaintRegion = QRegion(); + + return touchedRegion; +} + +void QGraphicsSystemFbScreen::removeWindowSurface(QGraphicsSystemFbWindowSurface * surface) +{ + windowStack.removeOne(surface); + invalidateRectCache(); + setDirty(surface->geometry()); +} + +void QGraphicsSystemFbWindowSurface::raise() +{ + mScreen->raise(this); +} + +void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) +{ + QGraphicsSystemFbWindowSurface *s = static_cast(surface); + int index = windowStack.indexOf(s); + if (index <= 0) + return; + windowStack.move(index, 0); + invalidateRectCache(); + setDirty(s->geometry()); +} + +void QGraphicsSystemFbWindowSurface::lower() +{ + mScreen->lower(this); +} + +void QGraphicsSystemFbScreen::lower(QWindowSurface * surface) +{ + QGraphicsSystemFbWindowSurface *s = static_cast(surface); + int index = windowStack.indexOf(s); + if (index == -1 || index == (windowStack.size() - 1)) + return; + windowStack.move(index, windowStack.size() - 1); + invalidateRectCache(); + setDirty(s->geometry()); +} + +QWidget * QGraphicsSystemFbScreen::topLevelAt(const QPoint & p) const +{ + for(int i = 0; i < windowStack.size(); i++) { + if (windowStack[i]->geometry().contains(p, false) && + windowStack[i]->visible() && + !windowStack[i]->window()->isMinimized()) { + return windowStack[i]->window(); + } + } + return 0; +} + +QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen), + visibleFlag(false) +{ + static QAtomicInt winIdGenerator(1); + + mImage = QImage(window->size(), mScreen->format()); + windowId = winIdGenerator.fetchAndAddRelaxed(1); +} + +QGraphicsSystemFbWindowSurface::~QGraphicsSystemFbWindowSurface() +{ + mScreen->removeWindowSurface(this); +} + +void QGraphicsSystemFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(offset); + + QRect currentGeometry = geometry(); + // If this is a move, redraw the previous location + if (oldGeometry != currentGeometry) { + mScreen->setDirty(oldGeometry); + oldGeometry = currentGeometry; + } + + QRect dirtyClient = region.boundingRect(); + QRect dirtyRegion(currentGeometry.left() + dirtyClient.left(), + currentGeometry.top() + dirtyClient.top(), + dirtyClient.width(), + dirtyClient.height()); + mScreen->setDirty(dirtyRegion); +} + +void QGraphicsSystemFbWindowSurface::setGeometry(const QRect &rect) +{ + // store previous geometry for screen update + oldGeometry = geometry(); + + // change the widget's QImage if this is a resize + if (mImage.size() != rect.size()) + mImage = QImage(rect.size(), mScreen->format()); + + mScreen->invalidateRectCache(); + QWindowSystemInterface::handleGeometryChange(window(), rect); + + QWindowSurface::setGeometry(rect); +} + +bool QGraphicsSystemFbWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QGraphicsSystemFbWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QGraphicsSystemFbWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QGraphicsSystemFbWindowSurface::setVisible(bool visible) +{ + visibleFlag = visible; + mScreen->invalidateRectCache(); + mScreen->setDirty(geometry()); +} + +Qt::WindowFlags QGraphicsSystemFbWindowSurface::setWindowFlags(Qt::WindowFlags type) +{ + flags = type; + mScreen->invalidateRectCache(); + return flags; +} + +Qt::WindowFlags QGraphicsSystemFbWindowSurface::windowFlags() const +{ + return flags; +} diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h new file mode 100644 index 0000000..7f9b005 --- /dev/null +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -0,0 +1,132 @@ +#ifndef QLIGHTHOUSEGRAPHICSSCREEN_H +#define QLIGHTHOUSEGRAPHICSSCREEN_H + +#include +#include +#include +#include +#include +#include + +class QMouseEvent; +class QSize; +class QPainter; + +class QGraphicsSystemFbScreen; + +class QGraphicsSystemSoftwareCursor : public QGraphicsSystemCursor +{ +public: + QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen * scr); + + // output methods + QRect dirtyRect(); + virtual QRect drawCursor(QPainter & painter); + + // input methods + virtual void pointerEvent(const QMouseEvent & event); + virtual void changeCursor(QCursor * widgetCursor, QWidget * widget); + +protected: + QGraphicsSystemCursorImage * graphic; + +private: + void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + void setCursor(Qt::CursorShape shape); + void setCursor(const QImage * image, int hotx, int hoty); + QRect currentRect; // next place to draw the cursor + QRect prevRect; // last place the cursor was drawn + QRect getCurrentRect(); +}; + +class QGraphicsSystemFbWindowSurface : public QWindowSurface +{ +public: + QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window); + ~QGraphicsSystemFbWindowSurface(); + + virtual QPaintDevice *paintDevice() { return &mImage; } + virtual void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + virtual bool scroll(const QRegion &area, int dx, int dy); + + virtual void beginPaint(const QRegion ®ion); + virtual void endPaint(const QRegion ®ion); + virtual void setVisible(bool visible); + virtual bool visible() { return visibleFlag; } + + const QImage image() { return mImage; } + void setGeometry(const QRect &rect); + + virtual void raise(); + virtual void lower(); + + virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); + virtual Qt::WindowFlags windowFlags() const; + + WId winId() const { return windowId; } +protected: + QGraphicsSystemFbScreen *mScreen; + QRect oldGeometry; + QImage mImage; + bool visibleFlag; + Qt::WindowFlags flags; + + WId windowId; +}; + +class QGraphicsSystemFbScreen : public QGraphicsSystemScreen +{ + Q_OBJECT +public: + QGraphicsSystemFbScreen(); + ~QGraphicsSystemFbScreen(); + + virtual QRect geometry() const { return mGeometry; } + virtual int depth() const { return mDepth; } + virtual QImage::Format format() const { return mFormat; } + virtual QSize physicalSize() const { return mPhysicalSize; } + + virtual void setGeometry(QRect rect); + virtual void setDepth(int depth); + virtual void setFormat(QImage::Format format); + virtual void setPhysicalSize(QSize size); + + virtual void setDirty(const QRect &rect); + + virtual void removeWindowSurface(QGraphicsSystemFbWindowSurface * surface); + virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { + windowStack.prepend(surface); invalidateRectCache(); } + virtual void raise(QWindowSurface * surface); + virtual void lower(QWindowSurface * surface); + virtual QWidget * topLevelAt(const QPoint & p) const; + + QImage * image() const { return mScreenImage; } + QPaintDevice * paintDevice() const { return mScreenImage; } + +protected: + QList windowStack; + QRegion repaintRegion; + QGraphicsSystemSoftwareCursor * cursor; + QTimer redrawTimer; + +protected slots: + virtual QRegion doRedraw(); + +protected: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; + QImage *mScreenImage; + +private: + QPainter * compositePainter; + void generateRects(); + QList > cachedRects; + + void invalidateRectCache() { isUpToDate = false; } + friend class QGraphicsSystemFbWindowSurface; + bool isUpToDate; +}; + +#endif // QLIGHTHOUSEGRAPHICSSCREEN_H diff --git a/src/plugins/platforms/fb_base/fb_base.pri b/src/plugins/platforms/fb_base/fb_base.pri new file mode 100644 index 0000000..41bd87f --- /dev/null +++ b/src/plugins/platforms/fb_base/fb_base.pri @@ -0,0 +1,2 @@ +SOURCES += ../fb_base/fb_base.cpp +HEADERS += ../fb_base/fb_base.h diff --git a/src/plugins/platforms/fb_base/fb_base.pro b/src/plugins/platforms/fb_base/fb_base.pro new file mode 100644 index 0000000..e08c0c5 --- /dev/null +++ b/src/plugins/platforms/fb_base/fb_base.pro @@ -0,0 +1,23 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2009-11-05T13:22:31 +# +#------------------------------------------------- + +#QT -= core gui +TARGET = fb_base +#include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +TEMPLATE = lib + +#DEFINES += STATIC_LIBRARY +CONFIG += staticlib + +SOURCES += fb_base.cpp + +HEADERS += fb_base.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro new file mode 100644 index 0000000..031b843 --- /dev/null +++ b/src/plugins/platforms/linuxfb/linuxfb.pro @@ -0,0 +1,12 @@ +TARGET = qlinuxfbgraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp qgraphicssystem_linuxfb.cpp +HEADERS = qgraphicssystem_linuxfb.h + +include(../fb_base/fb_base.pri) + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/platforms/linuxfb/main.cpp b/src/plugins/platforms/linuxfb/main.cpp new file mode 100644 index 0000000..4d03fe5 --- /dev/null +++ b/src/plugins/platforms/linuxfb/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qgraphicssystem_linuxfb.h" + +QT_BEGIN_NAMESPACE + +class QLinuxFbGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QLinuxFbGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "LinuxFb"; + return list; +} + +QGraphicsSystem* QLinuxFbGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "linuxfb") + return new QLinuxFbGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(linuxfb, QLinuxFbGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp new file mode 100644 index 0000000..44960bb --- /dev/null +++ b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp @@ -0,0 +1,856 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicssystem_linuxfb.h" +#include "../fb_base/fb_base.h" +#include +#include // overrides QT_OPEN +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if !defined(Q_OS_DARWIN) && !defined(Q_OS_FREEBSD) +#include + +#ifdef __i386__ +#include +#endif +#endif + +QT_BEGIN_NAMESPACE + +class QLinuxFbGraphicsSystemPrivate +{ +public: + QLinuxFbGraphicsSystemPrivate(); + ~QLinuxFbGraphicsSystemPrivate(); + + void openTty(); + void closeTty(); + + int fd; + int startupw; + int startuph; + int startupd; + bool blank; + + bool doGraphicsMode; +#ifdef QT_QWS_DEPTH_GENERIC + bool doGenericColors; +#endif + int ttyfd; + long oldKdMode; + QString ttyDevice; + QString displaySpec; +}; + +QLinuxFbGraphicsSystemPrivate::QLinuxFbGraphicsSystemPrivate() + : fd(-1), blank(true), doGraphicsMode(true), +#ifdef QT_QWS_DEPTH_GENERIC + doGenericColors(false), +#endif + ttyfd(-1), oldKdMode(KD_TEXT) +{ +} + +QLinuxFbGraphicsSystemPrivate::~QLinuxFbGraphicsSystemPrivate() +{ + closeTty(); +} + +void QLinuxFbGraphicsSystemPrivate::openTty() +{ + const char *const devs[] = {"/dev/tty0", "/dev/tty", "/dev/console", 0}; + + if (ttyDevice.isEmpty()) { + for (const char * const *dev = devs; *dev; ++dev) { + ttyfd = QT_OPEN(*dev, O_RDWR); + if (ttyfd != -1) + break; + } + } else { + ttyfd = QT_OPEN(ttyDevice.toAscii().constData(), O_RDWR); + } + + if (ttyfd == -1) + return; + + if (doGraphicsMode) { + ioctl(ttyfd, KDGETMODE, &oldKdMode); + if (oldKdMode != KD_GRAPHICS) { + int ret = ioctl(ttyfd, KDSETMODE, KD_GRAPHICS); + if (ret == -1) + doGraphicsMode = false; + } + } + + // No blankin' screen, no blinkin' cursor!, no cursor! + const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c"; + QT_WRITE(ttyfd, termctl, sizeof(termctl)); +} + +void QLinuxFbGraphicsSystemPrivate::closeTty() +{ + if (ttyfd == -1) + return; + + if (doGraphicsMode) + ioctl(ttyfd, KDSETMODE, oldKdMode); + + // Blankin' screen, blinkin' cursor! + const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c"; + QT_WRITE(ttyfd, termctl, sizeof(termctl)); + + QT_CLOSE(ttyfd); + ttyfd = -1; +} + +QLinuxFbGraphicsSystem::QLinuxFbGraphicsSystem() +{ + d_ptr = new QLinuxFbGraphicsSystemPrivate(); + + // XXX + QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY")); + + if (!connect(displaySpec)) + qFatal("QLinuxFbGraphicsSystem: could not initialize screen"); + initDevice(); + + // Create a QImage directly on the screen's framebuffer. + // This is the blit target for copying windows to the screen. + mPrimaryScreen = new QLinuxFbGraphicsSystemScreen(data, w, h, lstep, + screenFormat); + mPrimaryScreen->setPhysicalSize(QSize(physWidth, physHeight)); + + mScreens.append(mPrimaryScreen); +} + +QLinuxFbGraphicsSystem::~QLinuxFbGraphicsSystem() +{ + delete mPrimaryScreen; + delete d_ptr; +} + +bool QLinuxFbGraphicsSystem::connect(const QString &displaySpec) +{ + const QStringList args = displaySpec.split(QLatin1Char(':')); + + if (args.contains(QLatin1String("nographicsmodeswitch"))) + d_ptr->doGraphicsMode = false; + +#ifdef QT_QWS_DEPTH_GENERIC + if (args.contains(QLatin1String("genericcolors"))) + d_ptr->doGenericColors = true; +#endif + + QRegExp ttyRegExp(QLatin1String("tty=(.*)")); + if (args.indexOf(ttyRegExp) != -1) + d_ptr->ttyDevice = ttyRegExp.cap(1); + +#if 0 +#if Q_BYTE_ORDER == Q_BIG_ENDIAN +#ifndef QT_QWS_FRAMEBUFFER_LITTLE_ENDIAN + if (args.contains(QLatin1String("littleendian"))) +#endif + QScreen::setFrameBufferLittleEndian(true); +#endif +#endif + + // Check for explicitly specified device + const int len = 8; // "/dev/fbx" + int m = displaySpec.indexOf(QLatin1String("/dev/fb")); + + QString dev; + if (m > 0) + dev = displaySpec.mid(m, len); + else + dev = QLatin1String("/dev/fb0"); + + if (access(dev.toLatin1().constData(), R_OK|W_OK) == 0) + d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDWR); + if (d_ptr->fd == -1) { + if (access(dev.toLatin1().constData(), R_OK) == 0) + d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDONLY); + if (d_ptr->fd == 1) { + qWarning("Error opening framebuffer device %s", qPrintable(dev)); + return false; + } + } + + fb_fix_screeninfo finfo; + fb_var_screeninfo vinfo; + //####################### + // Shut up Valgrind + memset(&vinfo, 0, sizeof(vinfo)); + memset(&finfo, 0, sizeof(finfo)); + //####################### + + /* Get fixed screen information */ + if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) { + perror("QLinuxFbGraphicsSystem::connect"); + qWarning("Error reading fixed information"); + return false; + } + + if (finfo.type == FB_TYPE_VGA_PLANES) { + qWarning("VGA16 video mode not supported"); + return false; + } + + /* Get variable screen information */ + if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) { + perror("QLinuxFbGraphicsSystem::connect"); + qWarning("Error reading variable information"); + return false; + } + + grayscale = vinfo.grayscale; + d = vinfo.bits_per_pixel; + if (d == 24) { + d = vinfo.red.length + vinfo.green.length + vinfo.blue.length; + if (d <= 0) + d = 24; // reset if color component lengths are not reported + } else if (d == 16) { + d = vinfo.red.length + vinfo.green.length + vinfo.blue.length; + if (d <= 0) + d = 16; + } + lstep = finfo.line_length; + + int xoff = vinfo.xoffset; + int yoff = vinfo.yoffset; + const char* qwssize; + if((qwssize=::getenv("QWS_SIZE")) && sscanf(qwssize,"%dx%d",&w,&h)==2) { + if (d_ptr->fd != -1) { + if ((uint)w > vinfo.xres) w = vinfo.xres; + if ((uint)h > vinfo.yres) h = vinfo.yres; + } + dw=w; + dh=h; + int xxoff, yyoff; + if (sscanf(qwssize, "%*dx%*d+%d+%d", &xxoff, &yyoff) == 2) { + if (xxoff < 0 || xxoff + w > (int)(vinfo.xres)) + xxoff = vinfo.xres - w; + if (yyoff < 0 || yyoff + h > (int)(vinfo.yres)) + yyoff = vinfo.yres - h; + xoff += xxoff; + yoff += yyoff; + } else { + xoff += (vinfo.xres - w)/2; + yoff += (vinfo.yres - h)/2; + } + } else { + dw=w=vinfo.xres; + dh=h=vinfo.yres; + } + + if (w == 0 || h == 0) { + qWarning("QLinuxFbGraphicsSystem::connect(): Unable to find screen geometry, " + "will use 320x240."); + dw = w = 320; + dh = h = 240; + } + + setPixelFormat(vinfo); + + // Handle display physical size spec. + QStringList displayArgs = displaySpec.split(QLatin1Char(':')); + QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)")); + int dimIdxW = displayArgs.indexOf(mmWidthRx); + QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)")); + int dimIdxH = displayArgs.indexOf(mmHeightRx); + if (dimIdxW >= 0) { + mmWidthRx.exactMatch(displayArgs.at(dimIdxW)); + physWidth = mmWidthRx.cap(1).toInt(); + if (dimIdxH < 0) + physHeight = dh*physWidth/dw; + } + if (dimIdxH >= 0) { + mmHeightRx.exactMatch(displayArgs.at(dimIdxH)); + physHeight = mmHeightRx.cap(1).toInt(); + if (dimIdxW < 0) + physWidth = dw*physHeight/dh; + } + if (dimIdxW < 0 && dimIdxH < 0) { + if (vinfo.width != 0 && vinfo.height != 0 + && vinfo.width != UINT_MAX && vinfo.height != UINT_MAX) { + physWidth = vinfo.width; + physHeight = vinfo.height; + } else { + const int dpi = 72; + physWidth = qRound(dw * 25.4 / dpi); + physHeight = qRound(dh * 25.4 / dpi); + } + } + + dataoffset = yoff * lstep + xoff * d / 8; + //qDebug("Using %dx%dx%d screen",w,h,d); + + /* Figure out the size of the screen in bytes */ + size = h * lstep; + + mapsize = finfo.smem_len; + + data = (unsigned char *)-1; + if (d_ptr->fd != -1) + data = (unsigned char *)mmap(0, mapsize, PROT_READ | PROT_WRITE, + MAP_SHARED, d_ptr->fd, 0); + + if ((long)data == -1) { + perror("QLinuxFbGraphicsSystem::connect"); + qWarning("Error: failed to map framebuffer device to memory."); + return false; + } else { + data += dataoffset; + } + +#if 0 + canaccel = useOffscreen(); + if(canaccel) + setupOffScreen(); +#endif + canaccel = false; + + // Now read in palette + if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { + screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; + int loopc; + fb_cmap startcmap; + startcmap.start=0; + startcmap.len=screencols; + startcmap.red=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + startcmap.green=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + startcmap.blue=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + startcmap.transp=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + if (d_ptr->fd == -1 || ioctl(d_ptr->fd, FBIOGETCMAP, &startcmap)) { + perror("QLinuxFbGraphicsSystem::connect"); + qWarning("Error reading palette from framebuffer, using default palette"); + createPalette(startcmap, vinfo, finfo); + } + int bits_used = 0; + for(loopc=0;loopc> 8, + startcmap.green[loopc] >> 8, + startcmap.blue[loopc] >> 8); + bits_used |= startcmap.red[loopc] + | startcmap.green[loopc] + | startcmap.blue[loopc]; + } + // WORKAROUND: Some framebuffer drivers only return 8 bit + // color values, so we need to not bit shift them.. + if ((bits_used & 0x00ff) && !(bits_used & 0xff00)) { + for(loopc=0;loopcopenTty(); + + // Grab current mode so we can reset it + fb_var_screeninfo vinfo; + fb_fix_screeninfo finfo; + //####################### + // Shut up Valgrind + memset(&vinfo, 0, sizeof(vinfo)); + memset(&finfo, 0, sizeof(finfo)); + //####################### + + if (ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) { + perror("QLinuxFbScreen::initDevice"); + qFatal("Error reading variable information in card init"); + return false; + } + +#ifdef DEBUG_VINFO + qDebug("Greyscale %d",vinfo.grayscale); + qDebug("Nonstd %d",vinfo.nonstd); + qDebug("Red %d %d %d",vinfo.red.offset,vinfo.red.length, + vinfo.red.msb_right); + qDebug("Green %d %d %d",vinfo.green.offset,vinfo.green.length, + vinfo.green.msb_right); + qDebug("Blue %d %d %d",vinfo.blue.offset,vinfo.blue.length, + vinfo.blue.msb_right); + qDebug("Transparent %d %d %d",vinfo.transp.offset,vinfo.transp.length, + vinfo.transp.msb_right); +#endif + + d_ptr->startupw=vinfo.xres; + d_ptr->startuph=vinfo.yres; + d_ptr->startupd=vinfo.bits_per_pixel; + grayscale = vinfo.grayscale; + + if (ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) { + perror("QLinuxFbScreen::initDevice"); + qCritical("Error reading fixed information in card init"); + // It's not an /error/ as such, though definitely a bad sign + // so we return true + return true; + } + +#ifdef __i386__ + // Now init mtrr + if(!::getenv("QWS_NOMTRR")) { + int mfd=QT_OPEN("/proc/mtrr",O_WRONLY,0); + // MTRR entry goes away when file is closed - i.e. + // hopefully when QWS is killed + if(mfd != -1) { + mtrr_sentry sentry; + sentry.base=(unsigned long int)finfo.smem_start; + //qDebug("Physical framebuffer address %p",(void*)finfo.smem_start); + // Size needs to be in 4k chunks, but that's not always + // what we get thanks to graphics card registers. Write combining + // these is Not Good, so we write combine what we can + // (which is not much - 4 megs on an 8 meg card, it seems) + unsigned int size=finfo.smem_len; + size=size >> 22; + size=size << 22; + sentry.size=size; + sentry.type=MTRR_TYPE_WRCOMB; + if(ioctl(mfd,MTRRIOC_ADD_ENTRY,&sentry)==-1) { + //printf("Couldn't add mtrr entry for %lx %lx, %s\n", + //sentry.base,sentry.size,strerror(errno)); + } + } + + // Should we close mfd here? + //QT_CLOSE(mfd); + } +#endif + if ((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4) || (finfo.visual==FB_VISUAL_DIRECTCOLOR)) + { + fb_cmap cmap; + createPalette(cmap, vinfo, finfo); + if (ioctl(d_ptr->fd, FBIOPUTCMAP, &cmap)) { + perror("QLinuxFbScreen::initDevice"); + qWarning("Error writing palette to framebuffer"); + } + free(cmap.red); + free(cmap.green); + free(cmap.blue); + free(cmap.transp); + } + +#if 0 + if (canaccel) { + *entryp=0; + *lowest = mapsize; + insert_entry(*entryp, *lowest, *lowest); // dummy entry to mark start + } + + shared->fifocount = 0; + shared->buffer_offset = 0xffffffff; // 0 would be a sensible offset (screen) + shared->linestep = 0; + shared->cliptop = 0xffffffff; + shared->clipleft = 0xffffffff; + shared->clipright = 0xffffffff; + shared->clipbottom = 0xffffffff; + shared->rop = 0xffffffff; +#endif + +#ifdef QT_QWS_DEPTH_GENERIC + if (pixelFormat() == QImage::Format_Invalid && screencols == 0 + && d_ptr->doGenericColors) + { + qt_set_generic_blit(this, vinfo.bits_per_pixel, + vinfo.red.length, vinfo.green.length, + vinfo.blue.length, vinfo.transp.length, + vinfo.red.offset, vinfo.green.offset, + vinfo.blue.offset, vinfo.transp.offset); + } +#endif + +#if 0 +#ifndef QT_NO_QWS_CURSOR + QScreenCursor::initSoftwareCursor(); +#endif +#endif + blank(false); + + return true; +} + +void QLinuxFbGraphicsSystem::setPixelFormat(struct fb_var_screeninfo info) +{ + const fb_bitfield rgba[4] = { info.red, info.green, + info.blue, info.transp }; + + QImage::Format format = QImage::Format_Invalid; + + switch (d) { + case 32: { + const fb_bitfield argb8888[4] = {{16, 8, 0}, {8, 8, 0}, + {0, 8, 0}, {24, 8, 0}}; + const fb_bitfield abgr8888[4] = {{0, 8, 0}, {8, 8, 0}, + {16, 8, 0}, {24, 8, 0}}; + if (memcmp(rgba, argb8888, 4 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_ARGB32; + } else if (memcmp(rgba, argb8888, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB32; + } else if (memcmp(rgba, abgr8888, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB32; + pixeltype = BGRPixel; + } + break; + } + case 24: { + const fb_bitfield rgb888[4] = {{16, 8, 0}, {8, 8, 0}, + {0, 8, 0}, {0, 0, 0}}; + const fb_bitfield bgr888[4] = {{0, 8, 0}, {8, 8, 0}, + {16, 8, 0}, {0, 0, 0}}; + if (memcmp(rgba, rgb888, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB888; + } else if (memcmp(rgba, bgr888, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB888; + pixeltype = BGRPixel; + } + break; + } + case 18: { + const fb_bitfield rgb666[4] = {{12, 6, 0}, {6, 6, 0}, + {0, 6, 0}, {0, 0, 0}}; + if (memcmp(rgba, rgb666, 3 * sizeof(fb_bitfield)) == 0) + format = QImage::Format_RGB666; + break; + } + case 16: { + const fb_bitfield rgb565[4] = {{11, 5, 0}, {5, 6, 0}, + {0, 5, 0}, {0, 0, 0}}; + const fb_bitfield bgr565[4] = {{0, 5, 0}, {5, 6, 0}, + {11, 5, 0}, {0, 0, 0}}; + if (memcmp(rgba, rgb565, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB16; + } else if (memcmp(rgba, bgr565, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB16; + pixeltype = BGRPixel; + } + break; + } + case 15: { + const fb_bitfield rgb1555[4] = {{10, 5, 0}, {5, 5, 0}, + {0, 5, 0}, {15, 1, 0}}; + const fb_bitfield bgr1555[4] = {{0, 5, 0}, {5, 5, 0}, + {10, 5, 0}, {15, 1, 0}}; + if (memcmp(rgba, rgb1555, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB555; + } else if (memcmp(rgba, bgr1555, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB555; + pixeltype = BGRPixel; + } + break; + } + case 12: { + const fb_bitfield rgb444[4] = {{8, 4, 0}, {4, 4, 0}, + {0, 4, 0}, {0, 0, 0}}; + if (memcmp(rgba, rgb444, 3 * sizeof(fb_bitfield)) == 0) + format = QImage::Format_RGB444; + break; + } + case 8: + break; + case 1: + format = QImage::Format_Mono; //###: LSB??? + break; + default: + break; + } + + screenFormat = format; +} + +void QLinuxFbGraphicsSystem::createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo) +{ + if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { + screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; + cmap.start=0; + cmap.len=screencols; + cmap.red=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + cmap.green=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + cmap.blue=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + cmap.transp=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + + if (screencols==16) { + if (finfo.type == FB_TYPE_PACKED_PIXELS) { + // We'll setup a grayscale cmap for 4bpp linear + int val = 0; + for (int idx = 0; idx < 16; ++idx, val += 17) { + cmap.red[idx] = (val<<8)|val; + cmap.green[idx] = (val<<8)|val; + cmap.blue[idx] = (val<<8)|val; + screenclut[idx]=qRgb(val, val, val); + } + } else { + // Default 16 colour palette + // Green is now trolltech green so certain images look nicer + // black d_gray l_gray white red green blue cyan magenta yellow + unsigned char reds[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0xFF, 0xA2, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x82 }; + unsigned char greens[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0xC5, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F }; + unsigned char blues[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0x11, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00 }; + + for (int idx = 0; idx < 16; ++idx) { + cmap.red[idx] = ((reds[idx]) << 8)|reds[idx]; + cmap.green[idx] = ((greens[idx]) << 8)|greens[idx]; + cmap.blue[idx] = ((blues[idx]) << 8)|blues[idx]; + cmap.transp[idx] = 0; + screenclut[idx]=qRgb(reds[idx], greens[idx], blues[idx]); + } + } + } else { + if (grayscale) { + // Build grayscale palette + int i; + for(i=0;iblank == on) + return; + +#if defined(QT_QWS_IPAQ) + if (on) + system("apm -suspend"); +#else + if (d_ptr->fd == -1) + return; +// Some old kernel versions don't have this. These defines should go +// away eventually +#if defined(FBIOBLANK) +#if defined(VESA_POWERDOWN) && defined(VESA_NO_BLANKING) + ioctl(d_ptr->fd, FBIOBLANK, on ? VESA_POWERDOWN : VESA_NO_BLANKING); +#else + ioctl(d_ptr->fd, FBIOBLANK, on ? 1 : 0); +#endif +#endif +#endif + + d_ptr->blank = on; +} + +QPixmapData *QLinuxFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QLinuxFbGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + if (widget->windowType() == Qt::Desktop) + return 0; // Don't create an explicit window surface for the destkop. + QGraphicsSystemFbWindowSurface * surface = + new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); + mPrimaryScreen->addWindowSurface(surface); + return surface; +} + +QLinuxFbGraphicsSystemScreen::QLinuxFbGraphicsSystemScreen(uchar * d, int w, + int h, int lstep, QImage::Format screenFormat) : compositePainter(0) +{ + data = d; + mGeometry = QRect(0,0,w,h); + bytesPerLine = lstep; + mFormat = screenFormat; + mDepth = 16; + mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), + mFormat); + mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), + bytesPerLine, mFormat); + cursor = new QGraphicsSystemSoftwareCursor(this); +} + +void QLinuxFbGraphicsSystemScreen::setGeometry(QRect rect) +{ + mGeometry = rect; + delete mFbScreenImage; + mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), + bytesPerLine, mFormat); + delete compositePainter; + compositePainter = 0; + + delete mScreenImage; + mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), + mFormat); +} + +void QLinuxFbGraphicsSystemScreen::setFormat(QImage::Format format) +{ + mFormat = format; + delete mFbScreenImage; + mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), + bytesPerLine, mFormat); + delete compositePainter; + compositePainter = 0; + + delete mScreenImage; + mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), + mFormat); +} + +QRegion QLinuxFbGraphicsSystemScreen::doRedraw() +{ + QRegion touched; + touched = QGraphicsSystemFbScreen::doRedraw(); + + if (!compositePainter) { + compositePainter = new QPainter(mFbScreenImage); + } + + QVector rects = touched.rects(); + for (int i = 0; i < rects.size(); i++) + compositePainter->drawImage(rects[i], *mScreenImage, rects[i]); + return touched; +} +QT_END_NAMESPACE diff --git a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h new file mode 100644 index 0000000..cc8ce7e --- /dev/null +++ b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_LINUXFB_H +#define QGRAPHICSSYSTEM_LINUXFB_H + +#include +#include "../fb_base/fb_base.h" + +QT_BEGIN_NAMESPACE + +class QLinuxFbGraphicsSystemScreen : public QGraphicsSystemFbScreen +{ +public: + QLinuxFbGraphicsSystemScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat); + void setGeometry(QRect rect); + void setFormat(QImage::Format format); + +public slots: + QRegion doRedraw(); + +private: + QImage * mFbScreenImage; + uchar * data; + int bytesPerLine; + + QPainter *compositePainter; +}; + +class QLinuxFbGraphicsSystemPrivate; +struct fb_cmap; +struct fb_var_screeninfo; +struct fb_fix_screeninfo; + +class QLinuxFbGraphicsSystem : public QGraphicsSystem +{ +public: + QLinuxFbGraphicsSystem(); + ~QLinuxFbGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList screens() const { return mScreens; } + +private: + QLinuxFbGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; + QLinuxFbGraphicsSystemPrivate *d_ptr; + + enum PixelType { NormalPixel, BGRPixel }; + + QRgb screenclut[256]; + int screencols; + + uchar * data; + + QImage::Format screenFormat; + int w; + int lstep; + int h; + int d; + PixelType pixeltype; + bool grayscale; + + int dw; + int dh; + + int size; // Screen size + int mapsize; // Total mapped memory + + int displayId; + + int physWidth; + int physHeight; + + bool canaccel; + int dataoffset; + int cacheStart; + + bool connect(const QString &displaySpec); + bool initDevice(); + void setPixelFormat(struct fb_var_screeninfo); + void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo); + void blank(bool on); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/minimal/main.cpp b/src/plugins/platforms/minimal/main.cpp new file mode 100644 index 0000000..44c274b --- /dev/null +++ b/src/plugins/platforms/minimal/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qplatformintegration_minimal.h" + +QT_BEGIN_NAMESPACE + +class QMinimalIntegrationPlugin : public QPlatformIntegrationPlugin +{ +public: + QStringList keys() const; + QPlatformIntegration *create(const QString&); +}; + +QStringList QMinimalIntegrationPlugin::keys() const +{ + QStringList list; + list << "Minimal"; + return list; +} + +QPlatformIntegration *QMinimalIntegrationPlugin::create(const QString& system) +{ + if (system.toLower() == "minimal") + return new QMinimalIntegration; + + return 0; +} + +Q_EXPORT_PLUGIN2(minimal, QMinimalIntegrationPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro new file mode 100644 index 0000000..567b551 --- /dev/null +++ b/src/plugins/platforms/minimal/minimal.pro @@ -0,0 +1,13 @@ +TARGET = qminimalgraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms + +SOURCES = main.cpp \ + qplatformintegration_minimal.cpp \ + qwindowsurface_minimal.cpp +HEADERS = qplatformintegration_minimal.h \ + qwindowsurface_minimal.h + +target.path += $$[QT_INSTALL_PLUGINS]/platforms +INSTALLS += target diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp new file mode 100644 index 0000000..693e0c3 --- /dev/null +++ b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp @@ -0,0 +1,25 @@ +#include "qplatformintegration_minimal.h" +#include "qwindowsurface_minimal.h" + +#include + +QMinimalIntegration::QMinimalIntegration() +{ + QMinimalScreen *mPrimaryScreen = new QMinimalScreen(); + + mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320); + mPrimaryScreen->mDepth = 16; + mPrimaryScreen->mFormat = QImage::Format_RGB16; + mPrimaryScreen->mPhysicalSize = QSize(40, 54); + + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QMinimalIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} +QWindowSurface *QMinimalIntegration::createWindowSurface(QWidget *widget) const +{ + return new QMinimalWindowSurface(widget); +} diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.h b/src/plugins/platforms/minimal/qplatformintegration_minimal.h new file mode 100644 index 0000000..d4eb78b --- /dev/null +++ b/src/plugins/platforms/minimal/qplatformintegration_minimal.h @@ -0,0 +1,85 @@ + +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMINTEGRATION_MINIMAL_H +#define QPLATFORMINTEGRATION_MINIMAL_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QMinimalScreen : public QPlatformScreen +{ +public: + QMinimalScreen() + : mDepth(16), mFormat(QImage::Format_RGB16) {} + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; +}; + +class QMinimalIntegration : public QPlatformIntegration +{ +public: + QMinimalIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList screens() const { return mScreens; } + +private: + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp b/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp new file mode 100644 index 0000000..0b2bdd2 --- /dev/null +++ b/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsurface_minimal.h" +#include +#include + +QT_BEGIN_NAMESPACE + +QMinimalWindowSurface::QMinimalWindowSurface(QWidget *window) + : QWindowSurface(window) +{ + //qDebug() << "QMinimalWindowSurface::QMinimalWindowSurface:" << (long)this; +} + +QMinimalWindowSurface::~QMinimalWindowSurface() +{ +} + +QPaintDevice *QMinimalWindowSurface::paintDevice() +{ + //qDebug() << "QMinimalWindowSurface::paintDevice"; + return &mImage; +} + +void QMinimalWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); + + static int c = 0; + QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0')); + qDebug() << "QMinimalWindowSurface::flush() saving contents to" << filename.toLocal8Bit().constData(); + mImage.save(filename); +} + +void QMinimalWindowSurface::setGeometry(const QRect &rect) +{ + //qDebug() << "QMinimalWindowSurface::setGeometry:" << (long)this << rect; + QWindowSurface::setGeometry(rect); + QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format(); + if (mImage.size() != rect.size()) + mImage = QImage(rect.size(), format); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimal/qwindowsurface_minimal.h b/src/plugins/platforms/minimal/qwindowsurface_minimal.h new file mode 100644 index 0000000..959a731 --- /dev/null +++ b/src/plugins/platforms/minimal/qwindowsurface_minimal.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_MINIMAL_H +#define QWINDOWSURFACE_MINIMAL_H + +#include + +QT_BEGIN_NAMESPACE + +class QMinimalWindowSurface : public QWindowSurface +{ +public: + QMinimalWindowSurface(QWidget *window); + ~QMinimalWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + +private: + QImage mImage; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/minimaldfb/main.cpp b/src/plugins/platforms/minimaldfb/main.cpp new file mode 100644 index 0000000..fe9407c --- /dev/null +++ b/src/plugins/platforms/minimaldfb/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qgraphicssystem_minimaldfb.h" + +QT_BEGIN_NAMESPACE + +class QDirectFbGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QDirectFbGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "MinimalDfb"; + return list; +} + +QGraphicsSystem* QDirectFbGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "minimaldfb") + return new QDirectFbGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(directfb, QDirectFbGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimaldfb/minimaldfb.pro b/src/plugins/platforms/minimaldfb/minimaldfb.pro new file mode 100644 index 0000000..b6c2ea8 --- /dev/null +++ b/src/plugins/platforms/minimaldfb/minimaldfb.pro @@ -0,0 +1,29 @@ +TARGET = qminimaldfb +include(../../qpluginbase.pri) +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +isEmpty(DIRECTFB_LIBS) { + DIRECTFB_LIBS = -ldirectfb -lfusion -ldirect -lpthread +} +isEmpty(DIRECTFB_INCLUDEPATH) { + DIRECTFB_INCLUDEPATH = /usr/include/directfb +} + +INCLUDEPATH += $$DIRECTFB_INCLUDEPATH +LIBS += $$DIRECTFB_LIBS + +SOURCES = main.cpp \ + qgraphicssystem_minimaldfb.cpp \ + qwindowsurface_minimaldfb.cpp \ + qblitter_directfb.cpp \ + qdirectfbconvenience.cpp \ + qdirectfbinput.cpp \ + qdirectfbcursor.cpp +HEADERS = qgraphicssystem_minimaldfb.h \ + qwindowsurface_minimaldfb.h \ + qblitter_directfb.h \ + qdirectfbconvenience.h \ + qdirectfbinput.h \ + qdirectfbcursor.h +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/platforms/minimaldfb/qblitter_directfb.cpp b/src/plugins/platforms/minimaldfb/qblitter_directfb.cpp new file mode 100644 index 0000000..070c563 --- /dev/null +++ b/src/plugins/platforms/minimaldfb/qblitter_directfb.cpp @@ -0,0 +1,110 @@ +#include "qblitter_directfb.h" +#include "qgraphicssystem_minimaldfb.h" +#include "qdirectfbconvenience.h" + +#include + +#include + +#include + +QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, IDirectFBSurface *surface) + : QBlittable(rect, QBlittable::Capabilities(QBlittable::SolidRectCapability + |QBlittable::SourcePixmapCapability + |QBlittable::SourceOverPixmapCapability + |QBlittable::SourceOverScaledPixmapCapability)) +{ + if (surface) { + m_surface = surface; + } else { + DFBSurfaceDescription surfaceDesc; + memset(&surfaceDesc,0,sizeof(DFBSurfaceDescription)); + surfaceDesc.width = rect.width(); + surfaceDesc.height = rect.height(); + surfaceDesc.caps = DSCAPS_PREMULTIPLIED; + surfaceDesc.pixelformat = DSPF_ARGB; + surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT); + + IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); + dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); + m_surface->Clear(m_surface,0,0,0,0); + } +} + +QDirectFbBlitter::~QDirectFbBlitter() +{ + unlock(); + m_surface->Release(m_surface); +} + +void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color) +{ + m_surface->SetColor(m_surface, color.red(), color.green(), color.blue(), color.alpha()); +// When the blitter api supports non opaque blits, also remember to change +// qpixmap_blitter.cpp::fill +// DFBSurfaceDrawingFlags drawingFlags = color.alpha() ? DSDRAW_BLEND : DSDRAW_NOFX; +// m_surface->SetDrawingFlags(m_surface, drawingFlags); + m_surface->SetDrawingFlags(m_surface, DSDRAW_NOFX); + m_surface->FillRectangle(m_surface, rect.x(), rect.y(), + rect.width(), rect.height()); +} + +void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &srcRect) +{ + QPixmapData *data = pixmap.pixmapData(); + Q_ASSERT(data->width() && data->height()); + Q_ASSERT(data->classId() == QPixmapData::BlitterClass); + QBlittablePixmapData *blitPm = static_cast(data); + QDirectFbBlitter *dfbBlitter = static_cast(blitPm->blittable()); + dfbBlitter->unlock(); + + IDirectFBSurface *s = dfbBlitter->m_surface; + + quint32 blittingFlags = pixmap.hasAlpha()? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; + + s->SetBlittingFlags(s, DFBSurfaceBlittingFlags(blittingFlags)); + m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags)); + m_surface->SetPorterDuff(m_surface,DSPD_SRC_OVER); + m_surface->SetDstBlendFunction(m_surface,DSBF_INVSRCALPHA); + + const DFBRectangle sRect = { srcRect.x(), srcRect.y(), rect.width(), rect.height() }; + + DFBResult result; + if (rect.width() == srcRect.width() && rect.height() == srcRect.height()) + result = m_surface->Blit(m_surface, s, &sRect, rect.x(), rect.y()); + else { + const DFBRectangle dRect = { rect.x(), rect.y(), rect.width(), rect.height() }; + result = m_surface->StretchBlit(m_surface, s, &sRect, &dRect); + } + if (result != DFB_OK) + DirectFBError("QDirectFBBlitter::drawPixmap()", result); +} + +QImage *QDirectFbBlitter::doLock() +{ + Q_ASSERT(m_surface); + Q_ASSERT(size().isValid()); + + void *mem; + int bpl; + const DFBResult result = m_surface->Lock(m_surface, DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast(&mem), &bpl); + if (result == DFB_OK) { + DFBSurfacePixelFormat dfbFormat; + DFBSurfaceCapabilities dfbCaps; + m_surface->GetPixelFormat(m_surface,&dfbFormat); + m_surface->GetCapabilities(m_surface,&dfbCaps); + QImage::Format format = QDirectFbConvenience::imageFormatFromSurfaceFormat(dfbFormat, dfbCaps); + int w, h; + m_surface->GetSize(m_surface,&w,&h); + m_image = QImage(static_cast(mem),w,h,bpl,format); + } else { + DirectFBError("Failed to lock image", result); + } + + return &m_image; +} + +void QDirectFbBlitter::doUnlock() +{ + m_surface->Unlock(m_surface); +} diff --git a/src/plugins/platforms/minimaldfb/qblitter_directfb.h b/src/plugins/platforms/minimaldfb/qblitter_directfb.h new file mode 100644 index 0000000..85a303a --- /dev/null +++ b/src/plugins/platforms/minimaldfb/qblitter_directfb.h @@ -0,0 +1,29 @@ +#ifndef QDIRECTFBBLITTER_H +#define QDIRECTFBBLITTER_H + +#include "qdirectfbconvenience.h" + +#include + +#include + +class QDirectFbBlitter : public QBlittable +{ +public: + QDirectFbBlitter(const QSize &size, IDirectFBSurface *surface = 0); + virtual ~QDirectFbBlitter(); + + virtual void fillRect(const QRectF &rect, const QColor &color); + virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect); + +protected: + virtual QImage *doLock(); + virtual void doUnlock(); + + IDirectFBSurface *m_surface; + QImage m_image; + + friend class QDirectFbConvenience; +}; + +#endif // QDIRECTFBBLITTER_H diff --git a/src/plugins/platforms/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/platforms/minimaldfb/qdirectfbconvenience.cpp new file mode 100644 index 0000000..8594c09 --- /dev/null +++ b/src/plugins/platforms/minimaldfb/qdirectfbconvenience.cpp @@ -0,0 +1,335 @@ +#include "qdirectfbconvenience.h" +#include "qblitter_directfb.h" + +#include + +IDirectFB *QDirectFbConvenience::dfbInterface() +{ + static IDirectFB *dfb = 0; + if (!dfb) { + DFBResult result = DirectFBCreate(&dfb); + if (result != DFB_OK) { + DirectFBError("QDirectFBConvenience: error creating DirectFB interface",result); + return 0; + } + } + return dfb; +} + +IDirectFBDisplayLayer *QDirectFbConvenience::dfbDisplayLayer(int display) +{ + IDirectFBDisplayLayer *layer; + DFBResult result = QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),display,&layer); + if (result != DFB_OK) { + DirectFBError("QDirectFbConvenience: " + "Unable to get primary display layer!", result); + } + return layer; +} + +QImage::Format QDirectFbConvenience::imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps) +{ + switch (format) { + case DSPF_LUT8: + return QImage::Format_Indexed8; + case DSPF_RGB24: + return QImage::Format_RGB888; + case DSPF_ARGB4444: + return QImage::Format_ARGB4444_Premultiplied; + case DSPF_RGB444: + return QImage::Format_RGB444; + case DSPF_RGB555: + case DSPF_ARGB1555: + return QImage::Format_RGB555; + case DSPF_RGB16: + return QImage::Format_RGB16; + case DSPF_ARGB6666: + return QImage::Format_ARGB6666_Premultiplied; + case DSPF_RGB18: + return QImage::Format_RGB666; + case DSPF_RGB32: + return QImage::Format_RGB32; + case DSPF_ARGB: { + if (caps & DSCAPS_PREMULTIPLIED) + return QImage::Format_ARGB32_Premultiplied; + else return QImage::Format_ARGB32; } + default: + break; + } + return QImage::Format_Invalid; + +} + +int QDirectFbConvenience::colorDepthForSurface(const DFBSurfacePixelFormat format) +{ + return ((0x1f << 7) & format) >> 7; +} + +IDirectFBSurface *QDirectFbConvenience::dfbSurfaceForPixmapData(QPixmapData *pixmapData) +{ + QBlittablePixmapData *blittablePmData = static_cast(pixmapData); + if (blittablePmData) { + QBlittable *blittable = blittablePmData->blittable(); + QDirectFbBlitter *dfbBlitter = static_cast(blittable); + return dfbBlitter->m_surface; + } + return 0; +} + +Qt::MouseButton QDirectFbConvenience::mouseButton(DFBInputDeviceButtonIdentifier identifier) +{ + switch (identifier){ + case DIBI_LEFT: + return Qt::LeftButton; + case DIBI_MIDDLE: + return Qt::MidButton; + case DIBI_RIGHT: + return Qt::RightButton; + default: + return Qt::NoButton; + } +} + +Qt::MouseButtons QDirectFbConvenience::mouseButtons(DFBInputDeviceButtonMask mask) +{ + Qt::MouseButtons buttons = Qt::NoButton; + + if (mask & DIBM_LEFT) { + buttons |= Qt::LeftButton; + } + if (mask & DIBM_MIDDLE) { + buttons |= Qt::MidButton; + } + if (mask & DIBM_RIGHT) { + buttons |= Qt::RightButton; + } + return buttons; +} + +Qt::KeyboardModifiers QDirectFbConvenience::keyboardModifiers(DFBInputDeviceModifierMask mask) +{ + Qt::KeyboardModifiers modifiers = Qt::NoModifier; + + if (mask & DIMM_SHIFT) { + modifiers |= Qt::ShiftModifier; + } + if (mask & DIMM_ALT) { + modifiers |= Qt::AltModifier; + } + if (mask & DIMM_ALTGR) { + modifiers |= Qt::MetaModifier; + } + if (mask & DIMM_CONTROL) { + modifiers |= Qt::ControlModifier; + } + if (mask & DIMM_META) { + modifiers | Qt::MetaModifier; + } + return modifiers; +} + +QEvent::Type QDirectFbConvenience::eventType(DFBWindowEventType type) +{ + switch(type) { + case DWET_BUTTONDOWN: + return QEvent::MouseButtonPress; + case DWET_BUTTONUP: + return QEvent::MouseButtonRelease; + case DWET_MOTION: + return QEvent::MouseMove; + case DWET_WHEEL: + return QEvent::Wheel; + case DWET_KEYDOWN: + return QEvent::KeyPress; + case DWET_KEYUP: + return QEvent::KeyRelease; + default: + return QEvent::None; + } +} +QDirectFbKeyMap *QDirectFbConvenience::dfbKeymap = 0; +QDirectFbKeyMap *QDirectFbConvenience::keyMap() +{ + if (!dfbKeymap) + dfbKeymap = new QDirectFbKeyMap(); + return dfbKeymap; +} + +QDirectFbKeyMap::QDirectFbKeyMap() +{ + insert(DIKS_BACKSPACE , Qt::Key_Backspace); + insert(DIKS_TAB , Qt::Key_Tab); + insert(DIKS_RETURN , Qt::Key_Return); + insert(DIKS_ESCAPE , Qt::Key_Escape); + insert(DIKS_DELETE , Qt::Key_Delete); + + insert(DIKS_CURSOR_LEFT , Qt::Key_Left); + insert(DIKS_CURSOR_RIGHT , Qt::Key_Right); + insert(DIKS_CURSOR_UP , Qt::Key_Up); + insert(DIKS_CURSOR_DOWN , Qt::Key_Down); + insert(DIKS_INSERT , Qt::Key_Insert); + insert(DIKS_HOME , Qt::Key_Home); + insert(DIKS_END , Qt::Key_End); + insert(DIKS_PAGE_UP , Qt::Key_PageUp); + insert(DIKS_PAGE_DOWN , Qt::Key_PageDown); + insert(DIKS_PRINT , Qt::Key_Print); + insert(DIKS_PAUSE , Qt::Key_Pause); + insert(DIKS_SELECT , Qt::Key_Select); + insert(DIKS_GOTO , Qt::Key_OpenUrl); + insert(DIKS_CLEAR , Qt::Key_Clear); + insert(DIKS_MENU , Qt::Key_Menu); + insert(DIKS_HELP , Qt::Key_Help); + + insert(DIKS_INTERNET , Qt::Key_HomePage); + insert(DIKS_MAIL , Qt::Key_LaunchMail); + insert(DIKS_FAVORITES , Qt::Key_Favorites); + + insert(DIKS_BACK , Qt::Key_Back); + insert(DIKS_FORWARD , Qt::Key_Forward); + insert(DIKS_VOLUME_UP , Qt::Key_VolumeUp); + insert(DIKS_VOLUME_DOWN , Qt::Key_VolumeDown); + insert(DIKS_MUTE , Qt::Key_VolumeMute); + insert(DIKS_PLAYPAUSE , Qt::Key_Pause); + insert(DIKS_PLAY , Qt::Key_MediaPlay); + insert(DIKS_STOP , Qt::Key_MediaStop); + insert(DIKS_RECORD , Qt::Key_MediaRecord); + insert(DIKS_PREVIOUS , Qt::Key_MediaPrevious); + insert(DIKS_NEXT , Qt::Key_MediaNext); + + insert(DIKS_F1 , Qt::Key_F1); + insert(DIKS_F2 , Qt::Key_F2); + insert(DIKS_F3 , Qt::Key_F3); + insert(DIKS_F4 , Qt::Key_F4); + insert(DIKS_F5 , Qt::Key_F5); + insert(DIKS_F6 , Qt::Key_F6); + insert(DIKS_F7 , Qt::Key_F7); + insert(DIKS_F8 , Qt::Key_F8); + insert(DIKS_F9 , Qt::Key_F9); + insert(DIKS_F10 , Qt::Key_F10); + insert(DIKS_F11 , Qt::Key_F11); + insert(DIKS_F12 , Qt::Key_F12); + + insert(DIKS_SHIFT , Qt::Key_Shift); + insert(DIKS_CONTROL , Qt::Key_Control); + insert(DIKS_ALT , Qt::Key_Alt); + insert(DIKS_ALTGR , Qt::Key_AltGr); + + insert(DIKS_META , Qt::Key_Meta); + insert(DIKS_SUPER , Qt::Key_Super_L); // ??? + insert(DIKS_HYPER , Qt::Key_Hyper_L); // ??? + + insert(DIKS_CAPS_LOCK , Qt::Key_CapsLock); + insert(DIKS_NUM_LOCK , Qt::Key_NumLock); + insert(DIKS_SCROLL_LOCK , Qt::Key_ScrollLock); + + insert(DIKS_DEAD_ABOVEDOT , Qt::Key_Dead_Abovedot); + insert(DIKS_DEAD_ABOVERING , Qt::Key_Dead_Abovering); + insert(DIKS_DEAD_ACUTE , Qt::Key_Dead_Acute); + insert(DIKS_DEAD_BREVE , Qt::Key_Dead_Breve); + insert(DIKS_DEAD_CARON , Qt::Key_Dead_Caron); + insert(DIKS_DEAD_CEDILLA , Qt::Key_Dead_Cedilla); + insert(DIKS_DEAD_CIRCUMFLEX , Qt::Key_Dead_Circumflex); + insert(DIKS_DEAD_DIAERESIS , Qt::Key_Dead_Diaeresis); + insert(DIKS_DEAD_DOUBLEACUTE , Qt::Key_Dead_Doubleacute); + insert(DIKS_DEAD_GRAVE , Qt::Key_Dead_Grave); + insert(DIKS_DEAD_IOTA , Qt::Key_Dead_Iota); + insert(DIKS_DEAD_MACRON , Qt::Key_Dead_Macron); + insert(DIKS_DEAD_OGONEK , Qt::Key_Dead_Ogonek); + insert(DIKS_DEAD_SEMIVOICED_SOUND , Qt::Key_Dead_Semivoiced_Sound); + insert(DIKS_DEAD_TILDE , Qt::Key_Dead_Tilde); + insert(DIKS_DEAD_VOICED_SOUND , Qt::Key_Dead_Voiced_Sound); + insert(DIKS_SPACE , Qt::Key_Space); + insert(DIKS_EXCLAMATION_MARK , Qt::Key_Exclam); + insert(DIKS_QUOTATION , Qt::Key_QuoteDbl); + insert(DIKS_NUMBER_SIGN , Qt::Key_NumberSign); + insert(DIKS_DOLLAR_SIGN , Qt::Key_Dollar); + insert(DIKS_PERCENT_SIGN , Qt::Key_Percent); + insert(DIKS_AMPERSAND , Qt::Key_Ampersand); + insert(DIKS_APOSTROPHE , Qt::Key_Apostrophe); + insert(DIKS_PARENTHESIS_LEFT , Qt::Key_ParenLeft); + insert(DIKS_PARENTHESIS_RIGHT , Qt::Key_ParenRight); + insert(DIKS_ASTERISK , Qt::Key_Asterisk); + insert(DIKS_PLUS_SIGN , Qt::Key_Plus); + insert(DIKS_COMMA , Qt::Key_Comma); + insert(DIKS_MINUS_SIGN , Qt::Key_Minus); + insert(DIKS_PERIOD , Qt::Key_Period); + insert(DIKS_SLASH , Qt::Key_Slash); + insert(DIKS_0 , Qt::Key_0); + insert(DIKS_1 , Qt::Key_1); + insert(DIKS_2 , Qt::Key_2); + insert(DIKS_3 , Qt::Key_3); + insert(DIKS_4 , Qt::Key_4); + insert(DIKS_5 , Qt::Key_5); + insert(DIKS_6 , Qt::Key_6); + insert(DIKS_7 , Qt::Key_7); + insert(DIKS_8 , Qt::Key_8); + insert(DIKS_9 , Qt::Key_9); + insert(DIKS_COLON , Qt::Key_Colon); + insert(DIKS_SEMICOLON , Qt::Key_Semicolon); + insert(DIKS_LESS_THAN_SIGN , Qt::Key_Less); + insert(DIKS_EQUALS_SIGN , Qt::Key_Equal); + insert(DIKS_GREATER_THAN_SIGN , Qt::Key_Greater); + insert(DIKS_QUESTION_MARK , Qt::Key_Question); + insert(DIKS_AT , Qt::Key_At); + insert(DIKS_CAPITAL_A , Qt::Key_A); + insert(DIKS_CAPITAL_B , Qt::Key_B); + insert(DIKS_CAPITAL_C , Qt::Key_C); + insert(DIKS_CAPITAL_D , Qt::Key_D); + insert(DIKS_CAPITAL_E , Qt::Key_E); + insert(DIKS_CAPITAL_F , Qt::Key_F); + insert(DIKS_CAPITAL_G , Qt::Key_G); + insert(DIKS_CAPITAL_H , Qt::Key_H); + insert(DIKS_CAPITAL_I , Qt::Key_I); + insert(DIKS_CAPITAL_J , Qt::Key_J); + insert(DIKS_CAPITAL_K , Qt::Key_K); + insert(DIKS_CAPITAL_L , Qt::Key_L); + insert(DIKS_CAPITAL_M , Qt::Key_M); + insert(DIKS_CAPITAL_N , Qt::Key_N); + insert(DIKS_CAPITAL_O , Qt::Key_O); + insert(DIKS_CAPITAL_P , Qt::Key_P); + insert(DIKS_CAPITAL_Q , Qt::Key_Q); + insert(DIKS_CAPITAL_R , Qt::Key_R); + insert(DIKS_CAPITAL_S , Qt::Key_S); + insert(DIKS_CAPITAL_T , Qt::Key_T); + insert(DIKS_CAPITAL_U , Qt::Key_U); + insert(DIKS_CAPITAL_V , Qt::Key_V); + insert(DIKS_CAPITAL_W , Qt::Key_W); + insert(DIKS_CAPITAL_X , Qt::Key_X); + insert(DIKS_CAPITAL_Y , Qt::Key_Y); + insert(DIKS_CAPITAL_Z , Qt::Key_Z); + insert(DIKS_SQUARE_BRACKET_LEFT , Qt::Key_BracketLeft); + insert(DIKS_BACKSLASH , Qt::Key_Backslash); + insert(DIKS_SQUARE_BRACKET_RIGHT , Qt::Key_BracketRight); + insert(DIKS_CIRCUMFLEX_ACCENT , Qt::Key_AsciiCircum); + insert(DIKS_UNDERSCORE , Qt::Key_Underscore); + insert(DIKS_SMALL_A , Qt::Key_A); + insert(DIKS_SMALL_B , Qt::Key_B); + insert(DIKS_SMALL_C , Qt::Key_C); + insert(DIKS_SMALL_D , Qt::Key_D); + insert(DIKS_SMALL_E , Qt::Key_E); + insert(DIKS_SMALL_F , Qt::Key_F); + insert(DIKS_SMALL_G , Qt::Key_G); + insert(DIKS_SMALL_H , Qt::Key_H); + insert(DIKS_SMALL_I , Qt::Key_I); + insert(DIKS_SMALL_J , Qt::Key_J); + insert(DIKS_SMALL_K , Qt::Key_K); + insert(DIKS_SMALL_L , Qt::Key_L); + insert(DIKS_SMALL_M , Qt::Key_M); + insert(DIKS_SMALL_N , Qt::Key_N); + insert(DIKS_SMALL_O , Qt::Key_O); + insert(DIKS_SMALL_P , Qt::Key_P); + insert(DIKS_SMALL_Q , Qt::Key_Q); + insert(DIKS_SMALL_R , Qt::Key_R); + insert(DIKS_SMALL_S , Qt::Key_S); + insert(DIKS_SMALL_T , Qt::Key_T); + insert(DIKS_SMALL_U , Qt::Key_U); + insert(DIKS_SMALL_V , Qt::Key_V); + insert(DIKS_SMALL_W , Qt::Key_W); + insert(DIKS_SMALL_X , Qt::Key_X); + insert(DIKS_SMALL_Y , Qt::Key_Y); + insert(DIKS_SMALL_Z , Qt::Key_Z); + insert(DIKS_CURLY_BRACKET_LEFT , Qt::Key_BraceLeft); + insert(DIKS_VERTICAL_BAR , Qt::Key_Bar); + insert(DIKS_CURLY_BRACKET_RIGHT , Qt::Key_BraceRight); + insert(DIKS_TILDE , Qt::Key_AsciiTilde); +} diff --git a/src/plugins/platforms/minimaldfb/qdirectfbconvenience.h b/src/plugins/platforms/minimaldfb/qdirectfbconvenience.h new file mode 100644 index 0000000..0b1a24f --- /dev/null +++ b/src/plugins/platforms/minimaldfb/qdirectfbconvenience.h @@ -0,0 +1,43 @@ +#ifndef QDIRECTFBCONVENIENCE_H +#define QDIRECTFBCONVENIENCE_H + +#include +#include +#include +#include + +#include + +class QDirectFbKeyMap: public QHash +{ +public: + QDirectFbKeyMap(); +}; + + +class QDirectFbConvenience +{ +public: + static QImage::Format imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps); + static bool pixelFomatHasAlpha(const DFBSurfacePixelFormat format) { return (1 << 16) & format; } + static int colorDepthForSurface(const DFBSurfacePixelFormat format); + + //This is set by the graphicssystem constructor + static IDirectFB *dfbInterface(); + static IDirectFBDisplayLayer *dfbDisplayLayer(int display = DLID_PRIMARY); + + static IDirectFBSurface *dfbSurfaceForPixmapData(QPixmapData *); + + static Qt::MouseButton mouseButton(DFBInputDeviceButtonIdentifier identifier); + static Qt::MouseButtons mouseButtons(DFBInputDeviceButtonMask mask); + static Qt::KeyboardModifiers keyboardModifiers(DFBInputDeviceModifierMask mask); + static QEvent::Type eventType(DFBWindowEventType type); + + static QDirectFbKeyMap *keyMap(); + +private: + static QDirectFbKeyMap *dfbKeymap; + friend class QDirectFbGraphicsSystem; +}; + +#endif // QDIRECTFBCONVENIENCE_H diff --git a/src/plugins/platforms/minimaldfb/qdirectfbcursor.cpp b/src/plugins/platforms/minimaldfb/qdirectfbcursor.cpp new file mode 100644 index 0000000..229a875 --- /dev/null +++ b/src/plugins/platforms/minimaldfb/qdirectfbcursor.cpp @@ -0,0 +1,42 @@ +#include "qdirectfbcursor.h" +#include "qblitter_directfb.h" +#include "qgraphicssystem_minimaldfb.h" +#include "qdirectfbconvenience.h" + +#include + +QDirectFBCursor::QDirectFBCursor(QGraphicsSystemScreen * screen) : + QGraphicsSystemCursor(screen), surface(0) +{ + QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY, &m_layer); + image = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); +} + +void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) +{ + Q_UNUSED(widget); + int xSpot; + int ySpot; + QPixmap map; + + if (cursor->shape() != Qt::BitmapCursor) { + image->set(cursor->shape()); + xSpot = image->hotspot().x(); + ySpot = image->hotspot().y(); + QImage *i = image->image(); + map = QPixmap::fromImage(*i); + } else { + QPoint point = cursor->hotSpot(); + xSpot = point.x(); + ySpot = point.y(); + map = cursor->pixmap(); + } + + IDirectFBSurface *surface = QDirectFbConvenience::dfbSurfaceForPixmapData(map.pixmapData()); + + if (m_layer->SetCooperativeLevel(m_layer, DLSCL_ADMINISTRATIVE) != DFB_OK) { + return; + } + m_layer->SetCursorShape( m_layer, surface, xSpot, ySpot); + m_layer->SetCooperativeLevel(m_layer, DLSCL_SHARED); +} diff --git a/src/plugins/platforms/minimaldfb/qdirectfbcursor.h b/src/plugins/platforms/minimaldfb/qdirectfbcursor.h new file mode 100644 index 0000000..064a336 --- /dev/null +++ b/src/plugins/platforms/minimaldfb/qdirectfbcursor.h @@ -0,0 +1,22 @@ +#ifndef QDIRECTFBCURSOR_H +#define QDIRECTFBCURSOR_H + +#include +#include +class QDirectFbGraphicsSystemScreen; +class QDirectFbBlitter; + +class QDirectFBCursor : public QGraphicsSystemCursor +{ +public: + QDirectFBCursor(QGraphicsSystemScreen *screem); + void changeCursor(QCursor * cursor, QWidget * widget); + +private: + IDirectFBDisplayLayer * m_layer; + IDirectFBSurface * surface; + QGraphicsSystemCursorImage * image; + QDirectFbBlitter *blitter; +}; + +#endif // QDIRECTFBCURSOR_H diff --git a/src/plugins/platforms/minimaldfb/qdirectfbinput.cpp b/src/plugins/platforms/minimaldfb/qdirectfbinput.cpp new file mode 100644 index 0000000..74a38a4 --- /dev/null +++ b/src/plugins/platforms/minimaldfb/qdirectfbinput.cpp @@ -0,0 +1,205 @@ +#include "qdirectfbinput.h" +#include "qdirectfbconvenience.h" + +#include +#include +#include +#include +#include +#include + +#include + +InputSocketWaiter::InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent) + : QThread(parent), m_eventBuffer(eventBuffer),m_shouldStop(false) +{ + this->start(); +} + +InputSocketWaiter::~InputSocketWaiter() +{ + m_shouldStop = true; + m_eventBuffer->WakeUp(m_eventBuffer); + m_cleanupMutex.lock(); +} + +void InputSocketWaiter::continueWaitingForEvents() +{ + m_finishedProcessingEvents.wakeAll(); +} + +void InputSocketWaiter::run() +{ + m_cleanupMutex.lock(); + while (1) { + m_eventBuffer->WaitForEvent(m_eventBuffer); + if (m_shouldStop) + break; + emit newEvent(); + QMutex waitForProcessingMutex; + waitForProcessingMutex.lock(); + m_finishedProcessingEvents.wait(&waitForProcessingMutex); + } + m_cleanupMutex.unlock(); +} + +QDirectFbInput *QDirectFbInput::instance() +{ + static QDirectFbInput *input = 0; + if (!input) { + input = new QDirectFbInput(); + } + return input; +} + +QDirectFbInput::QDirectFbInput() + : QObject() +{ + dfbInterface = QDirectFbConvenience::dfbInterface(); + + DFBResult ok = dfbInterface->CreateEventBuffer(dfbInterface,&eventBuffer); + if (ok != DFB_OK) + DirectFBError("Failed to initialise eventbuffer", ok); + + dfbInterface->GetDisplayLayer(dfbInterface,DLID_PRIMARY, &dfbDisplayLayer); + + m_inputHandler = new InputSocketWaiter(eventBuffer,this); + connect(m_inputHandler,SIGNAL(newEvent()),this,SLOT(handleEvents())); + + connect(QApplication::instance(),SIGNAL(aboutToQuit()),SLOT(applicationEnd())); +} + +void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) +{ + tlwMap.insert(id,tlw); + IDirectFBWindow *window; + dfbDisplayLayer->GetWindow(dfbDisplayLayer,id,&window); + + window->AttachEventBuffer(window,eventBuffer); +} + +void QDirectFbInput::removeWindow(QWidget *tlw) +{ + DFBWindowID id = tlwMap.key(tlw,0); + if (id) { + IDirectFBWindow *window; + dfbDisplayLayer->GetWindow(dfbDisplayLayer,id, &window); + + window->DetachEventBuffer(window,eventBuffer); + tlwMap.remove(id); + } +} + +void QDirectFbInput::handleEvents() +{ + DFBResult hasEvent = eventBuffer->HasEvent(eventBuffer); + while(hasEvent == DFB_OK){ + DFBEvent event; + DFBResult ok = eventBuffer->GetEvent(eventBuffer,&event); + if (ok != DFB_OK) + DirectFBError("Failed to get event",ok); + if (event.clazz == DFEC_WINDOW) { + switch (event.window.type) { + case DWET_BUTTONDOWN: + case DWET_BUTTONUP: + case DWET_MOTION: + handleMouseEvents(event); + break; + case DWET_WHEEL: + handleWheelEvent(event); + break; + case DWET_KEYDOWN: + case DWET_KEYUP: + handleKeyEvents(event); + break; + case DWET_ENTER: + case DWET_LEAVE: + handleEnterLeaveEvents(event); + default: + break; + } + + } + + hasEvent = eventBuffer->HasEvent(eventBuffer); + } + m_inputHandler->continueWaitingForEvents(); +} + +void QDirectFbInput::handleMouseEvents(const DFBEvent &event) +{ + QPoint p(event.window.x, event.window.y); + QPoint globalPos = globalPoint(event); + Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); + + IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); + IDirectFBWindow *window; + layer->GetWindow(layer,event.window.window_id,&window); + + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + + if (event.window.type == DWET_BUTTONDOWN) { + window->GrabPointer(window); + } else if (event.window.type == DWET_BUTTONUP) { + window->UngrabPointer(window); + } + QWidget *tlw = tlwMap.value(event.window.window_id); + QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons); +} + +void QDirectFbInput::applicationEnd() +{ + delete m_inputHandler; + m_inputHandler = 0; +} + +void QDirectFbInput::handleWheelEvent(const DFBEvent &event) +{ + QPoint p(event.window.cx, event.window.cy); + QPoint globalPos = globalPoint(event); + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + QWidget *tlw = tlwMap.value(event.window.window_id); + QWindowSystemInterface::handleWheelEvent(tlw, timestamp, p, globalPos, + event.window.step*120, + Qt::Vertical); +} + +void QDirectFbInput::handleKeyEvents(const DFBEvent &event) +{ + QEvent::Type type = QDirectFbConvenience::eventType(event.window.type); + Qt::Key key = QDirectFbConvenience::keyMap()->value(event.window.key_symbol); + Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers); + + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + + QChar character; + if (DFB_KEY_TYPE(event.window.key_symbol) == DIKT_UNICODE) + character = QChar(event.window.key_symbol); + QWidget *tlw = tlwMap.value(event.window.window_id); + QWindowSystemInterface::handleKeyEvent(tlw, timestamp, type, key, modifiers, character); +} + +void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) +{ + QWidget *tlw = tlwMap.value(event.window.window_id); + switch (event.window.type) { + case DWET_ENTER: + QWindowSystemInterface::handleEnterEvent(tlw); + break; + case DWET_LEAVE: + QWindowSystemInterface::handleLeaveEvent(tlw); + break; + default: + break; + } +} + +inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const +{ + IDirectFBWindow *window; + dfbDisplayLayer->GetWindow(dfbDisplayLayer,event.window.window_id,&window); + int x,y; + window->GetPosition(window,&x,&y); + return QPoint(event.window.cx +x, event.window.cy + y); +} + diff --git a/src/plugins/platforms/minimaldfb/qdirectfbinput.h b/src/plugins/platforms/minimaldfb/qdirectfbinput.h new file mode 100644 index 0000000..31aa082 --- /dev/null +++ b/src/plugins/platforms/minimaldfb/qdirectfbinput.h @@ -0,0 +1,63 @@ +#ifndef QDIRECTFBINPUT_H +#define QDIRECTFBINPUT_H + +#include +#include +#include +#include +#include +#include +#include + +#include + +class InputSocketWaiter : public QThread +{ + Q_OBJECT +public: + InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent); + virtual ~InputSocketWaiter(); + void continueWaitingForEvents(); +protected: + void run(); +signals: + void newEvent(); +private: + IDirectFBEventBuffer *m_eventBuffer; + bool m_shouldStop; + QMutex m_cleanupMutex; + QWaitCondition m_finishedProcessingEvents; +}; + +class QDirectFbInput : public QObject +{ + Q_OBJECT +public: + static QDirectFbInput *instance(); + void addWindow(DFBWindowID id, QWidget *tlw); + void removeWindow(QWidget *tlw); + +public slots: + void handleEvents(); + void applicationEnd(); + +private: + QDirectFbInput(); + + void handleMouseEvents(const DFBEvent &event); + void handleWheelEvent(const DFBEvent &event); + void handleKeyEvents(const DFBEvent &event); + void handleEnterLeaveEvents(const DFBEvent &event); + IDirectFB *dfbInterface; + IDirectFBDisplayLayer *dfbDisplayLayer; + IDirectFBEventBuffer *eventBuffer; + + QHashtlwMap; + + inline QPoint globalPoint(const DFBEvent &event) const; + + InputSocketWaiter *m_inputHandler; + +}; + +#endif // QDIRECTFBINPUT_H diff --git a/src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.cpp new file mode 100644 index 0000000..212f3a9 --- /dev/null +++ b/src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicssystem_minimaldfb.h" +#include "qwindowsurface_minimaldfb.h" +#include "qblitter_directfb.h" +#include "qdirectfbconvenience.h" +#include "qdirectfbcursor.h" + +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(int display) + :QGraphicsSystemScreen() +{ + m_layer = QDirectFbConvenience::dfbDisplayLayer(display); + m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); + + DFBDisplayLayerConfig config; + m_layer->GetConfiguration(m_layer, &config); + + m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps); + m_geometry = QRect(0,0,config.width,config.height); + const int dpi = 72; + const qreal inch = 25.4; + m_depth = 32; + m_physicalSize = QSize(qRound(config.width * inch / dpi), qRound(config.height *inch / dpi)); + + cursor = new QDirectFBCursor(this); +} + +QDirectFbGraphicsSystemScreen::~QDirectFbGraphicsSystemScreen() +{ +} + +QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() +{ + const QStringList args = QCoreApplication::arguments(); + int argc = args.size(); + char **argv = new char*[argc]; + + for (int i = 0; i < argc; ++i) + argv[i] = qstrdup(args.at(i).toLocal8Bit().constData()); + + DFBResult result = DirectFBInit(&argc, &argv); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen: error initializing DirectFB", + result); + } + delete[] argv; + + mPrimaryScreen = new QDirectFbGraphicsSystemScreen(0); + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QDirectFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + if (type == QPixmapData::BitmapType) + return new QRasterPixmapData(type); + else + return new QBlittablePixmapData(type); +} + +QWindowSurface *QDirectFbGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + return new QDirectFbWindowSurface (widget); +} + +QBlittable *QDirectFbGraphicsSystem::createBlittable(const QSize &size) const +{ + return new QDirectFbBlitter(size); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.h new file mode 100644 index 0000000..27bddfb --- /dev/null +++ b/src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_MINIMAL_H +#define QGRAPHICSSYSTEM_MINIMAL_H + +#include "qdirectfbinput.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QDirectFBCursor; + +class QDirectFbGraphicsSystemScreen : public QGraphicsSystemScreen +{ +public: + QDirectFbGraphicsSystemScreen(int display); + ~QDirectFbGraphicsSystemScreen(); + + 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; } + +public: + QRect m_geometry; + int m_depth; + QImage::Format m_format; + QSize m_physicalSize; + + IDirectFBDisplayLayer *m_layer; + +private: + QDirectFBCursor * cursor; + +}; + +class QDirectFbGraphicsSystem : public QGraphicsSystem +{ +public: + QDirectFbGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + QBlittable *createBlittable(const QSize &size) const; + + QList screens() const { return mScreens; } + + + +private: + QDirectFbGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.cpp new file mode 100644 index 0000000..68d5aa0 --- /dev/null +++ b/src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.cpp @@ -0,0 +1,231 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsurface_minimaldfb.h" +#include "qgraphicssystem_minimaldfb.h" +#include "qblitter_directfb.h" +#include "qdirectfbconvenience.h" +#include + +#include + +QT_BEGIN_NAMESPACE + +QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window) + : QWindowSurface(window), m_pixmap(0), m_pmdata(0), + m_dfbWindow(0), m_dfbSurface(0) +{ + window->setWindowSurface(this); + + IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); + DFBDisplayLayerConfig layerConfig; + layer->GetConfiguration(layer,&layerConfig); + + DFBWindowDescription description; + memset(&description,0,sizeof(DFBWindowDescription)); + description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS +#if DIRECTFB_MINOR_VERSION >= 1 + |DWDESC_OPTIONS +#endif + |DWDESC_CAPS); + description.width = window->rect().width(); + description.height = window->rect().height(); + description.posx = window->rect().x(); + description.posy = window->rect().y(); + + if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED) + description.surface_caps = DSCAPS_PREMULTIPLIED; + description.pixelformat = layerConfig.pixelformat; + +#if DIRECTFB_MINOR_VERSION >= 1 + description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); +#endif + description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL); + description.surface_caps = DSCAPS_PREMULTIPLIED; + + DFBResult result = layer->CreateWindow(layer,&description,&m_dfbWindow); + if (result != DFB_OK) { + DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); + } + + DFBWindowID id; + m_dfbWindow->GetID(m_dfbWindow, &id); + QDirectFbInput::instance()->addWindow(id,window); + + m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); + + QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect().size(), m_dfbSurface); + m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); + m_pmdata->setBlittable(blitter); + m_pixmap = new QPixmap(m_pmdata); +} + +QDirectFbWindowSurface::~QDirectFbWindowSurface() +{ + QDirectFbInput::instance()->removeWindow(this->window()); + m_dfbWindow->Destroy(m_dfbWindow); +} + +QPaintDevice *QDirectFbWindowSurface::paintDevice() +{ + return m_pixmap; +} + +void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + m_pmdata->blittable()->unlock(); + + const quint8 windowOpacity = quint8(widget->windowOpacity() * 0xff); + m_dfbWindow->SetOpacity(m_dfbWindow,windowOpacity); + + QVector rects = region.rects(); + for (int i = 0 ; i < rects.size(); i++) { + const QRect rect = rects.at(i); + DFBRegion dfbReg = { rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()}; + m_dfbSurface->Flip(m_dfbSurface, &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC)); + } +} + +void QDirectFbWindowSurface::setGeometry(const QRect &rect) +{ + m_pmdata->blittable()->unlock(); + + QWindowSurface::setGeometry(rect); + m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), + rect.width(), rect.height()); + + //Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable + m_dfbSurface->AddRef(m_dfbSurface); + QDirectFbBlitter *blitter = new QDirectFbBlitter(rect.size(),m_dfbSurface); + m_pmdata->setBlittable(blitter); +} + +static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) +{ + const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; + surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy); + const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy }; + surface->Flip(surface, ®ion, DFBSurfaceFlipFlags(DSFLIP_BLIT)); +} + +bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + m_pmdata->blittable()->unlock(); + + if (!m_dfbSurface || area.isEmpty()) + return false; + m_dfbSurface->SetBlittingFlags(m_dfbSurface, DSBLIT_NOFX); + if (area.rectCount() == 1) { + scrollSurface(m_dfbSurface, area.boundingRect(), dx, dy); + } else { + const QVector rects = area.rects(); + const int n = rects.size(); + for (int i=0; iblittable()->unlock(); + + if (visible) { + int x = this->geometry().x(); + int y = this->geometry().y(); + m_dfbWindow->MoveTo(m_dfbWindow,x,y); + } else { + IDirectFBDisplayLayer *displayLayer; + QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY,&displayLayer); + + DFBDisplayLayerConfig config; + displayLayer->GetConfiguration(displayLayer,&config); + m_dfbWindow->MoveTo(m_dfbWindow,config.width+1,config.height + 1); + } +} + +Qt::WindowFlags QDirectFbWindowSurface::setWindowFlags(Qt::WindowFlags flags) +{ + switch (flags & Qt::WindowType_Mask) { + case Qt::ToolTip: { + DFBWindowOptions options; + m_dfbWindow->GetOptions(m_dfbWindow,&options); + options = DFBWindowOptions(options | DWOP_GHOST); + m_dfbWindow->SetOptions(m_dfbWindow,options); + break; } + default: + break; + } + + m_dfbWindow->SetStackingClass(m_dfbWindow, flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE); + return flags; +} + +void QDirectFbWindowSurface::raise() +{ + m_dfbWindow->RaiseToTop(m_dfbWindow); +} + +void QDirectFbWindowSurface::lower() +{ + m_dfbWindow->LowerToBottom(m_dfbWindow); +} + +WId QDirectFbWindowSurface::winId() const +{ + DFBWindowID id; + m_dfbWindow->GetID(m_dfbWindow, &id); + return WId(id); +} + + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.h new file mode 100644 index 0000000..ca34cbf --- /dev/null +++ b/src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_MINIMAL_H +#define QWINDOWSURFACE_MINIMAL_H + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class QDirectFbGraphicsSystemScreen; + +class QDirectFbWindowSurface : public QWindowSurface +{ +public: + QDirectFbWindowSurface(QWidget *window); + ~QDirectFbWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + + void setVisible(bool visible); + Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); + + void raise(); + void lower(); + + WId winId() const; + +private: + void lockSurfaceToImage(); + + QPixmap *m_pixmap; + QBlittablePixmapData *m_pmdata; + + IDirectFBWindow *m_dfbWindow; + IDirectFBSurface *m_dfbSurface; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/openkode/frag.glslf b/src/plugins/platforms/openkode/frag.glslf new file mode 100644 index 0000000..a593434 --- /dev/null +++ b/src/plugins/platforms/openkode/frag.glslf @@ -0,0 +1,8 @@ +uniform sampler2D tex_samp; + +varying vec2 texcoord_var; + +void main() +{ + gl_FragColor = texture2D(tex_samp, texcoord_var); +} diff --git a/src/plugins/platforms/openkode/frag.h b/src/plugins/platforms/openkode/frag.h new file mode 100644 index 0000000..6575cb5 --- /dev/null +++ b/src/plugins/platforms/openkode/frag.h @@ -0,0 +1,37 @@ +0x4e,0x56,0x75,0x63,0x01,0x00,0x00,0x00,0x09,0x00,0x06,0x00,0x06,0x00,0x50,0x00, +0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x50,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x40,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x27,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x50,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0xe8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x70,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x11,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xb0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x12,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0xc0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x2b,0x00,0x00,0x00,0x7a,0x00,0x00,0x00,0xd0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x2c,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x68,0x69,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff, +0x00,0x00,0x00,0x80,0x04,0x00,0x00,0x90,0x00,0x02,0x01,0x82,0x04,0x02,0x02,0x82, +0x01,0x00,0x40,0xf6,0x85,0xc7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x3a,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x2a,0x00,0x06,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0x3b,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x49,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x04,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0x00,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x00,0x00,0x00,0x74,0x65,0x78,0x63, +0x6f,0x6f,0x72,0x64,0x5f,0x76,0x61,0x72,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/src/plugins/platforms/openkode/main.cpp b/src/plugins/platforms/openkode/main.cpp new file mode 100644 index 0000000..e9c1083 --- /dev/null +++ b/src/plugins/platforms/openkode/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qgraphicssystem_openkode.h" + +QT_BEGIN_NAMESPACE + +class QOpenKODEGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QOpenKODEGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "OpenKODE"; + return list; +} + +QGraphicsSystem* QOpenKODEGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "openkode") + return new QOpenKODEGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(openkode, QOpenKODEGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/openkode.pro b/src/plugins/platforms/openkode/openkode.pro new file mode 100644 index 0000000..055048d --- /dev/null +++ b/src/plugins/platforms/openkode/openkode.pro @@ -0,0 +1,14 @@ +TARGET = qopenkodegraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp qgraphicssystem_openkode.cpp qwindowsurface_openkode.cpp +HEADERS = qgraphicssystem_openkode.h qwindowsurface_openkode.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target + +# openkode specific stuff +INCLUDEPATH += $(OPENKODE_DIR)/include +LIBS += $${QMAKE_RPATH}/$(OPENKODE_DIR)/lib-target -L$(OPENKODE_DIR)/lib-target -lKD -lEGL -lGLESv2 diff --git a/src/plugins/platforms/openkode/qgraphicssystem_openkode.cpp b/src/plugins/platforms/openkode/qgraphicssystem_openkode.cpp new file mode 100644 index 0000000..7a07776 --- /dev/null +++ b/src/plugins/platforms/openkode/qgraphicssystem_openkode.cpp @@ -0,0 +1,236 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicssystem_openkode.h" +#include "qwindowsurface_openkode.h" +#include + +#include +#include + +#include +#include +#include + +#include "GLES2/gl2ext.h" + + +QT_BEGIN_NAMESPACE + +QOpenKODEGraphicsSystemScreen::QOpenKODEGraphicsSystemScreen() +{ + KDDesktopNV *kdDesktop = KD_NULL; + KDDisplayNV *kdDisplay = KD_NULL; + + qDebug() << "QOpenKODEGraphicsSystemScreen::QOpenKODEGraphicsSystemScreen()"; + + // Get the default desktop and display + kdDesktop = kdGetDesktopNV(KD_DEFAULT_DESKTOP_NV, KD_NULL); + if (!kdDesktop || kdDesktop == (void*)-1) { + qErrnoWarning(kdGetError(), "Could not obtain KDDesktopNV pointer"); + return; + } + + kdDisplay = kdGetDisplayNV(KD_DEFAULT_DISPLAY_NV, KD_NULL); + if (!kdDisplay || kdDisplay == (void*)-1) { + qErrnoWarning(kdGetError(), "Could not obtain KDDisplayNV pointer"); + kdReleaseDesktopNV(kdDesktop); + return; + } + + KDDisplayModeNV mode; + if (kdGetDisplayModeNV(kdDisplay, &mode)) { + qErrnoWarning(kdGetError(), "Could not get display mode"); + return; + } + + qDebug() << " - display mode " << mode.width << "x" << mode.height << " refresh " << mode.refresh; + + KDint desktopSize[] = { mode.width, mode.height }; + + if (kdSetDesktopPropertyivNV(kdDesktop, KD_DESKTOPPROPERTY_SIZE_NV, desktopSize)) { + qErrnoWarning(kdGetError(), "Could not set desktop size"); + return; + } + + // Once we've set up the desktop and display we don't need them anymore + kdReleaseDisplayNV(kdDisplay); + kdReleaseDesktopNV(kdDesktop); + + const int defaultDpi = 72; + mGeometry = QRect(0, 0, mode.width, mode.height); + mPhysicalSize = QSize(mode.width * 25.4 / defaultDpi, mode.height * 25.4 / defaultDpi); + + mDepth = 24; + mFormat = QImage::Format_RGB888; + + + QEglProperties properties; + properties.setPixelFormat(QImage::Format_RGB888); + properties.setValue(EGL_BUFFER_SIZE, EGL_DONT_CARE); + properties.setRenderableType(QEgl::OpenGL); + + if (!mContext.chooseConfig(properties, QEgl::BestPixelFormat)) { + qWarning("qEglContext: Unable to choose config!"); + return; + } + + if (!mContext.display()) { + qWarning("qEglContext: Unable to open display!"); + return; + } + + qDebug() << " - QEglContext::openDisplay OK"; +} + +static GLuint NvKdTestLoadShaders(const char *vertex_shader_binary, + const char *fragment_shader_binary, + GLuint vertex_shader_binary_size, + GLuint fragment_shader_binary_size) +{ + GLuint prog; + GLuint vertShader; + GLuint fragShader; + + // Create the program + prog = glCreateProgram(); + + // Create the GL shader objects + vertShader = glCreateShader(GL_VERTEX_SHADER); + fragShader = glCreateShader(GL_FRAGMENT_SHADER); + + // Load the binary data into the shader objects + glShaderBinary(1, &vertShader, + GL_NVIDIA_PLATFORM_BINARY_NV, vertex_shader_binary, vertex_shader_binary_size); + glShaderBinary(1, &fragShader, + GL_NVIDIA_PLATFORM_BINARY_NV, fragment_shader_binary, fragment_shader_binary_size); + + // Attach the shaders to the program + glAttachShader(prog, vertShader); + glAttachShader(prog, fragShader); + + // Delete the shaders + glDeleteShader(vertShader); + glDeleteShader(fragShader); + + // Link and validate the shader program + glLinkProgram(prog); + glValidateProgram(prog); + + return prog; +} + +class QOpenKODEEventLoopHelper : public QThread +{ +public: + QOpenKODEEventLoopHelper(QSemaphore *m) + : eventMutex(m) + { + m->acquire(); + } + +protected: + void run() + { + qDebug() << "initializing KD"; + kdInitializeNV(); + qDebug() << "done initializing KD"; + eventMutex->release(); + + const KDEvent *event; + while ((event = kdWaitEvent(-1)) != 0) { + qDebug() << "!!! received event!"; + kdDefaultEvent(event); + } + + qDebug() << "exiting event loop"; + } + +private: + QSemaphore *eventMutex; +}; + +QOpenKODEGraphicsSystem::QOpenKODEGraphicsSystem() + : eventMutex(1) +{ + QOpenKODEEventLoopHelper *loop = new QOpenKODEEventLoopHelper(&eventMutex); + loop->start(); + eventMutex.acquire(); // block until initialization done + + mPrimaryScreen = new QOpenKODEGraphicsSystemScreen(); + + mScreens.append(mPrimaryScreen); + +} + +QPixmapData *QOpenKODEGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QOpenKODEGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + return new QOpenKODEWindowSurface(mPrimaryScreen, widget); +} + +GLuint QOpenKODEGraphicsSystem::blitterProgram() +{ + static GLuint shaderProgram = 0; + if (!shaderProgram) { + + const char vertShaderBinary[] = { +# include "vert.h" + }; + const char fragShaderBinary[] = { +# include "frag.h" + }; + + shaderProgram = NvKdTestLoadShaders(vertShaderBinary, fragShaderBinary, + sizeof(vertShaderBinary), sizeof(fragShaderBinary)); + + if (!shaderProgram) + qFatal("QOpenKodeGraphicsSystem(): Cannot load shaders!"); + } + return shaderProgram; +} + + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qgraphicssystem_openkode.h b/src/plugins/platforms/openkode/qgraphicssystem_openkode.h new file mode 100644 index 0000000..7d73ae0 --- /dev/null +++ b/src/plugins/platforms/openkode/qgraphicssystem_openkode.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_OPENKODE_H +#define QGRAPHICSSYSTEM_OPENKODE_H + +#include + +#include +#include + +# include + +QT_BEGIN_NAMESPACE + +struct KDDesktopNV; + +class QOpenKODEGraphicsSystemScreen : public QGraphicsSystemScreen +{ +public: + QOpenKODEGraphicsSystemScreen(); + ~QOpenKODEGraphicsSystemScreen() {} + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; + QEglContext mContext; +}; + +class QOpenKODEGraphicsSystem : public QGraphicsSystem +{ +public: + QOpenKODEGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList screens() const { return mScreens; } + + static GLuint blitterProgram(); + +private: + QOpenKODEGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; + QSemaphore eventMutex; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/openkode/qwindowsurface_openkode.cpp b/src/plugins/platforms/openkode/qwindowsurface_openkode.cpp new file mode 100644 index 0000000..b3f3965 --- /dev/null +++ b/src/plugins/platforms/openkode/qwindowsurface_openkode.cpp @@ -0,0 +1,265 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsurface_openkode.h" +#include "qgraphicssystem_openkode.h" +#include + +#include "KD/kd.h" +#include "KD/NV_display.h" + +QT_BEGIN_NAMESPACE + +QOpenKODEWindowSurface::QOpenKODEWindowSurface + (QOpenKODEGraphicsSystemScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen), + mSurface(0) +{ + qDebug() << "QOpenKODEWindowSurface::QOpenKODEWindowSurface:" << window << window->width() << "x" << window->height() + << "pos" << window->x() << "x" << window->y(); + + if (!mContext.display()) { + qWarning("qEglContext: Unable to open display!"); + return; + } + + QEglProperties properties; + properties.setPixelFormat(QImage::Format_RGB888); + properties.setValue(EGL_BUFFER_SIZE, EGL_DONT_CARE); + properties.setRenderableType(QEgl::OpenGL); + + if (!mContext.chooseConfig(properties, QEgl::BestPixelFormat)) { + qWarning("qEglContext: Unable to choose config!"); + return; + } + + createWindow(window); +} + +void QOpenKODEWindowSurface::createWindow(QWidget *window) +{ + qDebug() << "createWindow"; + kdWindow = kdCreateWindow(mContext.display(), mContext.config(), KD_NULL); + + if (!kdWindow) { + qErrnoWarning(kdGetError(), "Error creating native window"); + return; + } + + const KDint windowSize[2] = { window->width(), window->height() }; + if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { + qErrnoWarning(kdGetError(), "Could not set native window size"); + return; + } + + //const KDboolean windowExclusive[] = { false }; + //if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, windowExclusive)) { + // qErrnoWarning(kdGetError(), "Could not set exclusive bit"); + // //return; + //} + + //const KDint windowPos[2] = { window->x(), window->y() }; + //if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { + // qErrnoWarning(kdGetError(), "Could not set native window position"); + // //return; + //} + + EGLNativeWindowType nativeWindow; + + if (kdRealizeWindow(kdWindow, &nativeWindow)) { + qErrnoWarning(kdGetError(), "Could not realize native window"); + return; + } + qDebug() << "kdRealizeWindow" << nativeWindow; + + // Create an EGL window surface for the native window + EGLint windowAttrs[3] = { EGL_NONE }; + qDebug() << "doing createwindowsurface"; + *mSurface = eglCreateWindowSurface(mContext.display(), + mContext.config(), + nativeWindow, + windowAttrs); + qDebug() << "create windowsurface"; + if (!mSurface) { + qWarning("EGL couldn't create window surface: 0x%x", eglGetError()); + return; + } + + qDebug() << "making context"; + if (!mContext.createContext()) { + qDebug() << "Unable to create context!"; + return; + } + + qDebug() << "about to make current"; + mContext.makeCurrent(mSurface); +} + +QOpenKODEWindowSurface::~QOpenKODEWindowSurface() +{ +} + +QPaintDevice *QOpenKODEWindowSurface::paintDevice() +{ + qDebug() << "QOpenKODEWindowSurface::paintDevice"; + return &mImage; +} + +// ### TODO - this updates the entire toplevel, should only update the region +void QOpenKODEWindowSurface::flush(QWidget *, const QRegion ®ion, const QPoint &offset) +{ + qDebug() << "in flush"; + if (!offset.isNull()) { + qWarning("Offset flushing not supported yet"); + return; + } + + if (!mContext.makeCurrent(mSurface)) { + qWarning("EGL couldn't make context/surface current: 0x%x", eglGetError()); + return; + } + + QRect boundingRect = region.boundingRect(); + + int x, y, w, h; + QImage blitImage; + if (true || boundingRect == mImage.rect()) { // TODO - check optimization + blitImage = mImage; + x = y = 0; + w = mImage.width(); + h = mImage.height(); + } else { + blitImage = mImage.copy(boundingRect); + w = boundingRect.width(); + h = boundingRect.height(); + x = boundingRect.x(); + y = boundingRect.y(); + } + +// qDebug() << "flush" << widget << offset << region.boundingRect() << mImage.format() << blitImage.format(); + + GLuint shaderProgram = QOpenKODEGraphicsSystem::blitterProgram(); + + glUseProgram(shaderProgram); + + GLuint index = glGetUniformLocation(shaderProgram, "window"); + glUniform2f(index, GLfloat(mImage.width()), GLfloat(mImage.height())); + + // attributes + GLuint posId = glGetAttribLocation(shaderProgram, "pos_attr"); + GLuint texcoordId = glGetAttribLocation(shaderProgram, "texcoord_attr"); + + // sampler + index = glGetUniformLocation(shaderProgram, "tex_samp"); + + glUniform1i(index, 0); + + glDisable(GL_DEPTH_TEST); + glActiveTexture(GL_TEXTURE0); + + GLuint texId; + GLfloat coords[8] = {x, y, x, y + h, x + w, y + h, x + w, y }; + GLfloat texcoords[8] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0 }; + + // Generate texture for checkered background + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glGenTextures(1, &texId); + glBindTexture(GL_TEXTURE_2D, texId); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, blitImage.bits()); + + // Enable vertex attribute associated with vertex position + glEnableVertexAttribArray(posId); + glEnableVertexAttribArray(texcoordId); + + // Set the quad vertices + glVertexAttribPointer(posId, 2, GL_FLOAT, 0, 0, coords); + glVertexAttribPointer(texcoordId, 2, GL_FLOAT, 0, 0, texcoords); + + // Draw the quad + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + + // Cleanup + glDisableVertexAttribArray(posId); + glDisableVertexAttribArray(texcoordId); + + // Release all textures + glBindTexture(GL_TEXTURE_2D, 0); + if (texId) + glDeleteTextures(1, &texId); + + mContext.doneCurrent(); + mContext.swapBuffers(mSurface); +} + +void QOpenKODEWindowSurface::setGeometry(const QRect &rect) +{ + qDebug() << "QOpenKODEWindowSurface::setGeometry:" << rect; + QWindowSurface::setGeometry(rect); + if (mImage.size() != rect.size()) + mImage = QImage(rect.size(), mScreen->format()); + + mContext.destroySurface(mSurface); + kdDestroyWindow(kdWindow); + createWindow(window()); + qDebug() << "set geometry workded"; +} + +bool QOpenKODEWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QOpenKODEWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QOpenKODEWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qwindowsurface_openkode.h b/src/plugins/platforms/openkode/qwindowsurface_openkode.h new file mode 100644 index 0000000..bee94a5 --- /dev/null +++ b/src/plugins/platforms/openkode/qwindowsurface_openkode.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_OPENKODE_H +#define QWINDOWSURFACE_OPENKODE_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QOpenKODEGraphicsSystemScreen; + +class QOpenKODEWindowSurface : public QWindowSurface +{ +public: + QOpenKODEWindowSurface + (QOpenKODEGraphicsSystemScreen *screen, QWidget *window); + ~QOpenKODEWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + +private: + QOpenKODEGraphicsSystemScreen *mScreen; + QImage mImage; + struct KDWindow *kdWindow; + EGLSurface *mSurface; + QEglContext mContext; + + void createWindow(QWidget *window); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/openkode/vert.glslv b/src/plugins/platforms/openkode/vert.glslv new file mode 100644 index 0000000..57b5866 --- /dev/null +++ b/src/plugins/platforms/openkode/vert.glslv @@ -0,0 +1,14 @@ +uniform vec2 window; // window size + +// Per-vertex attributes] +attribute vec2 pos_attr; +attribute vec2 texcoord_attr; + +// Output vertex color +varying vec2 texcoord_var; + +void main() +{ + gl_Position = vec4( (2.0 * pos_attr / window -1.0) * vec2(1.0, -1.0), 0.0, 1.0); + texcoord_var = texcoord_attr; +} diff --git a/src/plugins/platforms/openkode/vert.h b/src/plugins/platforms/openkode/vert.h new file mode 100644 index 0000000..bdf564d --- /dev/null +++ b/src/plugins/platforms/openkode/vert.h @@ -0,0 +1,63 @@ +0x4e,0x56,0x75,0x63,0x01,0x00,0x00,0x00,0x0a,0x00,0x06,0x00,0x06,0x00,0x50,0x00, +0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0xf0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x60,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x24,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x70,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x26,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0xe8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0xb0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x28,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x10,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x20,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x30,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x2b,0x00,0x00,0x00,0x39,0x01,0x00,0x00,0xb0,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x05,0x08,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0f,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x01,0x02,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xff,0xff,0xff,0xff,0x04,0x05,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x80,0x3f,0x00,0x00,0x00,0x40,0x00,0x00,0x80,0xbf,0x00,0x00,0x00,0x00, +0x05,0x00,0x00,0x10,0x80,0xc7,0x00,0x24,0x05,0x02,0x00,0x10,0x80,0xc7,0x00,0x24, +0x01,0x02,0x81,0xc0,0x80,0x07,0x60,0x00,0x05,0x02,0x00,0x90,0x80,0x07,0x00,0x00, +0x09,0x00,0x01,0xe1,0x80,0x87,0x40,0x00,0x05,0x00,0x00,0x10,0x80,0xc7,0x00,0x24, +0x01,0x00,0x81,0xc0,0x80,0x07,0x60,0x00,0x09,0x04,0x00,0xa0,0x80,0x47,0x00,0xe4, +0x05,0x02,0x00,0x90,0x80,0x07,0x00,0x00,0x05,0x04,0x00,0x10,0x88,0xc7,0x03,0x04, +0x01,0x00,0x01,0xe1,0x88,0x87,0x40,0x00,0x09,0xf8,0x00,0x10,0x88,0xc7,0x03,0x04, +0x0d,0x00,0x00,0x10,0x88,0xc7,0x40,0x24,0x11,0x04,0x00,0x10,0x88,0xc7,0x23,0x04, +0x15,0x06,0x00,0x10,0x89,0xc7,0x23,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xa1,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0xad,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x28,0x00,0x02,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0xb6,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xb7,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0xbe,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x05,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xbf,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0xc9,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xca,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xcb,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0xd9,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0xda,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xdb,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0xe8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x02,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +0x00,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x50,0x4f,0x53, +0x49,0x54,0x49,0x4f,0x4e,0x00,0x00,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x00,0x00, +0x70,0x6f,0x73,0x5f,0x61,0x74,0x74,0x72,0x00,0x00,0x00,0x74,0x65,0x78,0x63,0x6f, +0x6f,0x72,0x64,0x5f,0x61,0x74,0x74,0x72,0x00,0x00,0x00,0x74,0x65,0x78,0x63,0x6f, +0x6f,0x72,0x64,0x5f,0x76,0x61,0x72,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/src/plugins/platforms/openvglite/main.cpp b/src/plugins/platforms/openvglite/main.cpp new file mode 100644 index 0000000..dc0b4a8 --- /dev/null +++ b/src/plugins/platforms/openvglite/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qgraphicssystem_vglite.h" + +QT_BEGIN_NAMESPACE + +class QVGGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QVGGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "OpenVG"; + return list; +} + +QGraphicsSystem* QVGGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "openvg") + return new QVGLiteGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(openvg, QVGGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/openvglite/openvglite.pro b/src/plugins/platforms/openvglite/openvglite.pro new file mode 100644 index 0000000..9d7860a --- /dev/null +++ b/src/plugins/platforms/openvglite/openvglite.pro @@ -0,0 +1,12 @@ +TARGET = qvglitegraphicssystem +include(../../qpluginbase.pri) + +QT += openvg + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp qgraphicssystem_vglite.cpp qwindowsurface_vglite.cpp +HEADERS = qgraphicssystem_vglite.h qwindowsurface_vglite.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp new file mode 100644 index 0000000..41b2303 --- /dev/null +++ b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicssystem_vglite.h" +#include "qwindowsurface_vglite.h" +#include +#include +#include +#ifdef OPENVG_USBHP_INIT +extern "C" { +#include +}; +#endif + +QT_BEGIN_NAMESPACE + +QVGLiteGraphicsSystem::QVGLiteGraphicsSystem() + : w(0), h(0), d(0), dw(0), dh(0), physWidth(0), physHeight(0), + surface(0), context(0), rootWindow(0), + screenFormat(QImage::Format_RGB16), preservedSwap(false) +{ +#ifdef OPENVG_USBHP_INIT + initLibrary(); +#endif + + // The graphics system is also the screen definition. + mScreens.append(this); + + QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY")); + QStringList displayArgs = displaySpec.split(QLatin1Char(':')); + + // Initialize EGL and create the global EGL context. + context = qt_vg_create_context(0); + if (!context) { + qFatal("QVGLiteGraphicsSystem: could not initialize EGL"); + return; + } + + // Get the root window handle to use. Default to zero. + QRegExp winidRx(QLatin1String("winid=?(\\d+)")); + int winidIdx = displayArgs.indexOf(winidRx); + int handle = 0; + if (winidIdx >= 0) { + winidRx.exactMatch(displayArgs.at(winidIdx)); + handle = winidRx.cap(1).toInt(); + } + + // Create a full-screen window based on the native handle. + // If the context is premultiplied, the window should be too. + QEglProperties props; +#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT + EGLint surfaceType = 0; + if (context->configAttrib(EGL_SURFACE_TYPE, &surfaceType) && + (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) != 0) + props.setValue(EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE); +#endif + rootWindow = eglCreateWindowSurface + (context->display(), context->config(), + (EGLNativeWindowType)handle, props.properties()); + if (rootWindow == EGL_NO_SURFACE) { + delete context; + context = 0; + qFatal("QVGLiteGraphicsSystem: could not create full-screen window"); + return; + } + + // Try to turn on preserved swap behaviour on the root window. + // This will allow us to optimize compositing to focus on just + // the screen region that has changed. Otherwise we must + // re-composite the entire screen every frame. +#if !defined(QVG_NO_PRESERVED_SWAP) + eglGetError(); // Clear error state first. + eglSurfaceAttrib(context->display(), rootWindow, + EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); + preservedSwap = (eglGetError() == EGL_SUCCESS); +#else + preservedSwap = false; +#endif + + // Fetch the root window properties. + eglQuerySurface(context->display(), rootWindow, EGL_WIDTH, &w); + eglQuerySurface(context->display(), rootWindow, EGL_HEIGHT, &h); + screenFormat = qt_vg_config_to_image_format(context); + switch (screenFormat) { + case QImage::Format_ARGB32_Premultiplied: + case QImage::Format_ARGB32: + case QImage::Format_RGB32: + default: + d = 32; + break; + case QImage::Format_RGB16: + case QImage::Format_ARGB4444_Premultiplied: + d = 16; + break; + } + dw = w; + dh = h; + qDebug("screen size: %dx%dx%d", w, h, d); + + // Handle display physical size spec. From qscreenlinuxfb_qws.cpp. + QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)")); + int dimIdxW = displayArgs.indexOf(mmWidthRx); + QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)")); + int dimIdxH = displayArgs.indexOf(mmHeightRx); + if (dimIdxW >= 0) { + mmWidthRx.exactMatch(displayArgs.at(dimIdxW)); + physWidth = mmWidthRx.cap(1).toInt(); + if (dimIdxH < 0) + physHeight = dh*physWidth/dw; + } + if (dimIdxH >= 0) { + mmHeightRx.exactMatch(displayArgs.at(dimIdxH)); + physHeight = mmHeightRx.cap(1).toInt(); + if (dimIdxW < 0) + physWidth = dw*physHeight/dh; + } + if (dimIdxW < 0 && dimIdxH < 0) { + const int dpi = 72; + physWidth = qRound(dw * 25.4 / dpi); + physHeight = qRound(dh * 25.4 / dpi); + } +} + +QVGLiteGraphicsSystem::~QVGLiteGraphicsSystem() +{ +} + +QPixmapData *QVGLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ +#if !defined(QVGLite_NO_SINGLE_CONTEXT) && !defined(QVGLite_NO_PIXMAP_DATA) + // Pixmaps can use QVGLitePixmapData; bitmaps must use raster. + if (type == QPixmapData::PixmapType) + return new QVGPixmapData(type); + else + return new QRasterPixmapData(type); +#else + return new QRasterPixmapData(type); +#endif +} + +QWindowSurface *QVGLiteGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + if (widget->windowType() == Qt::Desktop) + return 0; // Don't create an explicit window surface for the destkop. + if (surface) { + qWarning() << "QVGLiteGraphicsSystem: only one window surface " + "is supported at a time"; + return 0; + } + surface = new QVGLiteWindowSurface + (const_cast(this), widget); + return surface; +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h new file mode 100644 index 0000000..512793d --- /dev/null +++ b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_VGLITE_H +#define QGRAPHICSSYSTEM_VGLITE_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QVGLiteWindowSurface; + +class QVGLiteGraphicsSystem : public QGraphicsSystem, + public QGraphicsSystemScreen +{ +public: + QVGLiteGraphicsSystem(); + ~QVGLiteGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + QList screens() const { return mScreens; } + + QRect geometry() const { return QRect(0, 0, w, h); } + int depth() const { return d; } + QImage::Format format() const { return screenFormat; } + QSize physicalSize() const { return QSize(physWidth, physHeight); } + +private: + friend class QVGLiteWindowSurface; + + int w; + int h; + int d; + + int dw; + int dh; + + int physWidth; + int physHeight; + + mutable QVGLiteWindowSurface *surface; + QEglContext *context; + EGLSurface rootWindow; + QImage::Format screenFormat; + bool preservedSwap; + + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp b/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp new file mode 100644 index 0000000..c73e35a --- /dev/null +++ b/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsurface_vglite.h" +#include "qgraphicssystem_vglite.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QVGLiteWindowSurface::QVGLiteWindowSurface + (QVGLiteGraphicsSystem *gs, QWidget *window) + : QWindowSurface(window), graphicsSystem(gs), + isPaintingActive(false), engine(0) +{ +} + +QVGLiteWindowSurface::~QVGLiteWindowSurface() +{ + graphicsSystem->surface = 0; + if (engine) + qt_vg_destroy_paint_engine(engine); +} + +QPaintDevice *QVGLiteWindowSurface::paintDevice() +{ + qt_vg_make_current(graphicsSystem->context, graphicsSystem->rootWindow); + isPaintingActive = true; + // TODO: clear the parts of the back buffer that are not + // covered by the window surface to black. + return this; +} + +void QVGLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); + QEglContext *context = graphicsSystem->context; + if (context) { + if (!isPaintingActive) + qt_vg_make_current(context, graphicsSystem->rootWindow); + context->swapBuffers(); + qt_vg_done_current(context); + context->setSurface(EGL_NO_SURFACE); + isPaintingActive = false; + } +} + +void QVGLiteWindowSurface::setGeometry(const QRect &rect) +{ + QWindowSurface::setGeometry(rect); +} + +bool QVGLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QVGLiteWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QVGLiteWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +QPaintEngine *QVGLiteWindowSurface::paintEngine() const +{ + if (!engine) + engine = qt_vg_create_paint_engine(); + return engine; +} + +// We need to get access to QWidget::metric() from QVGLiteWindowSurface::metric, +// but it is not a friend of QWidget. To get around this, we create a +// fake QX11PaintEngine class, which is a friend. +class QX11PaintEngine +{ +public: + static int metric(const QWidget *widget, QPaintDevice::PaintDeviceMetric met) + { + return widget->metric(met); + } +}; + +int QVGLiteWindowSurface::metric(PaintDeviceMetric met) const +{ + return QX11PaintEngine::metric(window(), met); +} diff --git a/src/plugins/platforms/openvglite/qwindowsurface_vglite.h b/src/plugins/platforms/openvglite/qwindowsurface_vglite.h new file mode 100644 index 0000000..59faba8 --- /dev/null +++ b/src/plugins/platforms/openvglite/qwindowsurface_vglite.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_VGLITE_H +#define QWINDOWSURFACE_VGLITE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QVGLiteGraphicsSystem; +class QVGPaintEngine; + +class Q_OPENVG_EXPORT QVGLiteWindowSurface : public QWindowSurface, public QPaintDevice +{ +public: + QVGLiteWindowSurface(QVGLiteGraphicsSystem *gs, QWidget *window); + ~QVGLiteWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + + QPaintEngine *paintEngine() const; + +protected: + int metric(PaintDeviceMetric metric) const; + +private: + QVGLiteGraphicsSystem *graphicsSystem; + bool isPaintingActive; + mutable QVGPaintEngine *engine; +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSURFACE_VGLITE_H diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro new file mode 100644 index 0000000..9688443 --- /dev/null +++ b/src/plugins/platforms/platforms.pro @@ -0,0 +1,14 @@ +TEMPLATE = subdirs +contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl) { + embedded_lite { + SUBDIRS += openvglite + } +} + +embedded_lite { + SUBDIRS += minimal +} + +embedded_lite:x11 { + SUBDIRS += testlite +} diff --git a/src/plugins/platforms/qvfb/main.cpp b/src/plugins/platforms/qvfb/main.cpp new file mode 100644 index 0000000..b28dde8 --- /dev/null +++ b/src/plugins/platforms/qvfb/main.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qgraphicssystem_qvfb.h" +#include + +QT_BEGIN_NAMESPACE + +class QVFbGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QVFbGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "QVFb"; + return list; +} + +QGraphicsSystem* QVFbGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "qvfb") + return new QVFbGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(qvfb, QVFbGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.cpp b/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.cpp new file mode 100644 index 0000000..19058a6 --- /dev/null +++ b/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.cpp @@ -0,0 +1,434 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include // overrides QT_OPEN + +#include +#include + +#include "qgraphicssystem_qvfb.h" +#include "qwindowsurface_qvfb.h" +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + + +class QVFbGraphicsSystemScreenKeyboardHandler : public QObject +{ + Q_OBJECT +public: + QVFbGraphicsSystemScreenKeyboardHandler(); + ~QVFbGraphicsSystemScreenKeyboardHandler(); + +private slots: + void readKeyboardData(); + +private: + int kbdFD; + int kbdIdx; + int kbdBufferLen; + unsigned char *kbdBuffer; + QSocketNotifier *keyNotifier; +}; + +QVFbGraphicsSystemScreenKeyboardHandler::QVFbGraphicsSystemScreenKeyboardHandler() +{ + int displayId = 0; //TODO displayId + const QString keyboardDev = QT_VFB_KEYBOARD_PIPE(displayId); + + + kbdFD = -1; + kbdIdx = 0; + kbdBufferLen = sizeof(QVFbKeyData) * 5; + kbdBuffer = new unsigned char [kbdBufferLen]; + + kbdFD = QT_OPEN(keyboardDev.toLatin1().constData(), O_RDWR | O_NDELAY); + + if (kbdFD == -1) { + perror("QVFbGraphicsSystemScreenKeyboardHandler"); + qWarning("QVFbGraphicsSystemScreenKeyboardHandler: Unable to open device %s", + qPrintable(keyboardDev)); + return; + } + + // Clear pending input + char buf[2]; + while (QT_READ(kbdFD, buf, 1) > 0) { } + + keyNotifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this); + connect(keyNotifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData())); + +} + +QVFbGraphicsSystemScreenKeyboardHandler::~QVFbGraphicsSystemScreenKeyboardHandler() +{ + if (kbdFD >= 0) + QT_CLOSE(kbdFD); + delete [] kbdBuffer; +} + + +void QVFbGraphicsSystemScreenKeyboardHandler::readKeyboardData() +{ + int n; + do { + n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx); + if (n > 0) + kbdIdx += n; + } while (n > 0); + + int idx = 0; + while (kbdIdx - idx >= (int)sizeof(QVFbKeyData)) { + QVFbKeyData *kd = (QVFbKeyData *)(kbdBuffer + idx); + if (kd->unicode == 0 && kd->keycode == 0 && kd->modifiers == 0 && kd->press) { + // magic exit key + qWarning("Instructed to quit by Virtual Keyboard"); + qApp->quit(); + } + + //QWSServer::processKeyEvent(kd->unicode ? kd->unicode : 0xffff, kd->keycode, kd->modifiers, kd->press, kd->repeat); + + QEvent::Type type = kd->press ? QEvent::KeyPress : QEvent::KeyRelease; + + QString text; + if (kd->unicode && kd->unicode != 0xffff) + text += QChar(kd->unicode); + +// qDebug() << "readKeyboardData" << type << hex << kd->keycode << kd->modifiers << text; + + QWindowSystemInterface::handleKeyEvent(0, type, kd->keycode, kd->modifiers, text, kd->repeat, int(text.length())); + idx += sizeof(QVFbKeyData); + } + + int surplus = kbdIdx - idx; + for (int i = 0; i < surplus; i++) + kbdBuffer[i] = kbdBuffer[idx+i]; + kbdIdx = surplus; +} + + + + +class QVFbGraphicsSystemScreenMouseHandler : public QObject +{ + Q_OBJECT +public: + QVFbGraphicsSystemScreenMouseHandler(); + ~QVFbGraphicsSystemScreenMouseHandler(); + +private slots: + void readMouseData(); + +private: + int mouseFD; + int mouseIdx; + enum {mouseBufSize = 128}; + uchar mouseBuf[mouseBufSize]; + QSocketNotifier *mouseNotifier; + + int oldButtonState; +}; + +QVFbGraphicsSystemScreenMouseHandler::QVFbGraphicsSystemScreenMouseHandler() +{ + int displayId = 0; //TODO: displayId + QString mouseDev = QT_VFB_MOUSE_PIPE(displayId); + + mouseFD = QT_OPEN(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY); + + if (mouseFD == -1) { + perror("QVFbMouseHandler::QVFbMouseHandler"); + qWarning("QVFbMouseHander: Unable to open device %s", + qPrintable(mouseDev)); + return; + } + + // Clear pending input + char buf[2]; + while (QT_READ(mouseFD, buf, 1) > 0) { } + + mouseIdx = 0; + oldButtonState = 0; + mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this); + connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData())); +} + + +QVFbGraphicsSystemScreenMouseHandler::~QVFbGraphicsSystemScreenMouseHandler() +{ + if (mouseFD >= 0) + QT_CLOSE(mouseFD); +} + +void QVFbGraphicsSystemScreenMouseHandler::readMouseData() +{ + int n; + do { + n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx); + if (n > 0) + mouseIdx += n; + } while (n > 0); + + int idx = 0; + static const int packetsize = sizeof(QPoint) + 2*sizeof(int); + while (mouseIdx-idx >= packetsize) { + uchar *mb = mouseBuf+idx; + QPoint mousePos = *reinterpret_cast(mb); + mb += sizeof(QPoint); + int bstate = *reinterpret_cast(mb); + mb += sizeof(int); + int wheel = *reinterpret_cast(mb); + + int button = bstate ^ oldButtonState; + QEvent::Type type = QEvent::MouseMove; + + if (button) { + type = (button & bstate) ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; + } + QWindowSystemInterface::handleMouseEvent(0, mousePos, mousePos, Qt::MouseButtons(bstate)); + +// qDebug() << "readMouseData" << mousePos << button << bstate << oldButtonState << type; + + oldButtonState = bstate; + + idx += packetsize; + } + + int surplus = mouseIdx - idx; + for (int i = 0; i < surplus; i++) + mouseBuf[i] = mouseBuf[idx+i]; + mouseIdx = surplus; + +} + + +class QVFbGraphicsSystemScreenPrivate +{ +public: + QVFbGraphicsSystemScreenPrivate(QVFbGraphicsSystemScreen *) + : shmrgn(0), hdr(0), data(0), mouseHandler(0), keyboardHandler(0) + { + connect(0); //for now we only handle one screen + } + + ~QVFbGraphicsSystemScreenPrivate() { disconnect(); } + void setDirty(const QRect &r); + + bool connect(int displayId); + void disconnect(); + + QImage *screenImage() { return &img; } + QSize screenSize() { return img.size(); } + + int depth() const { return img.depth(); } + QImage::Format format() const { return img.format(); } + +private: + unsigned char *shmrgn; + QVFbHeader *hdr; + uchar *data; + QVFbGraphicsSystemScreenMouseHandler *mouseHandler; + QVFbGraphicsSystemScreenKeyboardHandler *keyboardHandler; + + + QImage img; +}; + + +void QVFbGraphicsSystemScreenPrivate::setDirty(const QRect &r) +{ + hdr->dirty = true; + hdr->update = hdr->update.united(r); +} + + +bool QVFbGraphicsSystemScreenPrivate::connect(int displayId) +{ + + key_t key = ftok(QT_VFB_MOUSE_PIPE(displayId).toLatin1(), 'b'); + + if (key == -1) + return false; + + + int shmId = shmget(key, 0, 0); + if (shmId != -1) + shmrgn = (unsigned char *)shmat(shmId, 0, 0); + else + return false; + + if ((long)shmrgn == -1 || shmrgn == 0) { + qDebug("No shmrgn %ld", (long)shmrgn); + return false; + } + + hdr = (QVFbHeader *)shmrgn; + data = shmrgn + hdr->dataoffset; + + int w = hdr->width; + int h = hdr->height; + int d = hdr->depth; + int lstep = hdr->linestep; + + QImage::Format format = QImage::Format_Invalid; + if (d == 32) + format = QImage::Format_ARGB32_Premultiplied; + else if (d == 16) + format = QImage::Format_RGB16; + + + if (format == QImage::Format_Invalid) { + img = QImage(); + return false; + } + + img = QImage(data, w, h, lstep, format); + + qDebug("connected %dx%d %d bpp", w, h, d); + + + mouseHandler = new QVFbGraphicsSystemScreenMouseHandler; + keyboardHandler = new QVFbGraphicsSystemScreenKeyboardHandler; + return true; +} + +void QVFbGraphicsSystemScreenPrivate::disconnect() +{ + if ((long)shmrgn != -1 && shmrgn) { + shmdt((char*)shmrgn); + shmrgn = 0; + } + delete mouseHandler; + mouseHandler = 0; + delete keyboardHandler; + keyboardHandler = 0; +} + + +QVFbGraphicsSystemScreen::QVFbGraphicsSystemScreen() +{ + d_ptr = new QVFbGraphicsSystemScreenPrivate(this); +} + + +QVFbGraphicsSystemScreen::~QVFbGraphicsSystemScreen() +{ + delete d_ptr; +} + +void QVFbGraphicsSystemScreen::setDirty(const QRect &rect) +{ + d_ptr->setDirty(rect); +} + + + +QRect QVFbGraphicsSystemScreen::geometry() const { + return QRect(QPoint(), d_ptr->screenSize()); +} + + +int QVFbGraphicsSystemScreen::depth() const +{ + return d_ptr->depth(); +} + +QImage::Format QVFbGraphicsSystemScreen::format() const +{ + return d_ptr->format(); +} + +QSize QVFbGraphicsSystemScreen::physicalSize() const { + return (d_ptr->screenSize()*254)/720; +} + +#if 0 +int QVFbGraphicsSystemScreen::linestep() const { + return d_ptr->screenImage() ? d_ptr->screenImage()->bytesPerLine() : 0; +} + +uchar *QVFbGraphicsSystemScreen::base() const { + return d_ptr->screenImage() ? d_ptr->screenImage()->bits() : 0; +} +#endif + +QImage *QVFbGraphicsSystemScreen::screenImage() +{ + return d_ptr->screenImage(); +} + +QVFbGraphicsSystem::QVFbGraphicsSystem() +{ + mPrimaryScreen = new QVFbGraphicsSystemScreen(); + + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QVFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QVFbGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + if (widget->windowType() == Qt::Desktop) + return 0; // Don't create an explicit window surface for the destkop. + return new QVFbWindowSurface + (const_cast(this), mPrimaryScreen, widget); +} + +QT_END_NAMESPACE + +#include "qgraphicssystem_qvfb.moc" diff --git a/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h b/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h new file mode 100644 index 0000000..b31869c --- /dev/null +++ b/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_QVFB_H +#define QGRAPHICSSYSTEM_QVFB_H + +#include + +QT_BEGIN_NAMESPACE + + +class QVFbGraphicsSystemScreenPrivate; + +class QVFbGraphicsSystemScreen : public QGraphicsSystemScreen +{ +public: + QVFbGraphicsSystemScreen(); + ~QVFbGraphicsSystemScreen(); + + QRect geometry() const; + int depth() const; + QImage::Format format() const; + QSize physicalSize() const; + + QImage *screenImage(); + + void setDirty(const QRect &rect); + +public: + + QVFbGraphicsSystemScreenPrivate *d_ptr; +}; + +class QVFbGraphicsSystemPrivate; + + +class QVFbGraphicsSystem : public QGraphicsSystem +{ +public: + QVFbGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList screens() const { return mScreens; } + +private: + QVFbGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; +}; + + + +QT_END_NAMESPACE + + +#endif diff --git a/src/plugins/platforms/qvfb/qvfb.pro b/src/plugins/platforms/qvfb/qvfb.pro new file mode 100644 index 0000000..b321725 --- /dev/null +++ b/src/plugins/platforms/qvfb/qvfb.pro @@ -0,0 +1,12 @@ +TARGET = qvfbgraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + + + +SOURCES = main.cpp qgraphicssystem_qvfb.cpp qwindowsurface_qvfb.cpp +HEADERS = qgraphicssystem_qvfb.h qwindowsurface_qvfb.h + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp new file mode 100644 index 0000000..0aafe28 --- /dev/null +++ b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "qwindowsurface_qvfb.h" +#include "qgraphicssystem_qvfb.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QVFbWindowSurface::QVFbWindowSurface(QVFbGraphicsSystem *graphicsSystem, + QVFbGraphicsSystemScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen) +{ +} + +QVFbWindowSurface::~QVFbWindowSurface() +{ +} + +QPaintDevice *QVFbWindowSurface::paintDevice() +{ + return mScreen->screenImage(); +} + +void QVFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(offset); + + QRect rect = geometry(); + QPoint topLeft = rect.topLeft(); + + mScreen->setDirty(region.boundingRect()); +} + +void QVFbWindowSurface::setGeometry(const QRect &) +{ + +// any size you like as long as it's full-screen... + + QRect rect(mScreen->availableGeometry()); + QWindowSystemInterface::handleGeometryChange(this->window(), rect); + + QWindowSurface::setGeometry(rect); +} + +bool QVFbWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QVFbWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QVFbWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h new file mode 100644 index 0000000..1971caa --- /dev/null +++ b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_QVFB_H +#define QWINDOWSURFACE_QVFB_H + +#include + +QT_BEGIN_NAMESPACE + +class QVFbGraphicsSystem; +class QVFbGraphicsSystemScreen; + +class QVFbWindowSurface : public QWindowSurface +{ +public: + QVFbWindowSurface(QVFbGraphicsSystem *graphicsSystem, + QVFbGraphicsSystemScreen *screen, QWidget *window); + ~QVFbWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + +private: + QVFbGraphicsSystem *mGraphicsSystem; + QVFbGraphicsSystemScreen *mScreen; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/testlite/main.cpp b/src/plugins/platforms/testlite/main.cpp new file mode 100644 index 0000000..28caea7 --- /dev/null +++ b/src/plugins/platforms/testlite/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qgraphicssystem_testlite.h" + +QT_BEGIN_NAMESPACE + +class QTestLiteGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QTestLiteGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "TestLite"; + return list; +} + +QGraphicsSystem* QTestLiteGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "testlite") + return new QTestLiteGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(testlite, QTestLiteGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qgraphicssystem_testlite.cpp b/src/plugins/platforms/testlite/qgraphicssystem_testlite.cpp new file mode 100644 index 0000000..92e0ebc --- /dev/null +++ b/src/plugins/platforms/testlite/qgraphicssystem_testlite.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicssystem_testlite.h" +#include "qwindowsurface_testlite.h" +#include +#include + +#include + + +#include "x11util.h" + +QT_BEGIN_NAMESPACE + +class MyCursor : QGraphicsSystemCursor +{ +public: + MyCursor(QGraphicsSystemScreen *screen) : QGraphicsSystemCursor(screen) {} + + void changeCursor(QCursor * cursor, QWidget * widget) { + QTestLiteWindowSurface *ws = 0; + if (widget) { + QWidget *window = widget->window(); + ws = static_cast(window->windowSurface()); + } else { + // No X11 cursor control when there is no widget under the cursor + return; + } + + //qDebug() << "changeCursor" << widget << ws; + if (!ws) + return; + + ws->setCursor(cursor); + } +}; + + +QTestLiteGraphicsSystem::QTestLiteGraphicsSystem() +{ + + xd = new MyDisplay; + + mPrimaryScreen = new QTestLiteGraphicsSystemScreen(); + + mPrimaryScreen->mGeometry = QRect + (0, 0, xd->width, xd->height); + mPrimaryScreen->mDepth = 32; + mPrimaryScreen->mFormat = QImage::Format_RGB32; + mPrimaryScreen->mPhysicalSize = + QSize(xd->physicalWidth, xd->physicalHeight); + + mScreens.append(mPrimaryScreen); + + + (void)new MyCursor(mPrimaryScreen); + +} + +QPixmapData *QTestLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QTestLiteGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + if (widget->windowType() == Qt::Desktop) + return 0; // Don't create an explicit window surface for the destkop. + return new QTestLiteWindowSurface + (const_cast(this), mPrimaryScreen, widget); +} + + +QPixmap QTestLiteGraphicsSystem::grabWindow(WId window, int x, int y, int width, int height) const +{ + QImage img = xd->grabWindow(window, x, y, width, height); + return QPixmap::fromImage(img); +} + + + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qgraphicssystem_testlite.h b/src/plugins/platforms/testlite/qgraphicssystem_testlite.h new file mode 100644 index 0000000..b2cd496 --- /dev/null +++ b/src/plugins/platforms/testlite/qgraphicssystem_testlite.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_TESTLITE_H +#define QGRAPHICSSYSTEM_TESTLITE_H + +#include + +QT_BEGIN_NAMESPACE + +class MyDisplay; + +class QTestLiteGraphicsSystemScreen : public QGraphicsSystemScreen +{ +public: + QTestLiteGraphicsSystemScreen() + : mDepth(16), mFormat(QImage::Format_RGB16) {} + ~QTestLiteGraphicsSystemScreen() {} + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; +}; + +class QTestLiteGraphicsSystem : public QGraphicsSystem +{ +public: + QTestLiteGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QPixmap grabWindow(WId window, int x, int y, int width, int height) const; + + QList screens() const { return mScreens; } + + MyDisplay *xd; + +private: + QTestLiteGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp new file mode 100644 index 0000000..c54f6eb --- /dev/null +++ b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp @@ -0,0 +1,661 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsurface_testlite.h" +#include "qgraphicssystem_testlite.h" + +#include +#include + +#include "x11util.h" + +QT_BEGIN_NAMESPACE + +QTestLiteWindowSurface::QTestLiteWindowSurface + (QTestLiteGraphicsSystem *graphicsSystem, + QTestLiteGraphicsSystemScreen *screen, QWidget *window) + : QWindowSurface(window), + mGraphicsSystem(graphicsSystem), + mScreen(screen), + xw(0) +{ + + + xw = new MyWindow(graphicsSystem->xd, 0,0,300,300); + xw->windowSurface = this; + +// qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window; + + setWindowFlags(window->windowFlags()); //##### This should not be the plugin's responsibility +} + +QTestLiteWindowSurface::~QTestLiteWindowSurface() +{ +// qDebug() << "~QTestLiteWindowSurface" << xw->window; + delete xw; +} + +QPaintDevice *QTestLiteWindowSurface::paintDevice() +{ + return xw->image(); +} + +void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); + + // qDebug() << "QTestLiteWindowSurface::flush:" << (long)this; + + xw->paintEvent(); +} + + +void QTestLiteWindowSurface::setGeometry(const QRect &rect) +{ + QRect oldRect = geometry(); + if (rect == oldRect) + return; + + QWindowSurface::setGeometry(rect); + + //if unchanged ### +// xw->setSize(rect.width(), rect.height()); + xw->setGeometry(rect.x(), rect.y(), rect.width(), rect.height()); +} + +//### scroll logic copied from QRasterWindowSurface, we should make better API for this + +void copied_qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) +{ + // make sure we don't detach + uchar *mem = const_cast(const_cast(img).bits()); + + int lineskip = img.bytesPerLine(); + int depth = img.depth() >> 3; + + const QRect imageRect(0, 0, img.width(), img.height()); + const QRect r = rect & imageRect & imageRect.translated(-offset); + const QPoint p = rect.topLeft() + offset; + + if (r.isEmpty()) + return; + + const uchar *src; + uchar *dest; + + if (r.top() < p.y()) { + src = mem + r.bottom() * lineskip + r.left() * depth; + dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth; + lineskip = -lineskip; + } else { + src = mem + r.top() * lineskip + r.left() * depth; + dest = mem + p.y() * lineskip + p.x() * depth; + } + + const int w = r.width(); + int h = r.height(); + const int bytes = w * depth; + + // overlapping segments? + if (offset.y() == 0 && qAbs(offset.x()) < w) { + do { + ::memmove(dest, src, bytes); + dest += lineskip; + src += lineskip; + } while (--h); + } else { + do { + ::memcpy(dest, src, bytes); + dest += lineskip; + src += lineskip; + } while (--h); + } +} + +bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + if (!xw->image() || xw->image()->isNull()) + return false; + + const QVector rects = area.rects(); + for (int i = 0; i < rects.size(); ++i) + copied_qt_scrollRectInImage(*xw->image(), rects.at(i), QPoint(dx, dy)); + + return true; +} + + +void QTestLiteWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); + xw->resizeBuffer(geometry().size()); +} + +void QTestLiteWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); + xw->painted = true; //there is content in the buffer +} + + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Mouse event stuff + + + + +static Qt::MouseButtons translateMouseButtons(int s) +{ + Qt::MouseButtons ret = 0; + if (s & Button1Mask) + ret |= Qt::LeftButton; + if (s & Button2Mask) + ret |= Qt::MidButton; + if (s & Button3Mask) + ret |= Qt::RightButton; + return ret; +} + + +static Qt::KeyboardModifiers translateModifiers(int s) +{ + const uchar qt_alt_mask = Mod1Mask; + const uchar qt_meta_mask = Mod4Mask; + + + Qt::KeyboardModifiers ret = 0; + if (s & ShiftMask) + ret |= Qt::ShiftModifier; + if (s & ControlMask) + ret |= Qt::ControlModifier; + if (s & qt_alt_mask) + ret |= Qt::AltModifier; + if (s & qt_meta_mask) + ret |= Qt::MetaModifier; +#if 0 + if (s & qt_mode_switch_mask) + ret |= Qt::GroupSwitchModifier; +#endif + return ret; +} + +void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) +{ + static QPoint mousePoint; + + XButtonEvent *e = static_cast(ev); + + Qt::MouseButton button = Qt::NoButton; + Qt::MouseButtons buttons = translateMouseButtons(e->state); + Qt::KeyboardModifiers modifiers = translateModifiers(e->state); + if (type != QEvent::MouseMove) { + switch (e->button) { + case Button1: button = Qt::LeftButton; break; + case Button2: button = Qt::MidButton; break; + case Button3: button = Qt::RightButton; break; + case Button4: + case Button5: + case 6: + case 7: { + //mouse wheel + if (type == QEvent::MouseButtonPress) { + //logic borrowed from qapplication_x11.cpp + int delta = 120 * ((e->button == Button4 || e->button == 6) ? 1 : -1); + bool hor = (((e->button == Button4 || e->button == Button5) + && (modifiers & Qt::AltModifier)) + || (e->button == 6 || e->button == 7)); + QWindowSystemInterface::handleWheelEvent(window(), e->time, + QPoint(e->x, e->y), + QPoint(e->x_root, e->y_root), + delta, hor ? Qt::Horizontal : Qt::Vertical); + } + return; + } + default: break; + } + } + + buttons ^= button; // X event uses state *before*, Qt uses state *after* + + QWindowSystemInterface::handleMouseEvent(window(), e->time, QPoint(e->x, e->y), + QPoint(e->x_root, e->y_root), + buttons); + + mousePoint = QPoint(e->x_root, e->y_root); +} + +void QTestLiteWindowSurface::handleGeometryChange(int x, int y, int w, int h) +{ + QWindowSystemInterface::handleGeometryChange(window(), QRect(x,y,w,h)); +} + + +void QTestLiteWindowSurface::handleCloseEvent() +{ + QWindowSystemInterface::handleCloseEvent(window()); +} + + +void QTestLiteWindowSurface::handleEnterEvent() +{ + QWindowSystemInterface::handleEnterEvent(window()); +} + +void QTestLiteWindowSurface::handleLeaveEvent() +{ + QWindowSystemInterface::handleLeaveEvent(window()); +} + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Key event stuff -- not pretty either +// +// What we want to do is to port Robert's keytable code properly + + + + + + + +// keyboard mapping table +static const unsigned int keyTbl[] = { + + // misc keys + + XK_Escape, Qt::Key_Escape, + XK_Tab, Qt::Key_Tab, + XK_ISO_Left_Tab, Qt::Key_Backtab, + XK_BackSpace, Qt::Key_Backspace, + XK_Return, Qt::Key_Return, + XK_Insert, Qt::Key_Insert, + XK_Delete, Qt::Key_Delete, + XK_Clear, Qt::Key_Delete, + XK_Pause, Qt::Key_Pause, + XK_Print, Qt::Key_Print, + 0x1005FF60, Qt::Key_SysReq, // hardcoded Sun SysReq + 0x1007ff00, Qt::Key_SysReq, // hardcoded X386 SysReq + + // cursor movement + + XK_Home, Qt::Key_Home, + XK_End, Qt::Key_End, + XK_Left, Qt::Key_Left, + XK_Up, Qt::Key_Up, + XK_Right, Qt::Key_Right, + XK_Down, Qt::Key_Down, + XK_Prior, Qt::Key_PageUp, + XK_Next, Qt::Key_PageDown, + + // modifiers + + XK_Shift_L, Qt::Key_Shift, + XK_Shift_R, Qt::Key_Shift, + XK_Shift_Lock, Qt::Key_Shift, + XK_Control_L, Qt::Key_Control, + XK_Control_R, Qt::Key_Control, + XK_Meta_L, Qt::Key_Meta, + XK_Meta_R, Qt::Key_Meta, + XK_Alt_L, Qt::Key_Alt, + XK_Alt_R, Qt::Key_Alt, + XK_Caps_Lock, Qt::Key_CapsLock, + XK_Num_Lock, Qt::Key_NumLock, + XK_Scroll_Lock, Qt::Key_ScrollLock, + XK_Super_L, Qt::Key_Super_L, + XK_Super_R, Qt::Key_Super_R, + XK_Menu, Qt::Key_Menu, + XK_Hyper_L, Qt::Key_Hyper_L, + XK_Hyper_R, Qt::Key_Hyper_R, + XK_Help, Qt::Key_Help, + 0x1000FF74, Qt::Key_Backtab, // hardcoded HP backtab + 0x1005FF10, Qt::Key_F11, // hardcoded Sun F36 (labeled F11) + 0x1005FF11, Qt::Key_F12, // hardcoded Sun F37 (labeled F12) + + // numeric and function keypad keys + + XK_KP_Space, Qt::Key_Space, + XK_KP_Tab, Qt::Key_Tab, + XK_KP_Enter, Qt::Key_Enter, + //XK_KP_F1, Qt::Key_F1, + //XK_KP_F2, Qt::Key_F2, + //XK_KP_F3, Qt::Key_F3, + //XK_KP_F4, Qt::Key_F4, + XK_KP_Home, Qt::Key_Home, + XK_KP_Left, Qt::Key_Left, + XK_KP_Up, Qt::Key_Up, + XK_KP_Right, Qt::Key_Right, + XK_KP_Down, Qt::Key_Down, + XK_KP_Prior, Qt::Key_PageUp, + XK_KP_Next, Qt::Key_PageDown, + XK_KP_End, Qt::Key_End, + XK_KP_Begin, Qt::Key_Clear, + XK_KP_Insert, Qt::Key_Insert, + XK_KP_Delete, Qt::Key_Delete, + XK_KP_Equal, Qt::Key_Equal, + XK_KP_Multiply, Qt::Key_Asterisk, + XK_KP_Add, Qt::Key_Plus, + XK_KP_Separator, Qt::Key_Comma, + XK_KP_Subtract, Qt::Key_Minus, + XK_KP_Decimal, Qt::Key_Period, + XK_KP_Divide, Qt::Key_Slash, + + // International input method support keys + + // International & multi-key character composition + XK_ISO_Level3_Shift, Qt::Key_AltGr, + XK_Multi_key, Qt::Key_Multi_key, + XK_Codeinput, Qt::Key_Codeinput, + XK_SingleCandidate, Qt::Key_SingleCandidate, + XK_MultipleCandidate, Qt::Key_MultipleCandidate, + XK_PreviousCandidate, Qt::Key_PreviousCandidate, + + // Misc Functions + XK_Mode_switch, Qt::Key_Mode_switch, + XK_script_switch, Qt::Key_Mode_switch, + + // Japanese keyboard support + XK_Kanji, Qt::Key_Kanji, + XK_Muhenkan, Qt::Key_Muhenkan, + //XK_Henkan_Mode, Qt::Key_Henkan_Mode, + XK_Henkan_Mode, Qt::Key_Henkan, + XK_Henkan, Qt::Key_Henkan, + XK_Romaji, Qt::Key_Romaji, + XK_Hiragana, Qt::Key_Hiragana, + XK_Katakana, Qt::Key_Katakana, + XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana, + XK_Zenkaku, Qt::Key_Zenkaku, + XK_Hankaku, Qt::Key_Hankaku, + XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku, + XK_Touroku, Qt::Key_Touroku, + XK_Massyo, Qt::Key_Massyo, + XK_Kana_Lock, Qt::Key_Kana_Lock, + XK_Kana_Shift, Qt::Key_Kana_Shift, + XK_Eisu_Shift, Qt::Key_Eisu_Shift, + XK_Eisu_toggle, Qt::Key_Eisu_toggle, + //XK_Kanji_Bangou, Qt::Key_Kanji_Bangou, + //XK_Zen_Koho, Qt::Key_Zen_Koho, + //XK_Mae_Koho, Qt::Key_Mae_Koho, + XK_Kanji_Bangou, Qt::Key_Codeinput, + XK_Zen_Koho, Qt::Key_MultipleCandidate, + XK_Mae_Koho, Qt::Key_PreviousCandidate, + +#ifdef XK_KOREAN + // Korean keyboard support + XK_Hangul, Qt::Key_Hangul, + XK_Hangul_Start, Qt::Key_Hangul_Start, + XK_Hangul_End, Qt::Key_Hangul_End, + XK_Hangul_Hanja, Qt::Key_Hangul_Hanja, + XK_Hangul_Jamo, Qt::Key_Hangul_Jamo, + XK_Hangul_Romaja, Qt::Key_Hangul_Romaja, + //XK_Hangul_Codeinput, Qt::Key_Hangul_Codeinput, + XK_Hangul_Codeinput, Qt::Key_Codeinput, + XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja, + XK_Hangul_Banja, Qt::Key_Hangul_Banja, + XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja, + XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja, + //XK_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate, + //XK_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate, + //XK_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate, + XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate, + XK_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate, + XK_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate, + XK_Hangul_Special, Qt::Key_Hangul_Special, + //XK_Hangul_switch, Qt::Key_Hangul_switch, + XK_Hangul_switch, Qt::Key_Mode_switch, +#endif // XK_KOREAN + + // dead keys + XK_dead_grave, Qt::Key_Dead_Grave, + XK_dead_acute, Qt::Key_Dead_Acute, + XK_dead_circumflex, Qt::Key_Dead_Circumflex, + XK_dead_tilde, Qt::Key_Dead_Tilde, + XK_dead_macron, Qt::Key_Dead_Macron, + XK_dead_breve, Qt::Key_Dead_Breve, + XK_dead_abovedot, Qt::Key_Dead_Abovedot, + XK_dead_diaeresis, Qt::Key_Dead_Diaeresis, + XK_dead_abovering, Qt::Key_Dead_Abovering, + XK_dead_doubleacute, Qt::Key_Dead_Doubleacute, + XK_dead_caron, Qt::Key_Dead_Caron, + XK_dead_cedilla, Qt::Key_Dead_Cedilla, + XK_dead_ogonek, Qt::Key_Dead_Ogonek, + XK_dead_iota, Qt::Key_Dead_Iota, + XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound, + XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound, + XK_dead_belowdot, Qt::Key_Dead_Belowdot, + XK_dead_hook, Qt::Key_Dead_Hook, + XK_dead_horn, Qt::Key_Dead_Horn, + +#if 0 + // Special multimedia keys + // currently only tested with MS internet keyboard + + // browsing keys + XF86XK_Back, Qt::Key_Back, + XF86XK_Forward, Qt::Key_Forward, + XF86XK_Stop, Qt::Key_Stop, + XF86XK_Refresh, Qt::Key_Refresh, + XF86XK_Favorites, Qt::Key_Favorites, + XF86XK_AudioMedia, Qt::Key_LaunchMedia, + XF86XK_OpenURL, Qt::Key_OpenUrl, + XF86XK_HomePage, Qt::Key_HomePage, + XF86XK_Search, Qt::Key_Search, + + // media keys + XF86XK_AudioLowerVolume, Qt::Key_VolumeDown, + XF86XK_AudioMute, Qt::Key_VolumeMute, + XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp, + XF86XK_AudioPlay, Qt::Key_MediaPlay, + XF86XK_AudioStop, Qt::Key_MediaStop, + XF86XK_AudioPrev, Qt::Key_MediaPrevious, + XF86XK_AudioNext, Qt::Key_MediaNext, + XF86XK_AudioRecord, Qt::Key_MediaRecord, + + // launch keys + XF86XK_Mail, Qt::Key_LaunchMail, + XF86XK_MyComputer, Qt::Key_Launch0, + XF86XK_Calculator, Qt::Key_Launch1, + XF86XK_Standby, Qt::Key_Standby, + + XF86XK_Launch0, Qt::Key_Launch2, + XF86XK_Launch1, Qt::Key_Launch3, + XF86XK_Launch2, Qt::Key_Launch4, + XF86XK_Launch3, Qt::Key_Launch5, + XF86XK_Launch4, Qt::Key_Launch6, + XF86XK_Launch5, Qt::Key_Launch7, + XF86XK_Launch6, Qt::Key_Launch8, + XF86XK_Launch7, Qt::Key_Launch9, + XF86XK_Launch8, Qt::Key_LaunchA, + XF86XK_Launch9, Qt::Key_LaunchB, + XF86XK_LaunchA, Qt::Key_LaunchC, + XF86XK_LaunchB, Qt::Key_LaunchD, + XF86XK_LaunchC, Qt::Key_LaunchE, + XF86XK_LaunchD, Qt::Key_LaunchF, +#endif + +#if 0 + // Qtopia keys + QTOPIAXK_Select, Qt::Key_Select, + QTOPIAXK_Yes, Qt::Key_Yes, + QTOPIAXK_No, Qt::Key_No, + QTOPIAXK_Cancel, Qt::Key_Cancel, + QTOPIAXK_Printer, Qt::Key_Printer, + QTOPIAXK_Execute, Qt::Key_Execute, + QTOPIAXK_Sleep, Qt::Key_Sleep, + QTOPIAXK_Play, Qt::Key_Play, + QTOPIAXK_Zoom, Qt::Key_Zoom, + QTOPIAXK_Context1, Qt::Key_Context1, + QTOPIAXK_Context2, Qt::Key_Context2, + QTOPIAXK_Context3, Qt::Key_Context3, + QTOPIAXK_Context4, Qt::Key_Context4, + QTOPIAXK_Call, Qt::Key_Call, + QTOPIAXK_Hangup, Qt::Key_Hangup, + QTOPIAXK_Flip, Qt::Key_Flip, +#endif + 0, 0 +}; + + +static int lookupCode(unsigned int xkeycode) +{ + if (xkeycode >= XK_F1 && xkeycode <= XK_F35) + return Qt::Key_F1 + (int(xkeycode) - XK_F1); + + const unsigned int *p = keyTbl; + while (*p) { + if (*p == xkeycode) + return *++p; + p += 2; + } + + return 0; +} + + +static Qt::KeyboardModifiers modifierFromKeyCode(int qtcode) +{ + switch (qtcode) { + case Qt::Key_Control: + return Qt::ControlModifier; + case Qt::Key_Alt: + return Qt::AltModifier; + case Qt::Key_Shift: + return Qt::ShiftModifier; + case Qt::Key_Meta: + return Qt::MetaModifier; + default: + return Qt::NoModifier; + } +} + +void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) +{ + XKeyEvent *e = static_cast(ev); + + KeySym keySym; + QByteArray chars; + chars.resize(513); + + int count = XLookupString(e, chars.data(), chars.size(), &keySym, 0); + +// qDebug() << "QTLWS::handleKeyEvent" << count << hex << "XKeysym:" << keySym; +// if (count) +// qDebug() << hex << int(chars[0]) << "String:" << chars; + + Qt::KeyboardModifiers modifiers = translateModifiers(e->state); + + int qtcode = lookupCode(keySym); +// qDebug() << "lookup: " << hex << keySym << qtcode << "mod" << modifiers; + + //X11 specifies state *before*, Qt expects state *after* the event + + modifiers ^= modifierFromKeyCode(qtcode); + + if (qtcode) { + QWindowSystemInterface::handleKeyEvent(window(), e->time, type, qtcode, modifiers); + } else if (chars[0]) { + int qtcode = chars.toUpper()[0]; //Not exactly right... + if (modifiers & Qt::ControlModifier && qtcode < ' ') + qtcode = chars[0] + '@'; + QWindowSystemInterface::handleKeyEvent(window(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars)); + } else { + qWarning() << "unknown X keycode" << hex << e->keycode << keySym; + } +} + + + +Qt::WindowFlags QTestLiteWindowSurface::setWindowFlags(Qt::WindowFlags flags) +{ + Q_ASSERT(flags & Qt::Window); + + window_flags = flags; + + xw->setWindowFlags(flags); + + return window_flags; + +} + +Qt::WindowFlags QTestLiteWindowSurface::windowFlags() const +{ + return window_flags; +} + +void QTestLiteWindowSurface::setVisible(bool visible) +{ + //qDebug() << "QTestLiteWindowSurface::setVisible" << visible << xw->window; + xw->setVisible(visible); +} + + +WId QTestLiteWindowSurface::winId() const +{ + if (xw) + return (WId) xw->window; + else + return WId(0); +} + +void QTestLiteWindowSurface::raise() +{ + WId window = winId(); + XRaiseWindow(mGraphicsSystem->xd->display, window); +} + +void QTestLiteWindowSurface::lower() +{ + WId window = winId(); + XLowerWindow(mGraphicsSystem->xd->display, window); +} + +void QTestLiteWindowSurface::setWindowTitle(const QString &title) +{ + xw->setWindowTitle(title); +} + +void QTestLiteWindowSurface::setCursor(QCursor *cursor) +{ + xw->setCursor(cursor); +} +QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qwindowsurface_testlite.h b/src/plugins/platforms/testlite/qwindowsurface_testlite.h new file mode 100644 index 0000000..0c4df1a --- /dev/null +++ b/src/plugins/platforms/testlite/qwindowsurface_testlite.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_TESTLITE_H +#define QWINDOWSURFACE_TESTLITE_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class MyWindow; +class QTestLiteGraphicsSystem; +class QTestLiteGraphicsSystemScreen; + +class QTestLiteWindowSurface : public QWindowSurface +{ +public: + QTestLiteWindowSurface + (QTestLiteGraphicsSystem *graphicsSystem, + QTestLiteGraphicsSystemScreen *screen, QWidget *window); + ~QTestLiteWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + + void handleMouseEvent(QEvent::Type, void *); //forwarding X types is apparently impossible :( + void handleKeyEvent(QEvent::Type, void *); + void handleGeometryChange(int x, int y, int w, int h); + void handleCloseEvent(); + void handleEnterEvent(); + void handleLeaveEvent(); + + Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); + Qt::WindowFlags windowFlags() const; + void setVisible(bool visible); + WId winId() const; + void raise(); + void lower(); + void setWindowTitle(const QString &title); + + void setCursor(QCursor * cursor); + +private: + QTestLiteGraphicsSystem *mGraphicsSystem; + QTestLiteGraphicsSystemScreen *mScreen; + Qt::WindowFlags window_flags; + MyWindow *xw; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/testlite/testlite.pro b/src/plugins/platforms/testlite/testlite.pro new file mode 100644 index 0000000..d483f45 --- /dev/null +++ b/src/plugins/platforms/testlite/testlite.pro @@ -0,0 +1,17 @@ +TARGET = qtestlitegraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp qgraphicssystem_testlite.cpp qwindowsurface_testlite.cpp +HEADERS = qgraphicssystem_testlite.h qwindowsurface_testlite.h + + +HEADERS += x11util.h +SOURCES += x11util.cpp + +LIBS += -lX11 -lXext + + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target diff --git a/src/plugins/platforms/testlite/x11util.cpp b/src/plugins/platforms/testlite/x11util.cpp new file mode 100644 index 0000000..6d2966f --- /dev/null +++ b/src/plugins/platforms/testlite/x11util.cpp @@ -0,0 +1,1215 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include +#include + +#include "x11util.h" +#include "qwindowsurface_testlite.h" + +#include +#include + + +#include + +#include + +# include +# include +# include + + +#include +#include +#include +#include + +//### remove stuff we don't want from qt_x11_p.h +#undef ATOM +#undef X11 + +//#define MYX11_DEBUG + +//#define DONT_USE_MIT_SHM + +static int (*original_x_errhandler)(Display *dpy, XErrorEvent *); +static bool seen_badwindow; + + +static Atom wmProtocolsAtom; +static Atom wmDeleteWindowAtom; + +//### copied from qapplication_x11.cpp + +static int qt_x_errhandler(Display *dpy, XErrorEvent *err) +{ + +qDebug() << "qt_x_errhandler" << err->error_code; + + switch (err->error_code) { + case BadAtom: +#if 0 + if (err->request_code == 20 /* X_GetProperty */ + && (err->resourceid == XA_RESOURCE_MANAGER + || err->resourceid == XA_RGB_DEFAULT_MAP + || err->resourceid == ATOM(_NET_SUPPORTED) + || err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK) + || err->resourceid == ATOM(KDE_FULL_SESSION) + || err->resourceid == ATOM(KWIN_RUNNING) + || err->resourceid == ATOM(XdndProxy) + || err->resourceid == ATOM(XdndAware)) + + + ) { + // Perhaps we're running under SECURITY reduction? :/ + return 0; + } +#endif + qDebug() << "BadAtom"; + break; + + case BadWindow: + if (err->request_code == 2 /* X_ChangeWindowAttributes */ + || err->request_code == 38 /* X_QueryPointer */) { + for (int i = 0; i < ScreenCount(dpy); ++i) { + if (err->resourceid == RootWindow(dpy, i)) { + // Perhaps we're running under SECURITY reduction? :/ + return 0; + } + } + } + seen_badwindow = true; + if (err->request_code == 25 /* X_SendEvent */) { + for (int i = 0; i < ScreenCount(dpy); ++i) { + if (err->resourceid == RootWindow(dpy, i)) { + // Perhaps we're running under SECURITY reduction? :/ + return 0; + } + } +#if 0 + if (X11->xdndHandleBadwindow()) { + qDebug("xdndHandleBadwindow returned true"); + return 0; + } +#endif + } +#if 0 + if (X11->ignore_badwindow) + return 0; +#endif + break; + + case BadMatch: + if (err->request_code == 42 /* X_SetInputFocus */) + return 0; + break; + + default: +#if 0 //!defined(QT_NO_XINPUT) + if (err->request_code == X11->xinput_major + && err->error_code == (X11->xinput_errorbase + XI_BadDevice) + && err->minor_code == 3 /* X_OpenDevice */) { + return 0; + } +#endif + break; + } + + char errstr[256]; + XGetErrorText( dpy, err->error_code, errstr, 256 ); + char buffer[256]; + char request_str[256]; + qsnprintf(buffer, 256, "%d", err->request_code); + XGetErrorDatabaseText(dpy, "XRequest", buffer, "", request_str, 256); + if (err->request_code < 128) { + // X error for a normal protocol request + qWarning( "X Error: %s %d\n" + " Major opcode: %d (%s)\n" + " Resource id: 0x%lx", + errstr, err->error_code, + err->request_code, + request_str, + err->resourceid ); + } else { + // X error for an extension request + const char *extensionName = 0; +#if 0 + if (err->request_code == X11->xrender_major) + extensionName = "RENDER"; + else if (err->request_code == X11->xrandr_major) + extensionName = "RANDR"; + else if (err->request_code == X11->xinput_major) + extensionName = "XInputExtension"; + else if (err->request_code == X11->mitshm_major) + extensionName = "MIT-SHM"; +#endif + char minor_str[256]; + if (extensionName) { + qsnprintf(buffer, 256, "%s.%d", extensionName, err->minor_code); + XGetErrorDatabaseText(dpy, "XRequest", buffer, "", minor_str, 256); + } else { + extensionName = "Uknown extension"; + qsnprintf(minor_str, 256, "Unknown request"); + } + qWarning( "X Error: %s %d\n" + " Extension: %d (%s)\n" + " Minor opcode: %d (%s)\n" + " Resource id: 0x%lx", + errstr, err->error_code, + err->request_code, + extensionName, + err->minor_code, + minor_str, + err->resourceid ); + } + + // ### we really should distinguish between severe, non-severe and + // ### application specific errors + + return 0; +} + + + + + + + + + +bool MyDisplay::handleEvent(XEvent *xe) +{ + //qDebug() << "handleEvent" << xe->xany.type << xe->xany.window; + int quit = false; + MyWindow *xw = 0; + foreach (MyWindow *w, windowList) { + if (w->window == xe->xany.window) { + xw = w; + break; + } + } + if (!xw) { +#ifdef MYX11_DEBUG + qWarning() << "Unknown window" << hex << xe->xany.window << "received event" << xe->type; +#endif + return quit; + } + + switch (xe->type) { + + case ClientMessage: + if (xe->xclient.format == 32 && xe->xclient.message_type == wmProtocolsAtom) { + Atom a = xe->xclient.data.l[0]; + if (a == wmDeleteWindowAtom) + xw->closeEvent(); +#ifdef MYX11_DEBUG + qDebug() << "ClientMessage WM_PROTOCOLS" << a; +#endif + } +#ifdef MYX11_DEBUG + else + qDebug() << "ClientMessage" << xe->xclient.format << xe->xclient.message_type; +#endif + break; + + case Expose: + if (xw) + if (xe->xexpose.count == 0) + xw->paintEvent(); + break; + case ConfigureNotify: + if (xw) + xw->resizeEvent(&xe->xconfigure); + break; + + case ButtonPress: + xw->mousePressEvent(&xe->xbutton); + break; + + case ButtonRelease: + xw->mouseReleaseEvent(&xe->xbutton); + break; + + case MotionNotify: + xw->mouseMoveEvent(&xe->xbutton); + break; + + case XKeyPress: + xw->keyPressEvent(&xe->xkey); + break; + + case XKeyRelease: + xw->keyReleaseEvent(&xe->xkey); + break; + + case EnterNotify: + xw->enterEvent(&xe->xcrossing); + break; + + case LeaveNotify: + xw->leaveEvent(&xe->xcrossing); + break; + + default: +#ifdef MYX11_DEBUG + qDebug() << hex << xe->xany.window << "Other X event" << xe->type; +#endif + break; + } + return quit; +}; + + + +MyDisplay::MyDisplay() +{ + char *display_name = getenv("DISPLAY"); + display = XOpenDisplay(display_name); + if (!display) { + fprintf(stderr, "Cannot connect to X server: %s\n", + display_name); + exit(1); + } + +#ifndef DONT_USE_MIT_SHM + Status MIT_SHM_extension_supported = XShmQueryExtension (display); + Q_ASSERT(MIT_SHM_extension_supported == True); +#endif + original_x_errhandler = XSetErrorHandler(qt_x_errhandler); + + if (qgetenv("DO_X_SYNCHRONIZE").toInt()) + XSynchronize(display, true); + + screen = DefaultScreen(display); + width = DisplayWidth(display, screen); + height = DisplayHeight(display, screen); + physicalWidth = DisplayWidthMM(display, screen); + physicalHeight = DisplayHeightMM(display, screen); + + int xSocketNumber = XConnectionNumber(display); +#ifdef MYX11_DEBUG + qDebug() << "X socket:"<< xSocketNumber; +#endif + QSocketNotifier *sock = new QSocketNotifier(xSocketNumber, QSocketNotifier::Read, this); + connect(sock, SIGNAL(activated(int)), this, SLOT(eventDispatcher())); + + wmProtocolsAtom = XInternAtom (display, "WM_PROTOCOLS", False); + wmDeleteWindowAtom = XInternAtom (display, "WM_DELETE_WINDOW", False); + + cursors = new MyX11Cursors(display); +} + + +MyDisplay::~MyDisplay() +{ + XCloseDisplay(display); +} + + +void MyDisplay::eventDispatcher() +{ +// qDebug() << "eventDispatcher"; + + + ulong marker = XNextRequest(display); +// int i = 0; + while (XPending(display)) { + XEvent event; + XNextEvent(display, &event); + /* done = */ + handleEvent(&event); + + if (event.xany.serial >= marker) { +#ifdef MYX11_DEBUG + qDebug() << "potential livelock averted"; +#endif +#if 0 + if (XEventsQueued(display, QueuedAfterFlush)) { + qDebug() << " with events queued"; + QTimer::singleShot(0, this, SLOT(eventDispatcher())); + } +#endif + break; + } + } +} + + +QImage MyDisplay::grabWindow(Window window, int x, int y, int w, int h) +{ + if (w == 0 || h ==0) + return QImage(); + + //WinId 0 means the desktop widget + if (!window) + window = rootWindow(); + + XWindowAttributes window_attr; + if (!XGetWindowAttributes(display, window, &window_attr)) + return QImage(); + + if (w < 0) + w = window_attr.width - x; + if (h < 0) + h = window_attr.height - y; + + // Ideally, we should also limit ourselves to the screen area, but the Qt docs say + // that it's "unsafe" to go outside the screen, so we can ignore that problem. + + //We're definitely not optimizing for speed... + XImage *xi = XGetImage(display, window, x, y, w, h, AllPlanes, ZPixmap); + + if (!xi) + return QImage(); + + //taking a copy to make sure we have ownership -- not fast + QImage result = QImage( (uchar*) xi->data, xi->width, xi->height, xi->bytes_per_line, QImage::Format_RGB32 ).copy(); + + XDestroyImage(xi); + + return result; +} + + + + +struct MyShmImageInfo { + MyShmImageInfo(Display *xdisplay) : image(0), display(xdisplay) {} + ~MyShmImageInfo() { destroy(); } + + void destroy(); + + XShmSegmentInfo shminfo; + XImage *image; + Display *display; +}; + +MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) +{ + xd = display; + + xd->windowList.append(this); + + window = XCreateSimpleWindow(xd->display, xd->rootWindow(), + x, y, w, h, 0 /*border_width*/, + xd->blackPixel(), xd->whitePixel()); + + +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::MyWindow" << hex << window; +#endif + + + width = -1; + height = -1; + xpos = -1; + ypos = -1; + + XSetWindowBackgroundPixmap(xd->display, window, XNone); + + XSelectInput(xd->display, window, ExposureMask | KeyPressMask | KeyReleaseMask | + EnterWindowMask | LeaveWindowMask | FocusChangeMask | + PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | + StructureNotifyMask); + + gc = createGC(); + + XChangeProperty (xd->display, window, + wmProtocolsAtom, + XA_ATOM, 32, PropModeAppend, + (unsigned char *) &wmDeleteWindowAtom, 1); + + + setWindowTitle(QLatin1String("Qt Lighthouse")); + + currentCursor = -1; + + image_info = 0; + painted = false; +} + + +void MyWindow::setWindowTitle(const QString &title) + +{ + QByteArray ba = title.toLatin1(); //We're not making a general solution here... + XTextProperty windowName; + windowName.value = (unsigned char *)ba.constData(); + windowName.encoding = XA_STRING; + windowName.format = 8; + windowName.nitems = ba.length(); + + XSetWMName(xd->display, window, &windowName); +} + +MyWindow::~MyWindow() +{ +#ifdef MYX11_DEBUG + qDebug() << "~MyWindow" << hex << window; +#endif + XFreeGC(xd->display, gc); + XDestroyWindow(xd->display, window); + + xd->windowList.removeAll(this); + + delete image_info; +} + +GC MyWindow::createGC() +{ + GC gc; + + gc = XCreateGC(xd->display, window, 0, 0); + if (gc < 0) { + qWarning("MyWindow::createGC() could not create GC"); + } + return gc; +} + +void MyWindow::closeEvent() +{ + windowSurface->handleCloseEvent(); +} + +void MyWindow::paintEvent() +{ +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::paintEvent" << shm_img.size() << painted; +#endif + if (!painted) + return; + +#ifdef DONT_USE_MIT_SHM + // just convert the image every time... + if (!shm_img.isNull()) { + Visual *visual = DefaultVisual(xd->display, xd->screen); + + QImage image = shm_img; + //img.convertToFormat( + XImage *xi = XCreateImage(xd->display, visual, 24, ZPixmap, + 0, (char *) image.scanLine(0), image.width(), image.height(), + 32, image.bytesPerLine()); + + int x = 0; + int y = 0; + + /*int r =*/ XPutImage(xd->display, window, gc, xi, 0, 0, x, y, image.width(), image.height()); + + xi->data = 0; // QImage owns these bits + XDestroyImage(xi); + } +#else + // Use MIT_SHM + if (image_info->image) { + //qDebug() << "Here we go" << image_info->image->width << image_info->image->height; + int x = 0; + int y = 0; + + // We could set send_event to true, and then use the ShmCompletion to synchronize, + // but let's do like Qt/11 and just use XSync + XShmPutImage (xd->display, window, gc, image_info->image, 0, 0, + x, y, image_info->image->width, image_info->image->height, + /*send_event*/ False); + + XSync(xd->display, False); + } +#endif +} + +#ifndef DONT_USE_MIT_SHM +void MyShmImageInfo::destroy() +{ + XShmDetach (display, &shminfo); + XDestroyImage (image); + shmdt (shminfo.shmaddr); + shmctl (shminfo.shmid, IPC_RMID, 0); +} +#endif + +void MyWindow::resizeShmImage(int width, int height) +{ +#ifdef DONT_USE_MIT_SHM + shm_img = QImage(width, height, QImage::Format_RGB32); +#else + if (image_info) + image_info->destroy(); + else + image_info = new MyShmImageInfo(xd->display); + + Visual *visual = DefaultVisual(xd->display, xd->screen); + + + XImage *image = XShmCreateImage (xd->display, visual, 24, ZPixmap, 0, + &image_info->shminfo, width, height); + + + image_info->shminfo.shmid = shmget (IPC_PRIVATE, + image->bytes_per_line * image->height, IPC_CREAT|0777); + + image_info->shminfo.shmaddr = image->data = (char*)shmat (image_info->shminfo.shmid, 0, 0); + image_info->shminfo.readOnly = False; + + image_info->image = image; + + Status shm_attach_status = XShmAttach(xd->display, &image_info->shminfo); + + Q_ASSERT(shm_attach_status == True); + + shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, QImage::Format_RGB32 ); +#endif + painted = false; +} + + +void MyWindow::resizeBuffer(QSize s) +{ + if (shm_img.size() != s) + resizeShmImage(s.width(), s.height()); +} + +QSize MyWindow::bufferSize() const +{ + return shm_img.size(); +} + + +void MyWindow::resizeEvent(XConfigureEvent *e) +{ + + if ((e->width != width || e->height != height) && e->x == 0 && e->y == 0) { + //qDebug() << "resize with bogus pos" << e->x << e->y << e->width << e->height << "window"<< hex << window; + } else { + //qDebug() << "geometry change" << e->x << e->y << e->width << e->height << "window"<< hex << window; + xpos = e->x; + ypos = e->y; + } + width = e->width; + height = e->height; + +#ifdef MYX11_DEBUG + qDebug() << hex << window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height << "img:" << shm_img.size(); +#endif + + windowSurface->handleGeometryChange(xpos, ypos, width, height); +} + +#if 0 +void MyWindow::setSize(int w, int h) +{ + XResizeWindow(xd->display, window, w, h); +} +#endif + +void MyWindow::setGeometry(int x, int y, int w, int h) +{ +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::setGeometry" << hex << window << dec << x << y << w << h << "img:" << shm_img.size(); +#endif + XMoveResizeWindow(xd->display, window, x, y, w, h); +} + + +void MyWindow::enterEvent(XCrossingEvent *) +{ +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::enterEvent" << hex << window; +#endif + windowSurface->handleEnterEvent(); +} + +void MyWindow::leaveEvent(XCrossingEvent *) +{ +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::enterEvent" << hex << window; +#endif + windowSurface->handleLeaveEvent(); +} + +void MyWindow::mousePressEvent(XButtonEvent *e) +{ + static long prevTime = 0; + static Window prevWindow; + static int prevX = -999; + static int prevY = -999; + + QEvent::Type type = QEvent::MouseButtonPress; + + if (e->window == prevWindow && long(e->time) - prevTime < QApplication::doubleClickInterval() + && qAbs(e->x - prevX) < 5 && qAbs(e->y - prevY) < 5) { + type = QEvent::MouseButtonDblClick; + prevTime = e->time - QApplication::doubleClickInterval(); //no double click next time + } else { + prevTime = e->time; + } + prevWindow = e->window; + prevX = e->x; + prevY = e->y; + + windowSurface->handleMouseEvent(type, e); +} + +void MyWindow::mouseReleaseEvent(XButtonEvent *e) +{ + windowSurface->handleMouseEvent(QEvent::MouseButtonRelease, e); +} + +void MyWindow::mouseMoveEvent(XButtonEvent *e) +{ + windowSurface->handleMouseEvent(QEvent::MouseMove, e); +} + +#ifdef KeyPress +#undef KeyPress +#endif + +void MyWindow::keyPressEvent(XKeyEvent *e) +{ + windowSurface->handleKeyEvent(QEvent::KeyPress, e); +} + +#ifdef KeyRelease +#undef KeyRelease +#endif + +void MyWindow::keyReleaseEvent(XKeyEvent *e) +{ + windowSurface->handleKeyEvent(QEvent::KeyRelease, e); +} + + +// WindowFlag stuff, lots of copied code from qwidget_x11.cpp... + +//We're hacking here... + + +// MWM support +struct QtMWMHints { + ulong flags, functions, decorations; + long input_mode; + ulong status; +}; + +enum { + MWM_HINTS_FUNCTIONS = (1L << 0), + + MWM_FUNC_ALL = (1L << 0), + MWM_FUNC_RESIZE = (1L << 1), + MWM_FUNC_MOVE = (1L << 2), + MWM_FUNC_MINIMIZE = (1L << 3), + MWM_FUNC_MAXIMIZE = (1L << 4), + MWM_FUNC_CLOSE = (1L << 5), + + MWM_HINTS_DECORATIONS = (1L << 1), + + MWM_DECOR_ALL = (1L << 0), + MWM_DECOR_BORDER = (1L << 1), + MWM_DECOR_RESIZEH = (1L << 2), + MWM_DECOR_TITLE = (1L << 3), + MWM_DECOR_MENU = (1L << 4), + MWM_DECOR_MINIMIZE = (1L << 5), + MWM_DECOR_MAXIMIZE = (1L << 6), + + MWM_HINTS_INPUT_MODE = (1L << 2), + + MWM_INPUT_MODELESS = 0L, + MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L, + MWM_INPUT_FULL_APPLICATION_MODAL = 3L +}; + +static Atom mwm_hint_atom = XNone; + +static QtMWMHints GetMWMHints(Display *display, Window window) +{ + QtMWMHints mwmhints; + + Atom type; + int format; + ulong nitems, bytesLeft; + uchar *data = 0; + if ((XGetWindowProperty(display, window, mwm_hint_atom, 0, 5, false, + mwm_hint_atom, &type, &format, &nitems, &bytesLeft, + &data) == Success) + && (type == mwm_hint_atom + && format == 32 + && nitems >= 5)) { + mwmhints = *(reinterpret_cast(data)); + } else { + mwmhints.flags = 0L; + mwmhints.functions = MWM_FUNC_ALL; + mwmhints.decorations = MWM_DECOR_ALL; + mwmhints.input_mode = 0L; + mwmhints.status = 0L; + } + + if (data) + XFree(data); + + return mwmhints; +} + +static void SetMWMHints(Display *display, Window window, const QtMWMHints &mwmhints) +{ + if (mwmhints.flags != 0l) { + XChangeProperty(display, window, mwm_hint_atom, mwm_hint_atom, 32, + PropModeReplace, (unsigned char *) &mwmhints, 5); + } else { + XDeleteProperty(display, window, mwm_hint_atom); + } +} + +// 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)); +} + + + +Qt::WindowFlags MyWindow::setWindowFlags(Qt::WindowFlags flags) +{ + + if (mwm_hint_atom == XNone) { + mwm_hint_atom = XInternAtom(xd->display, "_MOTIF_WM_HINTS\0", False); + } + +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::setWindowFlags" << hex << window << "flags" << flags; +#endif + Qt::WindowType type = static_cast(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); + + bool tooltip = (type == Qt::ToolTip); + + XSetWindowAttributes wsa; + + QtMWMHints mwmhints; + mwmhints.flags = 0L; + mwmhints.functions = 0L; + mwmhints.decorations = 0; + mwmhints.input_mode = 0L; + mwmhints.status = 0L; + + + ulong wsa_mask = 0; + if (type != Qt::SplashScreen) { // && customize) { + 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 (tool) { + wsa.save_under = True; + wsa_mask |= CWSaveUnder; + } + + if (flags & Qt::X11BypassWindowManagerHint) { + wsa.override_redirect = True; + wsa_mask |= CWOverrideRedirect; + } +#if 0 + if (wsa_mask && initializeWindow) { + Q_ASSERT(id); + XChangeWindowAttributes(dpy, id, wsa_mask, &wsa); + } +#endif + 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; + } + + SetMWMHints(xd->display, window, mwmhints); + +//##### only if initializeWindow??? + + if (popup || tooltip) { // popup widget +#ifdef MYX11_DEBUG + qDebug() << "Doing XChangeWindowAttributes for popup" << wsa.override_redirect; +#endif + // set EWMH window types + // setNetWmWindowTypes(); + + wsa.override_redirect = True; + wsa.save_under = True; + XChangeWindowAttributes(xd->display, window, CWOverrideRedirect | CWSaveUnder, + &wsa); + } else { +#ifdef MYX11_DEBUG + qDebug() << "Doing XChangeWindowAttributes for non-popup"; +#endif + } + + return flags; +} + +void MyWindow::setVisible(bool visible) +{ +#ifdef MYX11_DEBUG + qDebug() << "MyWindow::setVisible" << visible << hex << window; +#endif + if (visible) + XMapWindow(xd->display, window); + else + XUnmapWindow(xd->display, window); +} + +MyX11Cursors::MyX11Cursors(Display * d) : firstExpired(0), lastExpired(0), display(d), removalDelay(3) +{ + connect(&timer, SIGNAL(timeout()), this, SLOT(timeout())); +} + +void MyX11Cursors::insertNode(MyX11CursorNode * node) +{ + QDateTime now = QDateTime::currentDateTime(); + QDateTime timeout = now.addSecs(removalDelay); + node->setExpiration(timeout); + node->setPost(0); + if (lastExpired) { + lastExpired->setPost(node); + node->setAnte(lastExpired); + } + lastExpired = node; + if (!firstExpired) { + firstExpired = node; + node->setAnte(0); + int interval = removalDelay * 1000; + timer.setInterval(interval); + timer.start(); + } +} + +void MyX11Cursors::removeNode(MyX11CursorNode * node) +{ + MyX11CursorNode *pre = node->ante(); + MyX11CursorNode *post = node->post(); + if (pre) + pre->setPost(post); + if (post) + post->setAnte(pre); + if (node == lastExpired) + lastExpired = pre; + if (node == firstExpired) { + firstExpired = post; + if (!firstExpired) { + timer.stop(); + return; + } + int interval = QDateTime::currentDateTime().secsTo(firstExpired->expiration()) * 1000; + timer.stop(); + timer.setInterval(interval); + timer.start(); + } +} + +void MyX11Cursors::incrementUseCount(int id) +{ + MyX11CursorNode * node = lookupMap.value(id); + Q_ASSERT(node); + if (!node->refCount) + removeNode(node); + node->refCount++; +} + +void MyX11Cursors::decrementUseCount(int id) +{ + MyX11CursorNode * node = lookupMap.value(id); + Q_ASSERT(node); + node->refCount--; + if (!node->refCount) + insertNode(node); +} + +void MyX11Cursors::createNode(int id, Cursor c) +{ + MyX11CursorNode * node = new MyX11CursorNode(id, c); + lookupMap.insert(id, node); +} + +void MyX11Cursors::timeout() +{ + MyX11CursorNode * node; + node = firstExpired; + QDateTime now = QDateTime::currentDateTime(); + while (node && now.secsTo(node->expiration()) < 1) { + Cursor c = node->cursor(); + int id = node->id(); + lookupMap.take(id); + MyX11CursorNode * tmp = node; + node = node->post(); + delete tmp; + XFreeCursor(display, c); + } + firstExpired = node; + if (node == 0) { + timer.stop(); + lastExpired = 0; + } + else { + int interval = QDateTime::currentDateTime().secsTo(firstExpired->expiration()) * 1000; + timer.setInterval(interval); + timer.start(); + } +} + +Cursor MyX11Cursors::cursor(int id) +{ + MyX11CursorNode * node = lookupMap.value(id); + Q_ASSERT(node); + return node->cursor(); +} + +void MyWindow::setCursor(QCursor * cursor) +{ + int id = cursor->handle(); + if (id == currentCursor) + return; + Cursor c; + if (!xd->cursors->exists(id)) { + if (cursor->shape() == Qt::BitmapCursor) + c = createCursorBitmap(cursor); + else + c = createCursorShape(cursor->shape()); + if (!c) { + return; + } + xd->cursors->createNode(id, c); + } else { + xd->cursors->incrementUseCount(id); + c = xd->cursors->cursor(id); + } + + if (currentCursor != -1) + xd->cursors->decrementUseCount(currentCursor); + currentCursor = id; + + XDefineCursor(xd->display, window, c); + XFlush(xd->display); +} + +Cursor MyWindow::createCursorBitmap(QCursor * cursor) +{ + XColor bg, fg; + bg.red = 255 << 8; + bg.green = 255 << 8; + bg.blue = 255 << 8; + fg.red = 0; + fg.green = 0; + fg.blue = 0; + QPoint spot = cursor->hotSpot(); + Window rootwin = window; + + QImage mapImage = cursor->bitmap()->toImage().convertToFormat(QImage::Format_MonoLSB); + QImage maskImage = cursor->mask()->toImage().convertToFormat(QImage::Format_MonoLSB); + + int width = cursor->bitmap()->width(); + int height = cursor->bitmap()->height(); + int bytesPerLine = mapImage.bytesPerLine(); + int destLineSize = width / 8; + if (width % 8) + destLineSize++; + + const uchar * map = mapImage.bits(); + const uchar * mask = maskImage.bits(); + + char * mapBits = new char[height * destLineSize]; + char * maskBits = new char[height * destLineSize]; + for (int i = 0; i < height; i++) { + memcpy(mapBits + (destLineSize * i),map + (bytesPerLine * i), destLineSize); + memcpy(maskBits + (destLineSize * i),mask + (bytesPerLine * i), destLineSize); + } + + Pixmap cp = XCreateBitmapFromData(xd->display, rootwin, mapBits, width, height); + Pixmap mp = XCreateBitmapFromData(xd->display, rootwin, maskBits, width, height); + Cursor c = XCreatePixmapCursor(xd->display, cp, mp, &fg, &bg, spot.x(), spot.y()); + XFreePixmap(xd->display, cp); + XFreePixmap(xd->display, mp); + delete[] mapBits; + delete[] maskBits; + + return c; +} + +Cursor MyWindow::createCursorShape(int cshape) +{ + Cursor cursor = 0; + + if (cshape < 0 || cshape > Qt::LastCursor) + return 0; + + switch (cshape) { + case Qt::ArrowCursor: + cursor = XCreateFontCursor(xd->display, XC_left_ptr); + break; + case Qt::UpArrowCursor: + cursor = XCreateFontCursor(xd->display, XC_center_ptr); + break; + case Qt::CrossCursor: + cursor = XCreateFontCursor(xd->display, XC_crosshair); + break; + case Qt::WaitCursor: + cursor = XCreateFontCursor(xd->display, XC_watch); + break; + case Qt::IBeamCursor: + cursor = XCreateFontCursor(xd->display, XC_xterm); + break; + case Qt::SizeAllCursor: + cursor = XCreateFontCursor(xd->display, XC_fleur); + break; + case Qt::PointingHandCursor: + cursor = XCreateFontCursor(xd->display, XC_hand2); + break; + case Qt::SizeBDiagCursor: + cursor = XCreateFontCursor(xd->display, XC_top_right_corner); + break; + case Qt::SizeFDiagCursor: + cursor = XCreateFontCursor(xd->display, XC_bottom_right_corner); + break; + case Qt::SizeVerCursor: + case Qt::SplitVCursor: + cursor = XCreateFontCursor(xd->display, XC_sb_v_double_arrow); + break; + case Qt::SizeHorCursor: + case Qt::SplitHCursor: + cursor = XCreateFontCursor(xd->display, XC_sb_h_double_arrow); + break; + case Qt::WhatsThisCursor: + cursor = XCreateFontCursor(xd->display, XC_question_arrow); + break; + case Qt::ForbiddenCursor: + cursor = XCreateFontCursor(xd->display, XC_circle); + break; + case Qt::BusyCursor: + cursor = XCreateFontCursor(xd->display, XC_watch); + break; + + default: //default cursor for all the rest + break; + } + return cursor; +} + + +#if 0 + + + switch (cshape) { // map Q cursor to X cursor + case Qt::BlankCursor: + XColor bg, fg; + bg.red = 255 << 8; + bg.green = 255 << 8; + bg.blue = 255 << 8; + fg.red = 0; + fg.green = 0; + fg.blue = 0; + pm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16); + pmm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16); + hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8); + return; + break; + default: + qWarning("QCursor::update: Invalid cursor shape %d", cshape); + return; + } +#endif diff --git a/src/plugins/platforms/testlite/x11util.h b/src/plugins/platforms/testlite/x11util.h new file mode 100644 index 0000000..79e7461 --- /dev/null +++ b/src/plugins/platforms/testlite/x11util.h @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYX11UTIL_H +#define MYX11UTIL_H + +#include +#include +#include +#include + +#include + +#include +#include + + +class MyWindow; +class MyX11Cursors; + +class MyDisplay : public QObject +{ + Q_OBJECT; +public: + MyDisplay(); + ~MyDisplay(); + + Window rootWindow() { return RootWindow(display, screen); } + unsigned long blackPixel() { return BlackPixel(display, screen); } + unsigned long whitePixel() { return WhitePixel(display, screen); } + + bool handleEvent(XEvent *xe); + QImage grabWindow(Window window, int x, int y, int w, int h); + +public slots: + void eventDispatcher(); + +public: //### + Display * display; + int screen; + int width, height; + int physicalWidth; + int physicalHeight; + + QList windowList; + + MyX11Cursors * cursors; +}; + +class QTestLiteWindowSurface; //### abstract callback interface, anyone? + +struct MyShmImageInfo; + +class MyWindow : public QObject +{ + Q_OBJECT; +public: + MyWindow(MyDisplay *xd, int x, int y, int w, int h); + ~MyWindow(); + + + void mousePressEvent(XButtonEvent*); + void mouseReleaseEvent(XButtonEvent*); + void mouseMoveEvent(XButtonEvent*); + + void keyPressEvent(XKeyEvent*); + void keyReleaseEvent(XKeyEvent*); + + void enterEvent(XCrossingEvent*); + void leaveEvent(XCrossingEvent*); + + void closeEvent(); + void paintEvent(); + void resizeEvent(XConfigureEvent *configure_event); +// void setSize(int w, int h); + void setGeometry(int x, int y, int w, int h); + + GC createGC(); + + Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); + void setVisible(bool visible); + void setCursor(QCursor * cursor); + Cursor createCursorShape(int cshape); + Cursor createCursorBitmap(QCursor * cursor); + + void setWindowTitle(const QString &title); + + QImage *image() { return &shm_img; } + +public: //### + + int xpos, ypos; + int width, height; + Window window; + MyDisplay *xd; + GC gc; + + QTestLiteWindowSurface *windowSurface; + + int currentCursor; + bool painted; + void resizeBuffer(QSize); + QSize bufferSize() const; + +private: + void resizeShmImage(int width, int height); + + QImage shm_img; + MyShmImageInfo *image_info; +}; + +class MyX11CursorNode +{ +public: + MyX11CursorNode(int id, Cursor c) { idValue = id; cursorValue = c; refCount = 1; } + QDateTime expiration() { return t; } + void setExpiration(QDateTime val) { t = val; } + MyX11CursorNode * ante() { return before; } + void setAnte(MyX11CursorNode *node) { before = node; } + MyX11CursorNode * post() { return after; } + void setPost(MyX11CursorNode *node) { after = node; } + Cursor cursor() { return cursorValue; } + int id() { return idValue; } + unsigned int refCount; + +private: + MyX11CursorNode *before; + MyX11CursorNode *after; + QDateTime t; + Cursor cursorValue; + int idValue; + + Display * display; +}; + +class MyX11Cursors : public QObject +{ + Q_OBJECT +public: + MyX11Cursors(Display * d); + ~MyX11Cursors() { timer.stop(); } + void incrementUseCount(int id); + void decrementUseCount(int id); + void createNode(int id, Cursor c); + bool exists(int id) { return lookupMap.contains(id); } + Cursor cursor(int id); +public slots: + void timeout(); + +private: + void removeNode(MyX11CursorNode *node); + void insertNode(MyX11CursorNode *node); + + // linked list of cursors currently not assigned to any window + MyX11CursorNode *firstExpired; + MyX11CursorNode *lastExpired; + + QHash lookupMap; + QTimer timer; + + Display *display; + + int removalDelay; +}; + +#endif // MYX11UTIL_H diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp new file mode 100644 index 0000000..f10748a --- /dev/null +++ b/src/plugins/platforms/vnc/main.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qgraphicssystem_vnc.h" +#include + +QT_BEGIN_NAMESPACE + +class QVNCGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + QStringList keys() const; + QGraphicsSystem *create(const QString&); +}; + +QStringList QVNCGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "VNC"; + return list; +} + +QGraphicsSystem* QVNCGraphicsSystemPlugin::create(const QString& system) +{ + if (system.toLower() == "vnc") + return new QVNCGraphicsSystem; + + return 0; +} + +Q_EXPORT_PLUGIN2(vnc, QVNCGraphicsSystemPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp b/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp new file mode 100644 index 0000000..7815f24 --- /dev/null +++ b/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicssystem_vnc.h" +#include "../fb_base/fb_base.h" +#include +#include +#include + +#include +#include + +#include + + +QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() + : QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() +{ + int w = 800; + int h = 600; + int ew, eh; + const char *str; + if ((str=::getenv("QT_VNC_SIZE")) && sscanf(str,"%dx%d",&ew,&eh)==2) { + w = ew; + h = eh; + } + + setGeometry(QRect(0,0,w, h)); + setDepth(32); + setFormat(QImage::Format_RGB32); + setPhysicalSize((geometry().size()*254)/720); + + + d_ptr = new QVNCGraphicsSystemScreenPrivate(this); + + cursor = new QVNCCursor(d_ptr->vncServer, this); + d_ptr->vncServer->setCursor(static_cast(cursor)); +} + +QVNCDirtyMap *QVNCGraphicsSystemScreen::dirtyMap() +{ + return d_ptr->dirty; +} + +QRegion QVNCGraphicsSystemScreen::doRedraw() +{ + QRegion touched; + touched = QGraphicsSystemFbScreen::doRedraw(); + + QVector rects = touched.rects(); + for (int i = 0; i < rects.size(); i++) + d_ptr->setDirty(rects[i]); + return touched; +} + + +QVNCGraphicsSystem::QVNCGraphicsSystem() +{ + mPrimaryScreen = new QVNCGraphicsSystemScreen(); + + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QVNCGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QVNCGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + if (widget->windowType() == Qt::Desktop) + return 0; // Don't create an explicit window surface for the destkop. + QGraphicsSystemFbWindowSurface * surface; + surface = new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); + mPrimaryScreen->addWindowSurface(surface); + return surface; +} diff --git a/src/plugins/platforms/vnc/qgraphicssystem_vnc.h b/src/plugins/platforms/vnc/qgraphicssystem_vnc.h new file mode 100644 index 0000000..b3349b7 --- /dev/null +++ b/src/plugins/platforms/vnc/qgraphicssystem_vnc.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_VNC_H +#define QGRAPHICSSYSTEM_VNC_H + +#include +#include "qvnccursor.h" +#include "../fb_base/fb_base.h" + +QT_BEGIN_NAMESPACE + +class QVNCServer; +class QVNCDirtyMap; + +class QVNCGraphicsSystemScreenPrivate; + +class QVNCGraphicsSystemScreen : public QGraphicsSystemFbScreen +{ +public: + QVNCGraphicsSystemScreen(); + + int linestep() const { return image() ? image()->bytesPerLine() : 0; } + uchar *base() const { return image() ? image()->bits() : 0; } + QVNCDirtyMap *dirtyMap(); + +public: + QVNCGraphicsSystemScreenPrivate *d_ptr; + +private: + QVNCServer *server; + QRegion doRedraw(); +}; + +class QVNCGraphicsSystemPrivate; + + +class QVNCGraphicsSystem : public QGraphicsSystem +{ +public: + QVNCGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList screens() const { return mScreens; } + + +private: + QVNCGraphicsSystemScreen *mPrimaryScreen; + QList mScreens; +}; + + + +QT_END_NAMESPACE + +#endif //QGRAPHICSSYSTEM_VNC_H + diff --git a/src/plugins/platforms/vnc/qvnccursor.cpp b/src/plugins/platforms/vnc/qvnccursor.cpp new file mode 100644 index 0000000..fb214d8 --- /dev/null +++ b/src/plugins/platforms/vnc/qvnccursor.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +#include + +#include "qvnccursor.h" +#include "qvncserver.h" +#include "qgraphicssystem_vnc.h" + +QT_BEGIN_NAMESPACE + +QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCGraphicsSystemScreen *scr ) + :QGraphicsSystemSoftwareCursor(scr), useVncCursor(false), server(srvr) +{ +} + +void QVNCCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) +{ + QGraphicsSystemSoftwareCursor::changeCursor(widgetCursor, widget); + if (useVncCursor) { + server->setDirtyCursor(); + } else { + screen->setDirty(QRect(0,0,1,1)); + } +} + +void QVNCCursor::setCursorMode(bool vnc) +{ + if (vnc) { + screen->setDirty(dirtyRect()); + server->setDirtyCursor(); + } else { + server->setDirtyCursor(); + } + useVncCursor = vnc; +} + +QRect QVNCCursor::drawCursor(QPainter & painter) +{ + if (useVncCursor) + return QRect(); + + return QGraphicsSystemSoftwareCursor::drawCursor(painter); +} + +void QVNCCursor::clearClientCursor() +{ + QTcpSocket *socket = server->clientSocket(); + if (!socket) { + return; + } + // FramebufferUpdate header + { + const quint16 tmp[6] = { htons(0), + htons(1), + htons(0), htons(0), + htons(0), + htons(0) }; + socket->write((char*)tmp, sizeof(tmp)); + + const quint32 encoding = htonl(-239); + socket->write((char*)(&encoding), sizeof(encoding)); + } +} + +void QVNCCursor::sendClientCursor() +{ + if (useVncCursor == false) { + clearClientCursor(); + return; + } + QImage *image = graphic->image(); + if (image->isNull()) + return; + QTcpSocket *socket = server->clientSocket(); + if (!socket) { + return; + } + // FramebufferUpdate header + { + const quint16 tmp[6] = { htons(0), + htons(1), + htons(graphic->hotspot().x()), htons(graphic->hotspot().y()), + htons(image->width()), + htons(image->height()) }; + socket->write((char*)tmp, sizeof(tmp)); + + const quint32 encoding = htonl(-239); + socket->write((char*)(&encoding), sizeof(encoding)); + } + + // write pixels + //Q_ASSERT(cursor->hasAlphaChannel()); + const QImage img = image->convertToFormat(QImage::Format_RGB32); + const int n = server->clientBytesPerPixel() * img.width(); + char *buffer = new char[n]; + for (int i = 0; i < img.height(); ++i) { + server->convertPixels(buffer, (const char*)img.scanLine(i), img.width()); + socket->write(buffer, n); + } + delete[] buffer; + + // write mask + const QImage bitmap = image->createAlphaMask().convertToFormat(QImage::Format_Mono); + Q_ASSERT(bitmap.depth() == 1); + Q_ASSERT(bitmap.size() == img.size()); + const int width = (bitmap.width() + 7) / 8; + for (int i = 0; i < bitmap.height(); ++i) + socket->write((const char*)bitmap.scanLine(i), width); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/vnc/qvnccursor.h b/src/plugins/platforms/vnc/qvnccursor.h new file mode 100644 index 0000000..8ea0f45 --- /dev/null +++ b/src/plugins/platforms/vnc/qvnccursor.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QVNCCURSOR_H +#define QVNCCURSOR_H + +#include "../fb_base/fb_base.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QVNCGraphicsSystemScreen; +class QVNCServer; + +class QVNCCursor : public QGraphicsSystemSoftwareCursor { +public: + QVNCCursor(QVNCServer *, QVNCGraphicsSystemScreen *); + + // input methods + void setCursorMode(bool vnc); + void changeCursor(QCursor * widgetCursor, QWidget * widget); + + // output methods + QRect drawCursor(QPainter &); + + // VNC client communication + void sendClientCursor(); + void clearClientCursor(); +private: + bool useVncCursor; // VNC or local + + QVNCServer * server; // VNC server to get events from +}; + +QT_END_NAMESPACE + +#endif // QVNCCURSOR_H diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp new file mode 100644 index 0000000..ea576d4 --- /dev/null +++ b/src/plugins/platforms/vnc/qvncserver.cpp @@ -0,0 +1,1935 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvncserver.h" + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#include + + +#define QT_QWS_VNC_DEBUG +#define QT_NO_QWS_CURSOR //### + + +QT_BEGIN_NAMESPACE + + + +//copied from qscreen_qws.h +#ifndef QT_QWS_DEPTH16_RGB +#define QT_QWS_DEPTH16_RGB 565 +#endif +static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100); +static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10); +static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10); +static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits); +static const int qt_green_shift = qt_bbits-(8-qt_gbits); +static const int qt_neg_blue_shift = 8-qt_bbits; +static const int qt_blue_mask = (1<> qt_red_shift | r >> qt_red_rounding_shift; + const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift; + const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift; + + return qRgb(tr,tg,tb); +} + + + +//=========================================================================== + +static const struct { + int keysym; + int keycode; +} keyMap[] = { + { 0xff08, Qt::Key_Backspace }, + { 0xff09, Qt::Key_Tab }, + { 0xff0d, Qt::Key_Return }, + { 0xff1b, Qt::Key_Escape }, + { 0xff63, Qt::Key_Insert }, + { 0xffff, Qt::Key_Delete }, + { 0xff50, Qt::Key_Home }, + { 0xff57, Qt::Key_End }, + { 0xff55, Qt::Key_PageUp }, + { 0xff56, Qt::Key_PageDown }, + { 0xff51, Qt::Key_Left }, + { 0xff52, Qt::Key_Up }, + { 0xff53, Qt::Key_Right }, + { 0xff54, Qt::Key_Down }, + { 0xffbe, Qt::Key_F1 }, + { 0xffbf, Qt::Key_F2 }, + { 0xffc0, Qt::Key_F3 }, + { 0xffc1, Qt::Key_F4 }, + { 0xffc2, Qt::Key_F5 }, + { 0xffc3, Qt::Key_F6 }, + { 0xffc4, Qt::Key_F7 }, + { 0xffc5, Qt::Key_F8 }, + { 0xffc6, Qt::Key_F9 }, + { 0xffc7, Qt::Key_F10 }, + { 0xffc8, Qt::Key_F11 }, + { 0xffc9, Qt::Key_F12 }, + { 0xffe1, Qt::Key_Shift }, + { 0xffe2, Qt::Key_Shift }, + { 0xffe3, Qt::Key_Control }, + { 0xffe4, Qt::Key_Control }, + { 0xffe7, Qt::Key_Meta }, + { 0xffe8, Qt::Key_Meta }, + { 0xffe9, Qt::Key_Alt }, + { 0xffea, Qt::Key_Alt }, + { 0, 0 } +}; + +void QRfbRect::read(QTcpSocket *s) +{ + quint16 buf[4]; + s->read((char*)buf, 8); + x = ntohs(buf[0]); + y = ntohs(buf[1]); + w = ntohs(buf[2]); + h = ntohs(buf[3]); +} + +void QRfbRect::write(QTcpSocket *s) const +{ + quint16 buf[4]; + buf[0] = htons(x); + buf[1] = htons(y); + buf[2] = htons(w); + buf[3] = htons(h); + s->write((char*)buf, 8); +} + +void QRfbPixelFormat::read(QTcpSocket *s) +{ + char buf[16]; + s->read(buf, 16); + bitsPerPixel = buf[0]; + depth = buf[1]; + bigEndian = buf[2]; + trueColor = buf[3]; + + quint16 a = ntohs(*(quint16 *)(buf + 4)); + redBits = 0; + while (a) { a >>= 1; redBits++; } + + a = ntohs(*(quint16 *)(buf + 6)); + greenBits = 0; + while (a) { a >>= 1; greenBits++; } + + a = ntohs(*(quint16 *)(buf + 8)); + blueBits = 0; + while (a) { a >>= 1; blueBits++; } + + redShift = buf[10]; + greenShift = buf[11]; + blueShift = buf[12]; +} + +void QRfbPixelFormat::write(QTcpSocket *s) +{ + char buf[16]; + buf[0] = bitsPerPixel; + buf[1] = depth; + buf[2] = bigEndian; + buf[3] = trueColor; + + quint16 a = 0; + for (int i = 0; i < redBits; i++) a = (a << 1) | 1; + *(quint16 *)(buf + 4) = htons(a); + + a = 0; + for (int i = 0; i < greenBits; i++) a = (a << 1) | 1; + *(quint16 *)(buf + 6) = htons(a); + + a = 0; + for (int i = 0; i < blueBits; i++) a = (a << 1) | 1; + *(quint16 *)(buf + 8) = htons(a); + + buf[10] = redShift; + buf[11] = greenShift; + buf[12] = blueShift; + s->write(buf, 16); +} + + +void QRfbServerInit::setName(const char *n) +{ + delete[] name; + name = new char [strlen(n) + 1]; + strcpy(name, n); +} + +void QRfbServerInit::read(QTcpSocket *s) +{ + s->read((char *)&width, 2); + width = ntohs(width); + s->read((char *)&height, 2); + height = ntohs(height); + format.read(s); + + quint32 len; + s->read((char *)&len, 4); + len = ntohl(len); + + name = new char [len + 1]; + s->read(name, len); + name[len] = '\0'; +} + +void QRfbServerInit::write(QTcpSocket *s) +{ + quint16 t = htons(width); + s->write((char *)&t, 2); + t = htons(height); + s->write((char *)&t, 2); + format.write(s); + quint32 len = strlen(name); + len = htonl(len); + s->write((char *)&len, 4); + s->write(name, strlen(name)); +} + +bool QRfbSetEncodings::read(QTcpSocket *s) +{ + if (s->bytesAvailable() < 3) + return false; + + char tmp; + s->read(&tmp, 1); // padding + s->read((char *)&count, 2); + count = ntohs(count); + + return true; +} + +bool QRfbFrameBufferUpdateRequest::read(QTcpSocket *s) +{ + if (s->bytesAvailable() < 9) + return false; + + s->read(&incremental, 1); + rect.read(s); + + return true; +} + +bool QRfbKeyEvent::read(QTcpSocket *s) +{ + if (s->bytesAvailable() < 7) + return false; + + s->read(&down, 1); + quint16 tmp; + s->read((char *)&tmp, 2); // padding + + quint32 key; + s->read((char *)&key, 4); + key = ntohl(key); + + unicode = 0; + keycode = 0; + int i = 0; + while (keyMap[i].keysym && !keycode) { + if (keyMap[i].keysym == (int)key) + keycode = keyMap[i].keycode; + i++; + } + if (!keycode) { + if (key <= 0xff) { + unicode = key; + if (key >= 'a' && key <= 'z') + keycode = Qt::Key_A + key - 'a'; + else if (key >= ' ' && key <= '~') + keycode = Qt::Key_Space + key - ' '; + } + } + + return true; +} + +bool QRfbPointerEvent::read(QTcpSocket *s) +{ + if (s->bytesAvailable() < 5) + return false; + + char buttonMask; + s->read(&buttonMask, 1); + + buttons = Qt::NoButton; + wheelDirection = WheelNone; + if (buttonMask & 1) + buttons |= Qt::LeftButton; + if (buttonMask & 2) + buttons |= Qt::MidButton; + if (buttonMask & 4) + buttons |= Qt::RightButton; + if (buttonMask & 8) + wheelDirection = WheelUp; + if (buttonMask & 16) + wheelDirection = WheelDown; + if (buttonMask & 32) + wheelDirection = WheelLeft; + if (buttonMask & 64) + wheelDirection = WheelRight; + + quint16 tmp; + s->read((char *)&tmp, 2); + x = ntohs(tmp); + s->read((char *)&tmp, 2); + y = ntohs(tmp); + + return true; +} + +bool QRfbClientCutText::read(QTcpSocket *s) +{ + if (s->bytesAvailable() < 7) + return false; + + char tmp[3]; + s->read(tmp, 3); // padding + s->read((char *)&length, 4); + length = ntohl(length); + + return true; +} + +//=========================================================================== + +QVNCServer::QVNCServer(QVNCGraphicsSystemScreen *screen) + : qvnc_screen(screen), cursor(0) +{ + init(5900); +} + +QVNCServer::QVNCServer(QVNCGraphicsSystemScreen *screen, int id) + : qvnc_screen(screen), cursor(0) +{ + init(5900 + id); +} + +void QVNCServer::init(uint port) +{ + qDebug() << "QVNCServer::init" << port; + + handleMsg = false; + client = 0; + encodingsPending = 0; + cutTextPending = 0; + keymod = 0; + state = Unconnected; + dirtyCursor = false; + + refreshRate = 25; + timer = new QTimer(this); + timer->setSingleShot(true); + connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); + + serverSocket = new QTcpServer(this); + if (!serverSocket->listen(QHostAddress::Any, port)) + qDebug() << "QVNCServer could not connect:" << serverSocket->errorString(); + else + qDebug("QVNCServer created on port %d", port); + + connect(serverSocket, SIGNAL(newConnection()), this, SLOT(newConnection())); + +#ifndef QT_NO_QWS_CURSOR + qvnc_cursor = 0; +#endif + encoder = 0; +} + +QVNCServer::~QVNCServer() +{ + delete encoder; + encoder = 0; + delete client; + client = 0; +#ifndef QT_NO_QWS_CURSOR + delete qvnc_cursor; + qvnc_cursor = 0; +#endif +} + +void QVNCServer::setDirty() +{ + if (state == Connected && !timer->isActive() && + ((dirtyMap()->numDirty > 0) || dirtyCursor)) { + timer->start(); + } +} + +void QVNCServer::newConnection() +{ + if (client) + delete client; + + client = serverSocket->nextPendingConnection(); + connect(client,SIGNAL(readyRead()),this,SLOT(readClient())); + connect(client,SIGNAL(disconnected()),this,SLOT(discardClient())); + handleMsg = false; + encodingsPending = 0; + cutTextPending = 0; + supportHextile = false; + wantUpdate = false; + + timer->start(1000 / refreshRate); + dirtyMap()->reset(); + + // send protocol version + const char *proto = "RFB 003.003\n"; + client->write(proto, 12); + state = Protocol; + +// if (!qvnc_screen->screen()) +// QWSServer::instance()->enablePainting(true); +} + +void QVNCServer::readClient() +{ + switch (state) { + case Protocol: + if (client->bytesAvailable() >= 12) { + char proto[13]; + client->read(proto, 12); + proto[12] = '\0'; + qDebug("Client protocol version %s", proto); + // No authentication + quint32 auth = htonl(1); + client->write((char *) &auth, sizeof(auth)); + state = Init; + } + break; + + case Init: + if (client->bytesAvailable() >= 1) { + quint8 shared; + client->read((char *) &shared, 1); + + // Server Init msg + QRfbServerInit sim; + QRfbPixelFormat &format = sim.format; + switch (qvnc_screen->depth()) { + case 32: + format.bitsPerPixel = 32; + format.depth = 32; + format.bigEndian = 0; + format.trueColor = true; + format.redBits = 8; + format.greenBits = 8; + format.blueBits = 8; + format.redShift = 16; + format.greenShift = 8; + format.blueShift = 0; + break; + + case 24: + format.bitsPerPixel = 24; + format.depth = 24; + format.bigEndian = 0; + format.trueColor = true; + format.redBits = 8; + format.greenBits = 8; + format.blueBits = 8; + format.redShift = 16; + format.greenShift = 8; + format.blueShift = 0; + break; + + case 18: + format.bitsPerPixel = 24; + format.depth = 18; + format.bigEndian = 0; + format.trueColor = true; + format.redBits = 6; + format.greenBits = 6; + format.blueBits = 6; + format.redShift = 12; + format.greenShift = 6; + format.blueShift = 0; + break; + + case 16: + format.bitsPerPixel = 16; + format.depth = 16; + format.bigEndian = 0; + format.trueColor = true; + format.redBits = 5; + format.greenBits = 6; + format.blueBits = 5; + format.redShift = 11; + format.greenShift = 5; + format.blueShift = 0; + break; + + case 15: + format.bitsPerPixel = 16; + format.depth = 15; + format.bigEndian = 0; + format.trueColor = true; + format.redBits = 5; + format.greenBits = 5; + format.blueBits = 5; + format.redShift = 10; + format.greenShift = 5; + format.blueShift = 0; + break; + + case 12: + format.bitsPerPixel = 16; + format.depth = 12; + format.bigEndian = 0; + format.trueColor = true; + format.redBits = 4; + format.greenBits = 4; + format.blueBits = 4; + format.redShift = 8; + format.greenShift = 4; + format.blueShift = 0; + break; + + case 8: + case 4: + format.bitsPerPixel = 8; + format.depth = 8; + format.bigEndian = 0; + format.trueColor = false; + format.redBits = 0; + format.greenBits = 0; + format.blueBits = 0; + format.redShift = 0; + format.greenShift = 0; + format.blueShift = 0; + break; + + default: + qDebug("QVNC cannot drive depth %d", qvnc_screen->depth()); + discardClient(); + return; + } + sim.width = qvnc_screen->geometry().width(); + sim.height = qvnc_screen->geometry().height(); + sim.setName("Qt for Embedded Linux VNC Server"); + sim.write(client); + state = Connected; + } + break; + + case Connected: + do { + if (!handleMsg) { + client->read((char *)&msgType, 1); + handleMsg = true; + } + if (handleMsg) { + switch (msgType ) { + case SetPixelFormat: + setPixelFormat(); + break; + case FixColourMapEntries: + qDebug("Not supported: FixColourMapEntries"); + handleMsg = false; + break; + case SetEncodings: + setEncodings(); + break; + case FramebufferUpdateRequest: + frameBufferUpdateRequest(); + break; + case KeyEvent: + keyEvent(); + break; + case PointerEvent: + pointerEvent(); + break; + case ClientCutText: + clientCutText(); + break; + default: + qDebug("Unknown message type: %d", (int)msgType); + handleMsg = false; + } + } + } while (!handleMsg && client->bytesAvailable()); + break; + default: + break; + } +} + +#if 0//Q_BYTE_ORDER == Q_BIG_ENDIAN +bool QVNCGraphicsSystemScreen::swapBytes() const +{ + if (depth() != 16) + return false; + + if (screen()) + return screen()->frameBufferLittleEndian(); + return frameBufferLittleEndian(); +} +#endif + +void QVNCServer::setPixelFormat() +{ + if (client->bytesAvailable() >= 19) { + char buf[3]; + client->read(buf, 3); // just padding + pixelFormat.read(client); +#ifdef QT_QWS_VNC_DEBUG + qDebug("Want format: %d %d %d %d %d %d %d %d %d %d", + int(pixelFormat.bitsPerPixel), + int(pixelFormat.depth), + int(pixelFormat.bigEndian), + int(pixelFormat.trueColor), + int(pixelFormat.redBits), + int(pixelFormat.greenBits), + int(pixelFormat.blueBits), + int(pixelFormat.redShift), + int(pixelFormat.greenShift), + int(pixelFormat.blueShift)); +#endif + if (!pixelFormat.trueColor) { + qDebug("Can only handle true color clients"); + discardClient(); + } + handleMsg = false; + sameEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) == !!pixelFormat.bigEndian; + needConversion = pixelConversionNeeded(); +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + swapBytes = qvnc_screen->swapBytes(); +#endif + } +} + +void QVNCServer::setEncodings() +{ + QRfbSetEncodings enc; + + if (!encodingsPending && enc.read(client)) { + encodingsPending = enc.count; + if (!encodingsPending) + handleMsg = false; + } + + if (encoder) { + delete encoder; + encoder = 0; + } + + enum Encodings { + Raw = 0, + CopyRect = 1, + RRE = 2, + CoRRE = 4, + Hextile = 5, + ZRLE = 16, + Cursor = -239, + DesktopSize = -223 + }; + + supportCursor = false; + + if (encodingsPending && (unsigned)client->bytesAvailable() >= + encodingsPending * sizeof(quint32)) { + for (int i = 0; i < encodingsPending; ++i) { + qint32 enc; + client->read((char *)&enc, sizeof(qint32)); + enc = ntohl(enc); +#ifdef QT_QWS_VNC_DEBUG + qDebug("QVNCServer::setEncodings: %d", enc); +#endif + switch (enc) { + case Raw: + if (!encoder) { + encoder = new QRfbRawEncoder(this); +#ifdef QT_QWS_VNC_DEBUG + qDebug("QVNCServer::setEncodings: using raw"); +#endif + } + break; + case CopyRect: + supportCopyRect = true; + break; + case RRE: + supportRRE = true; + break; + case CoRRE: + supportCoRRE = true; + break; + case Hextile: + supportHextile = true; + if (encoder) + break; + switch (qvnc_screen->depth()) { +#ifdef QT_QWS_DEPTH_8 + case 8: + encoder = new QRfbHextileEncoder(this); + break; +#endif +#ifdef QT_QWS_DEPTH_12 + case 12: + encoder = new QRfbHextileEncoder(this); + break; +#endif +#ifdef QT_QWS_DEPTH_15 + case 15: + encoder = new QRfbHextileEncoder(this); + break; +#endif +#ifdef QT_QWS_DEPTH_16 + case 16: + encoder = new QRfbHextileEncoder(this); + break; +#endif +#ifdef QT_QWS_DEPTH_18 + case 18: + encoder = new QRfbHextileEncoder(this); + break; +#endif +#ifdef QT_QWS_DEPTH_24 + case 24: + encoder = new QRfbHextileEncoder(this); + break; +#endif +#ifdef QT_QWS_DEPTH_32 + case 32: + encoder = new QRfbHextileEncoder(this); + break; +#endif + default: + break; + } +#ifdef QT_QWS_VNC_DEBUG + qDebug("QVNCServer::setEncodings: using hextile"); +#endif + break; + case ZRLE: + supportZRLE = true; + break; + case Cursor: + supportCursor = true; +#ifndef QT_NO_QWS_CURSOR + if (!qvnc_screen->screen() || qt_screencursor->isAccelerated()) { + delete qvnc_cursor; + qvnc_cursor = new QVNCClientCursor(this); + } +#endif + break; + case DesktopSize: + supportDesktopSize = true; + break; + default: + break; + } + } + handleMsg = false; + encodingsPending = 0; + } + + if (!encoder) { + encoder = new QRfbRawEncoder(this); +#ifdef QT_QWS_VNC_DEBUG + qDebug("QVNCServer::setEncodings: fallback using raw"); +#endif + } + + if (cursor) + cursor->setCursorMode(supportCursor); +} + +void QVNCServer::frameBufferUpdateRequest() +{ + QRfbFrameBufferUpdateRequest ev; + + if (ev.read(client)) { + if (!ev.incremental) { + QRect r(ev.rect.x, ev.rect.y, ev.rect.w, ev.rect.h); +////### r.translate(qvnc_screen->offset()); + qvnc_screen->d_ptr->setDirty(r, true); + } + wantUpdate = true; + checkUpdate(); + handleMsg = false; + } +} + +static bool buttonChange(Qt::MouseButtons before, Qt::MouseButtons after, Qt::MouseButton *button, bool *isPress) +{ + if (before == after) + return false; + for (int b = Qt::LeftButton; b <= Qt::MidButton; b<<=1) { + if ((before & b) != (after & b)) { + *button = static_cast(b); + *isPress = (after & b); + return true; + } + } + return false; +} + +void QVNCServer::pointerEvent() +{ + QRfbPointerEvent ev; + if (ev.read(client)) { +// const QPoint offset = qvnc_screen->offset(); +// QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons); + + + //qDebug() << "pointerEvent" << ev.x << ev.y << hex << ev.buttons; + if (ev.wheelDirection == ev.WheelNone) { + QEvent::Type type = QEvent::MouseMove; + Qt::MouseButton button = Qt::NoButton; + bool isPress; + if (buttonChange(buttons, ev.buttons, &button, &isPress)) + type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; + QWindowSystemInterface::handleMouseEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), ev.buttons); + } else { + // No buttons or motion reported at the same time as wheel events + Qt::Orientation orientation; + if (ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelRight) + orientation = Qt::Horizontal; + else + orientation = Qt::Vertical; + int delta = 120 * ((ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelUp) ? 1 : -1); + QWindowSystemInterface::handleWheelEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), delta, orientation); + } + handleMsg = false; + } +} + +void QVNCServer::keyEvent() +{ + QRfbKeyEvent ev; + + if (ev.read(client)) { + if (ev.keycode == Qt::Key_Shift) + keymod = ev.down ? keymod | Qt::ShiftModifier : + keymod & ~Qt::ShiftModifier; + else if (ev.keycode == Qt::Key_Control) + keymod = ev.down ? keymod | Qt::ControlModifier : + keymod & ~Qt::ControlModifier; + else if (ev.keycode == Qt::Key_Alt) + keymod = ev.down ? keymod | Qt::AltModifier : + keymod & ~Qt::AltModifier; + if (ev.unicode || ev.keycode) { +// qDebug() << "keyEvent" << hex << ev.unicode << ev.keycode << keymod << ev.down; + QEvent::Type type = ev.down ? QEvent::KeyPress : QEvent::KeyRelease; + QString str; + if (ev.unicode && ev.unicode != 0xffff) + str = QString(ev.unicode); + QWindowSystemInterface::handleKeyEvent(0, type, ev.keycode, keymod, str); + } + handleMsg = false; + } +} + +void QVNCServer::clientCutText() +{ + QRfbClientCutText ev; + + if (ev.read(client)) { + cutTextPending = ev.length; + if (!cutTextPending) + handleMsg = false; + } + + if (cutTextPending && client->bytesAvailable() >= cutTextPending) { + char *text = new char [cutTextPending+1]; + client->read(text, cutTextPending); + delete [] text; + cutTextPending = 0; + handleMsg = false; + } +} + +// stride in bytes +template +bool QRfbSingleColorHextile::read(const uchar *data, + int width, int height, int stride) +{ + const int depth = encoder->server->screen()->depth(); + if (width % (depth / 8)) // hw: should rather fallback to simple loop + return false; + + static int alwaysFalse = qgetenv("QT_VNC_NOCHECKFILL").toInt(); + if (alwaysFalse) + return false; + + switch (depth) { + case 4: { + const quint8 *data8 = reinterpret_cast(data); + if ((data8[0] & 0xf) != (data8[0] >> 4)) + return false; + width /= 2; + } // fallthrough + case 8: { + const quint8 *data8 = reinterpret_cast(data); + if (data8[0] != data8[1]) + return false; + width /= 2; + } // fallthrough + case 12: + case 15: + case 16: { + const quint16 *data16 = reinterpret_cast(data); + if (data16[0] != data16[1]) + return false; + width /= 2; + } // fallthrough + case 18: + case 24: + case 32: { + const quint32 *data32 = reinterpret_cast(data); + const quint32 first = data32[0]; + const int linestep = (stride / sizeof(quint32)) - width; + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x) { + if (*(data32++) != first) + return false; + } + data32 += linestep; + } + break; + } + default: + return false; + } + + SRC color = reinterpret_cast(data)[0]; + encoder->newBg |= (color != encoder->bg); + encoder->bg = color; + return true; +} + +template +void QRfbSingleColorHextile::write(QTcpSocket *socket) const +{ + if (true || encoder->newBg) { + const int bpp = encoder->server->clientBytesPerPixel(); + const int padding = 3; + QVarLengthArray buffer(padding + 1 + bpp); + buffer[padding] = 2; // BackgroundSpecified + encoder->server->convertPixels(buffer.data() + padding + 1, + reinterpret_cast(&encoder->bg), + 1); + socket->write(buffer.data() + padding, bpp + 1); +// encoder->newBg = false; + } else { + char subenc = 0; + socket->write(&subenc, 1); + } +} + +template +bool QRfbDualColorHextile::read(const uchar *data, + int width, int height, int stride) +{ + const SRC *ptr = reinterpret_cast(data); + const int linestep = (stride / sizeof(SRC)) - width; + + SRC c1; + SRC c2 = 0; + int n1 = 0; + int n2 = 0; + int x = 0; + int y = 0; + + c1 = *ptr; + + // find second color + while (y < height) { + while (x < width) { + if (*ptr == c1) { + ++n1; + } else { + c2 = *ptr; + goto found_second_color; + } + ++ptr; + ++x; + } + x = 0; + ptr += linestep; + ++y; + } + +found_second_color: + // finish counting + while (y < height) { + while (x < width) { + if (*ptr == c1) { + ++n1; + } else if (*ptr == c2) { + ++n2; + } else { + return false; + } + ++ptr; + ++x; + } + x = 0; + ptr += linestep; + ++y; + } + + if (n2 > n1) { + const quint32 tmpC = c1; + c1 = c2; + c2 = tmpC; + } + + encoder->newBg |= (c1 != encoder->bg); + encoder->newFg |= (c2 != encoder->fg); + + encoder->bg = c1; + encoder->fg = c2; + + // create map + bool inRect = false; + numRects = 0; + ptr = reinterpret_cast(data); + for (y = 0; y < height; ++y) { + for (x = 0; x < width; ++x) { + if (inRect && *ptr == encoder->bg) { + // rect finished + setWidth(x - lastx()); + next(); + inRect = false; + } else if (!inRect && *ptr == encoder->fg) { + // rect start + setX(x); + setY(y); + setHeight(1); + inRect = true; + } + ++ptr; + } + if (inRect) { + // finish rect + setWidth(width - lastx()); + next(); + inRect = false; + } + ptr += linestep; + } + + return true; +} + +template +void QRfbDualColorHextile::write(QTcpSocket *socket) const +{ + const int bpp = encoder->server->clientBytesPerPixel(); + const int padding = 3; + QVarLengthArray buffer(padding + 2 * bpp + sizeof(char) + sizeof(numRects)); + char &subenc = buffer[padding]; + int n = padding + sizeof(subenc); + + subenc = 0x8; // AnySubrects + + if (encoder->newBg) { + subenc |= 0x2; // Background + encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->bg, 1); + n += bpp; +// encoder->newBg = false; + } + + if (encoder->newFg) { + subenc |= 0x4; // Foreground + encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->fg, 1); + n += bpp; +// encoder->newFg = false; + } + buffer[n] = numRects; + n += sizeof(numRects); + + socket->write(buffer.data() + padding, n - padding); + socket->write((char*)rects, numRects * sizeof(Rect)); +} + +template +void QRfbDualColorHextile::next() +{ + for (int r = numRects - 1; r >= 0; --r) { + if (recty(r) == lasty()) + continue; + if (recty(r) < lasty() - 1) // only search previous scanline + break; + if (rectx(r) == lastx() && width(r) == width(numRects)) { + ++rects[r].wh; + return; + } + } + ++numRects; +} + +template +inline void QRfbMultiColorHextile::setColor(SRC color) +{ + encoder->server->convertPixels(reinterpret_cast(rect(numRects)), + (const char*)&color, 1); +} + +template +inline bool QRfbMultiColorHextile::beginRect() +{ + if ((rects.size() + bpp + 2) > maxRectsSize) + return false; + rects.resize(rects.size() + bpp + 2); + return true; +} + +template +inline void QRfbMultiColorHextile::endRect() +{ + setHeight(numRects, 1); + ++numRects; +} + +template +bool QRfbMultiColorHextile::read(const uchar *data, + int width, int height, int stride) +{ + const SRC *ptr = reinterpret_cast(data); + const int linestep = (stride / sizeof(SRC)) - width; + + bpp = encoder->server->clientBytesPerPixel(); + + if (encoder->newBg) + encoder->bg = ptr[0]; + + const SRC bg = encoder->bg; + SRC color = bg; + bool inRect = false; + + numRects = 0; + rects.clear(); + + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x) { + if (inRect && *ptr != color) { // end rect + setWidth(numRects, x - rectx(numRects)); + endRect(); + inRect = false; + } + + if (!inRect && *ptr != bg) { // begin rect + if (!beginRect()) + return false; + inRect = true; + color = *ptr; + setColor(color); + setX(numRects, x); + setY(numRects, y); + } + ++ptr; + } + if (inRect) { // end rect + setWidth(numRects, width - rectx(numRects)); + endRect(); + inRect = false; + } + ptr += linestep; + } + + return true; +} + +template +void QRfbMultiColorHextile::write(QTcpSocket *socket) const +{ + const int padding = 3; + QVarLengthArray buffer(bpp + padding + sizeof(quint8) + sizeof(numRects)); + + quint8 &subenc = buffer[padding]; + int n = padding + sizeof(quint8); + + subenc = 8 | 16; // AnySubrects | SubrectsColoured + + if (encoder->newBg) { + subenc |= 0x2; // Background + encoder->server->convertPixels(reinterpret_cast(buffer.data() + n), + reinterpret_cast(&encoder->bg), + 1); + n += bpp; +// encoder->newBg = false; + } + + buffer[n] = numRects; + n += sizeof(numRects); + + socket->write(reinterpret_cast(buffer.data() + padding), + n - padding); + socket->write(reinterpret_cast(rects.constData()), + rects.size()); +} + +bool QVNCServer::pixelConversionNeeded() const +{ + if (!sameEndian) + return true; + +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + if (qvnc_screen->swapBytes()) + return true; +#endif + + const int screendepth = qvnc_screen->depth(); + if (screendepth != pixelFormat.bitsPerPixel) + return true; + + switch (screendepth) { + case 32: + case 24: + return false; + case 18: + return (pixelFormat.redBits == 6 + && pixelFormat.greenBits == 6 + && pixelFormat.blueBits == 6); + case 16: + return (pixelFormat.redBits == 5 + && pixelFormat.greenBits == 6 + && pixelFormat.blueBits == 5); + case 15: + return (pixelFormat.redBits == 5 + && pixelFormat.greenBits == 5 + && pixelFormat.blueBits == 5); + case 12: + return (pixelFormat.redBits == 4 + && pixelFormat.greenBits == 4 + && pixelFormat.blueBits == 4); + } + return true; +} + +// count: number of pixels +void QVNCServer::convertPixels(char *dst, const char *src, int count) const +{ + const int screendepth = qvnc_screen->depth(); + const bool isBgr = false; //### qvnc_screen->pixelType() == QScreen::BGRPixel; + + // cutoffs +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + if (!swapBytes) +#endif + if (sameEndian) { + if (screendepth == pixelFormat.bitsPerPixel) { // memcpy cutoffs + + switch (screendepth) { + case 32: + memcpy(dst, src, count * sizeof(quint32)); + return; + case 16: + if (pixelFormat.redBits == 5 + && pixelFormat.greenBits == 6 + && pixelFormat.blueBits == 5) + { + memcpy(dst, src, count * sizeof(quint16)); + return; + } + } + } else if (screendepth == 16 && pixelFormat.bitsPerPixel == 32) { +#if defined(__i386__) // Currently fails on ARM if dst is not 4 byte aligned + const quint32 *src32 = reinterpret_cast(src); + quint32 *dst32 = reinterpret_cast(dst); + int count32 = count * sizeof(quint16) / sizeof(quint32); + while (count32--) { + const quint32 s = *src32++; + quint32 result1; + quint32 result2; + + // red + result1 = ((s & 0xf8000000) | ((s & 0xe0000000) >> 5)) >> 8; + result2 = ((s & 0x0000f800) | ((s & 0x0000e000) >> 5)) << 8; + + // green + result1 |= ((s & 0x07e00000) | ((s & 0x06000000) >> 6)) >> 11; + result2 |= ((s & 0x000007e0) | ((s & 0x00000600) >> 6)) << 5; + + // blue + result1 |= ((s & 0x001f0000) | ((s & 0x001c0000) >> 5)) >> 13; + result2 |= ((s & 0x0000001f) | ((s & 0x0000001c) >> 5)) << 3; + + *dst32++ = result2; + *dst32++ = result1; + } + if (count & 0x1) { + const quint16 *src16 = reinterpret_cast(src); + dst32[count - 1] = qt_conv16ToRgb(src16[count - 1]); + } + return; +#endif + } + } + + const int bytesPerPixel = (pixelFormat.bitsPerPixel + 7) / 8; + +// nibble = 0; + + for (int i = 0; i < count; ++i) { + int r, g, b; + + switch (screendepth) { +#if 0 + case 4: { + if (!nibble) { + r = ((*src) & 0x0f) << 4; + } else { + r = (*src) & 0xf0; + src++; + } + nibble = !nibble; + g = b = r; + break; + } +#endif +#if 0 + case 8: { + QRgb rgb = qvnc_screen->clut()[int(*src)]; + r = qRed(rgb); + g = qGreen(rgb); + b = qBlue(rgb); + src++; + break; + } +#endif +#ifdef QT_QWS_DEPTH_12 + case 12: { + quint32 p = quint32(*reinterpret_cast(src)); + r = qRed(p); + g = qGreen(p); + b = qBlue(p); + src += sizeof(qrgb444); + break; + } +#endif +#ifdef QT_QWS_DEPTH_15 + case 15: { + quint32 p = quint32(*reinterpret_cast(src)); + r = qRed(p); + g = qGreen(p); + b = qBlue(p); + src += sizeof(qrgb555); + break; + } +#endif + case 16: { + quint16 p = *reinterpret_cast(src); +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + if (swapBytes) + p = ((p & 0xff) << 8) | ((p & 0xff00) >> 8); +#endif + r = (p >> 11) & 0x1f; + g = (p >> 5) & 0x3f; + b = p & 0x1f; + r <<= 3; + g <<= 2; + b <<= 3; + src += sizeof(quint16); + break; + } +#ifdef QT_QWS_DEPTH_18 + case 18: { + quint32 p = quint32(*reinterpret_cast(src)); + r = qRed(p); + g = qGreen(p); + b = qBlue(p); + src += sizeof(qrgb666); + break; + } +#endif +#ifdef QT_QWS_DEPTH_24 + case 24: { + quint32 p = quint32(*reinterpret_cast(src)); + r = qRed(p); + g = qGreen(p); + b = qBlue(p); + src += sizeof(qrgb888); + break; + } +#endif + case 32: { + quint32 p = *reinterpret_cast(src); + r = (p >> 16) & 0xff; + g = (p >> 8) & 0xff; + b = p & 0xff; + src += sizeof(quint32); + break; + } + default: { + r = g = b = 0; + qDebug("QVNCServer: don't support %dbpp display", screendepth); + return; + } + } + +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + if (swapBytes ^ isBgr) +#else + if (isBgr) +#endif + qSwap(r, b); + + r >>= (8 - pixelFormat.redBits); + g >>= (8 - pixelFormat.greenBits); + b >>= (8 - pixelFormat.blueBits); + + int pixel = (r << pixelFormat.redShift) | + (g << pixelFormat.greenShift) | + (b << pixelFormat.blueShift); + + if (sameEndian || pixelFormat.bitsPerPixel == 8) { + memcpy(dst, &pixel, bytesPerPixel); // XXX: do a simple for-loop instead? + dst += bytesPerPixel; + continue; + } + + + if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { + switch (pixelFormat.bitsPerPixel) { + case 16: + pixel = (((pixel & 0x0000ff00) << 8) | + ((pixel & 0x000000ff) << 24)); + break; + case 32: + pixel = (((pixel & 0xff000000) >> 24) | + ((pixel & 0x00ff0000) >> 8) | + ((pixel & 0x0000ff00) << 8) | + ((pixel & 0x000000ff) << 24)); + break; + default: + qDebug("Cannot handle %d bpp client", pixelFormat.bitsPerPixel); + } + } else { // QSysInfo::ByteOrder == QSysInfo::LittleEndian + switch (pixelFormat.bitsPerPixel) { + case 16: + pixel = (((pixel & 0xff000000) >> 8) | + ((pixel & 0x00ff0000) << 8)); + break; + case 32: + pixel = (((pixel & 0xff000000) >> 24) | + ((pixel & 0x00ff0000) >> 8) | + ((pixel & 0x0000ff00) << 8) | + ((pixel & 0x000000ff) << 24)); + break; + default: + qDebug("Cannot handle %d bpp client", + pixelFormat.bitsPerPixel); + break; + } + } + memcpy(dst, &pixel, bytesPerPixel); // XXX: simple for-loop instead? + dst += bytesPerPixel; + } +} + +#ifndef QT_NO_QWS_CURSOR +static void blendCursor(QImage &image, const QRect &imageRect) +{ + const QRect cursorRect = qt_screencursor->boundingRect(); + const QRect intersection = (cursorRect & imageRect); + const QRect destRect = intersection.translated(-imageRect.topLeft()); + const QRect srcRect = intersection.translated(-cursorRect.topLeft()); + + QPainter painter(&image); + painter.drawImage(destRect, qt_screencursor->image(), srcRect); + painter.end(); +} +#endif // QT_NO_QWS_CURSOR + +QVNCDirtyMap::QVNCDirtyMap(QVNCGraphicsSystemScreen *s) + : bytesPerPixel(0), numDirty(0), screen(s) +{ + bytesPerPixel = (screen->depth() + 7) / 8; + QSize screenSize = screen->geometry().size(); + bufferWidth = screenSize.width(); + bufferHeight = screenSize.height(); + bufferStride = bufferWidth * bytesPerPixel; + buffer = new uchar[bufferHeight * bufferStride]; + + mapWidth = (bufferWidth + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE; + mapHeight = (bufferHeight + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE; + numTiles = mapWidth * mapHeight; + map = new uchar[numTiles]; +} + +QVNCDirtyMap::~QVNCDirtyMap() +{ + delete[] map; + delete[] buffer; +} + +void QVNCDirtyMap::reset() +{ + memset(map, 1, numTiles); + memset(buffer, 0, bufferHeight * bufferStride); + numDirty = numTiles; +} + +inline bool QVNCDirtyMap::dirty(int x, int y) const +{ + return map[y * mapWidth + x]; +} + +inline void QVNCDirtyMap::setClean(int x, int y) +{ + map[y * mapWidth + x] = 0; + --numDirty; +} + +template +void QVNCDirtyMapOptimized::setDirty(int tileX, int tileY, bool force) +{ + static bool alwaysForce = qgetenv("QT_VNC_NO_COMPAREBUFFER").toInt(); + if (alwaysForce) + force = true; + + bool changed = false; + + if (!force) { + const int lstep = screen->linestep(); + const int startX = tileX * MAP_TILE_SIZE; + const int startY = tileY * MAP_TILE_SIZE; + const uchar *scrn = screen->base() + + startY * lstep + startX * bytesPerPixel; + uchar *old = buffer + startY * bufferStride + startX * sizeof(T); + + const int tileHeight = (startY + MAP_TILE_SIZE > bufferHeight ? + bufferHeight - startY : MAP_TILE_SIZE); + const int tileWidth = (startX + MAP_TILE_SIZE > bufferWidth ? + bufferWidth - startX : MAP_TILE_SIZE); + const bool doInlines = (tileWidth == MAP_TILE_SIZE); + + int y = tileHeight; + + if (doInlines) { // hw: memcmp/memcpy is inlined when using constants + while (y) { + if (memcmp(old, scrn, sizeof(T) * MAP_TILE_SIZE)) { + changed = true; + break; + } + scrn += lstep; + old += bufferStride; + --y; + } + + while (y) { + memcpy(old, scrn, sizeof(T) * MAP_TILE_SIZE); + scrn += lstep; + old += bufferStride; + --y; + } + } else { + while (y) { + if (memcmp(old, scrn, sizeof(T) * tileWidth)) { + changed = true; + break; + } + scrn += lstep; + old += bufferStride; + --y; + } + + while (y) { + memcpy(old, scrn, sizeof(T) * tileWidth); + scrn += lstep; + old += bufferStride; + --y; + } + } + } + + const int mapIndex = tileY * mapWidth + tileX; + if ((force || changed) && !map[mapIndex]) { + map[mapIndex] = 1; + ++numDirty; + } +} + +template +QRfbHextileEncoder::QRfbHextileEncoder(QVNCServer *s) + : QRfbEncoder(s), + singleColorHextile(this), dualColorHextile(this), multiColorHextile(this) +{ +} + +/* + \internal + Send dirty rects using hextile encoding. +*/ +template +void QRfbHextileEncoder::write() +{ +// QWSDisplay::grab(true); + + QVNCDirtyMap *map = server->dirtyMap(); + QTcpSocket *socket = server->clientSocket(); + + const quint32 encoding = htonl(5); // hextile encoding + const int bytesPerPixel = server->clientBytesPerPixel(); + + { + const char tmp[2] = { 0, 0 }; // msg type, padding + socket->write(tmp, sizeof(tmp)); + } + { + const quint16 count = htons(map->numDirty); + socket->write((char *)&count, sizeof(count)); + } + + if (map->numDirty <= 0) { +// QWSDisplay::ungrab(); + return; + } + + newBg = true; + newFg = true; + + const QImage screenImage = server->screenImage(); + QRfbRect rect(0, 0, MAP_TILE_SIZE, MAP_TILE_SIZE); + + QSize screenSize = server->screen()->geometry().size(); + + for (int y = 0; y < map->mapHeight; ++y) { + if (rect.y + MAP_TILE_SIZE > screenSize.height()) + rect.h = screenSize.height() - rect.y; + rect.w = MAP_TILE_SIZE; + for (int x = 0; x < map->mapWidth; ++x) { + if (!map->dirty(x, y)) + continue; + map->setClean(x, y); + + rect.x = x * MAP_TILE_SIZE; + if (rect.x + MAP_TILE_SIZE > screenSize.width()) //###deviceWidth ??? + rect.w = screenSize.width() - rect.x; + rect.write(socket); + + socket->write((char *)&encoding, sizeof(encoding)); + + const uchar *screendata = screenImage.scanLine(rect.y) + + rect.x * screenImage.depth() / 8; + int linestep = screenImage.bytesPerLine(); + +#ifndef QT_NO_QWS_CURSOR + // hardware cursors must be blended with the screen memory + const bool doBlendCursor = qt_screencursor + && !server->hasClientCursor() + && qt_screencursor->isAccelerated(); + QImage tileImage; + if (doBlendCursor) { + const QRect tileRect(rect.x, rect.y, rect.w, rect.h); + const QRect cursorRect = qt_screencursor->boundingRect() + .translated(-server->screen()->offset()); + if (tileRect.intersects(cursorRect)) { + tileImage = screenImage.copy(tileRect); + blendCursor(tileImage, + tileRect.translated(server->screen()->offset())); + screendata = tileImage.bits(); + linestep = tileImage.bytesPerLine(); + } + } +#endif // QT_NO_QWS_CURSOR + + if (singleColorHextile.read(screendata, rect.w, rect.h, linestep)) { + singleColorHextile.write(socket); + } else if (dualColorHextile.read(screendata, rect.w, rect.h, linestep)) { + dualColorHextile.write(socket); + } else if (multiColorHextile.read(screendata, rect.w, rect.h, linestep)) { + multiColorHextile.write(socket); + } else if (server->doPixelConversion()) { + const int bufferSize = rect.w * rect.h * bytesPerPixel + 1; + const int padding = sizeof(quint32) - sizeof(char); + buffer.resize(bufferSize + padding); + + buffer[padding] = 1; // Raw subencoding + + // convert pixels + char *b = buffer.data() + padding + 1; + const int bstep = rect.w * bytesPerPixel; + for (int i = 0; i < rect.h; ++i) { + server->convertPixels(b, (const char*)screendata, rect.w); + screendata += linestep; + b += bstep; + } + socket->write(buffer.constData() + padding, bufferSize); + } else { + quint8 subenc = 1; // Raw subencoding + socket->write((char *)&subenc, 1); + + // send pixels + for (int i = 0; i < rect.h; ++i) { + socket->write((const char*)screendata, + rect.w * bytesPerPixel); + screendata += linestep; + } + } + } + if (socket->state() == QAbstractSocket::UnconnectedState) + break; + rect.y += MAP_TILE_SIZE; + } + socket->flush(); + Q_ASSERT(map->numDirty == 0); + +// QWSDisplay::ungrab(); +} + +void QRfbRawEncoder::write() +{ +// QWSDisplay::grab(false); + + QVNCDirtyMap *map = server->dirtyMap(); + QTcpSocket *socket = server->clientSocket(); + + const int bytesPerPixel = server->clientBytesPerPixel(); + QSize screenSize = server->screen()->geometry().size(); + + // create a region from the dirty rects and send the region's merged rects. + QRegion rgn; + if (map) { + for (int y = 0; y < map->mapHeight; ++y) { + for (int x = 0; x < map->mapWidth; ++x) { + if (!map->dirty(x, y)) + continue; + rgn += QRect(x * MAP_TILE_SIZE, y * MAP_TILE_SIZE, + MAP_TILE_SIZE, MAP_TILE_SIZE); + map->setClean(x, y); + } + } + + rgn &= QRect(0, 0, screenSize.width(), + screenSize.height()); + } + const QVector rects = rgn.rects(); + + { + const char tmp[2] = { 0, 0 }; // msg type, padding + socket->write(tmp, sizeof(tmp)); + } + + { + const quint16 count = htons(rects.size()); + socket->write((char *)&count, sizeof(count)); + } + + if (rects.size() <= 0) { +// QWSDisplay::ungrab(); + return; + } + + const QImage *screenImage = server->screenImage(); + + for (int i = 0; i < rects.size(); ++i) { + const QRect tileRect = rects.at(i); + const QRfbRect rect(tileRect.x(), tileRect.y(), + tileRect.width(), tileRect.height()); + rect.write(socket); + + const quint32 encoding = htonl(0); // raw encoding + socket->write((char *)&encoding, sizeof(encoding)); + + int linestep = screenImage->bytesPerLine(); + const uchar *screendata = screenImage->scanLine(rect.y) + + rect.x * screenImage->depth() / 8; + +#ifndef QT_NO_QWS_CURSOR + // hardware cursors must be blended with the screen memory + const bool doBlendCursor = qt_screencursor + && !server->hasClientCursor() + && qt_screencursor->isAccelerated(); + QImage tileImage; + if (doBlendCursor) { + const QRect cursorRect = qt_screencursor->boundingRect() + .translated(-server->screen()->offset()); + if (tileRect.intersects(cursorRect)) { + tileImage = screenImage->copy(tileRect); + blendCursor(tileImage, + tileRect.translated(server->screen()->offset())); + screendata = tileImage.bits(); + linestep = tileImage.bytesPerLine(); + } + } +#endif // QT_NO_QWS_CURSOR + + if (server->doPixelConversion()) { + const int bufferSize = rect.w * rect.h * bytesPerPixel; + if (bufferSize > buffer.size()) + buffer.resize(bufferSize); + + // convert pixels + char *b = buffer.data(); + const int bstep = rect.w * bytesPerPixel; + for (int i = 0; i < rect.h; ++i) { + server->convertPixels(b, (const char*)screendata, rect.w); + screendata += linestep; + b += bstep; + } + socket->write(buffer.constData(), bufferSize); + } else { + for (int i = 0; i < rect.h; ++i) { + socket->write((const char*)screendata, rect.w * bytesPerPixel); + screendata += linestep; + } + } + if (socket->state() == QAbstractSocket::UnconnectedState) + break; + } + socket->flush(); + +// QWSDisplay::ungrab(); +} + +inline QImage *QVNCServer::screenImage() const +{ + return qvnc_screen->image(); +} + +void QVNCServer::checkUpdate() +{ + if (!wantUpdate) + return; + + if (dirtyCursor) { +#ifndef QT_NO_QWS_CURSOR + Q_ASSERT(qvnc_cursor); + qvnc_cursor->write(); +#endif + cursor->sendClientCursor(); + dirtyCursor = false; + wantUpdate = false; + return; + } + + if (dirtyMap()->numDirty > 0) { + if (encoder) + encoder->write(); + wantUpdate = false; + } +} + +void QVNCServer::discardClient() +{ + timer->stop(); + state = Unconnected; + delete encoder; + encoder = 0; +#ifndef QT_NO_QWS_CURSOR + delete qvnc_cursor; + qvnc_cursor = 0; +#endif +// if (!qvnc_screen->screen()) +// QWSServer::instance()->enablePainting(false); +} + + + +QVNCGraphicsSystemScreenPrivate::QVNCGraphicsSystemScreenPrivate(QVNCGraphicsSystemScreen *parent) + : dpiX(72), dpiY(72), doOnScreenSurface(false), refreshRate(25), + vncServer(0), q_ptr(parent) +{ +#if 0//ndef QT_NO_QWS_SIGNALHANDLER + QWSSignalHandler::instance()->addObject(this); +#endif + + vncServer = new QVNCServer(q_ptr); + vncServer->setRefreshRate(refreshRate); + + + Q_ASSERT(q_ptr->depth() == 32); + + dirty = new QVNCDirtyMapOptimized(q_ptr); +} + +QVNCGraphicsSystemScreenPrivate::~QVNCGraphicsSystemScreenPrivate() +{ +} + + +void QVNCGraphicsSystemScreenPrivate::setDirty(const QRect& rect, bool force) +{ + if (rect.isEmpty()) + return; + +// if (q_ptr->screen()) +// q_ptr->screen()->setDirty(rect); + + if (!vncServer || !vncServer->isConnected()) { +// qDebug() << "QVNCGraphicsSystemScreenPrivate::setDirty() - Not connected"; + return; + } + const QRect r = rect; // .translated(-q_ptr->offset()); + const int x1 = r.x() / MAP_TILE_SIZE; + int y = r.y() / MAP_TILE_SIZE; + for (; (y <= r.bottom() / MAP_TILE_SIZE) && y < dirty->mapHeight; y++) + for (int x = x1; (x <= r.right() / MAP_TILE_SIZE) && x < dirty->mapWidth; x++) + dirty->setDirty(x, y, force); + + vncServer->setDirty(); +} + + + + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/vnc/qvncserver.h b/src/plugins/platforms/vnc/qvncserver.h new file mode 100644 index 0000000..4fcdbae --- /dev/null +++ b/src/plugins/platforms/vnc/qvncserver.h @@ -0,0 +1,534 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSCREENVNC_P_H +#define QSCREENVNC_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include "qgraphicssystem_vnc.h" +#include "qvnccursor.h" +#define QT_NO_QWS_CURSOR + +#ifndef QT_NO_QWS_VNC + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QVNCServer; + +#ifndef QT_NO_QWS_CURSOR +class QVNCCursor : public QProxyScreenCursor +{ +public: + QVNCCursor(QVNCGraphicsSystemScreen *s); + ~QVNCCursor(); + + void hide(); + void show(); + void set(const QImage &image, int hotx, int hoty); + void move(int x, int y); + +private: + void setDirty(const QRect &r) const; + QVNCGraphicsSystemScreen *screen; +}; + +class QVNCClientCursor : public QProxyScreenCursor +{ +public: + QVNCClientCursor(QVNCServer *s); + ~QVNCClientCursor(); + + void set(const QImage &image, int hotx, int hoty); + void write() const; + +private: + QVNCServer *server; +}; +#endif // QT_NO_QWS_CURSOR + +#define MAP_TILE_SIZE 16 +#define MAP_WIDTH 1280 / MAP_TILE_SIZE +#define MAP_HEIGHT 1024 / MAP_TILE_SIZE + +class QVNCDirtyMap +{ +public: + QVNCDirtyMap(QVNCGraphicsSystemScreen *screen); + virtual ~QVNCDirtyMap(); + + void reset(); + bool dirty(int x, int y) const; + virtual void setDirty(int x, int y, bool force = false) = 0; + void setClean(int x, int y); + + int bytesPerPixel; + + int numDirty; + int mapWidth; + int mapHeight; + +protected: + uchar *map; + QVNCGraphicsSystemScreen *screen; + uchar *buffer; + int bufferWidth; + int bufferHeight; + int bufferStride; + int numTiles; +}; + +template +class QVNCDirtyMapOptimized : public QVNCDirtyMap +{ +public: + QVNCDirtyMapOptimized(QVNCGraphicsSystemScreen *screen) : QVNCDirtyMap(screen) {} + ~QVNCDirtyMapOptimized() {} + + void setDirty(int x, int y, bool force = false); +}; + +class QRfbRect +{ +public: + QRfbRect() {} + QRfbRect(quint16 _x, quint16 _y, quint16 _w, quint16 _h) { + x = _x; y = _y; w = _w; h = _h; + } + + void read(QTcpSocket *s); + void write(QTcpSocket *s) const; + + quint16 x; + quint16 y; + quint16 w; + quint16 h; +}; + +class QRfbPixelFormat +{ +public: + static int size() { return 16; } + + void read(QTcpSocket *s); + void write(QTcpSocket *s); + + int bitsPerPixel; + int depth; + bool bigEndian; + bool trueColor; + int redBits; + int greenBits; + int blueBits; + int redShift; + int greenShift; + int blueShift; +}; + +class QRfbServerInit +{ +public: + QRfbServerInit() { name = 0; } + ~QRfbServerInit() { delete[] name; } + + int size() const { return QRfbPixelFormat::size() + 8 + strlen(name); } + void setName(const char *n); + + void read(QTcpSocket *s); + void write(QTcpSocket *s); + + quint16 width; + quint16 height; + QRfbPixelFormat format; + char *name; +}; + +class QRfbSetEncodings +{ +public: + bool read(QTcpSocket *s); + + quint16 count; +}; + +class QRfbFrameBufferUpdateRequest +{ +public: + bool read(QTcpSocket *s); + + char incremental; + QRfbRect rect; +}; + +class QRfbKeyEvent +{ +public: + bool read(QTcpSocket *s); + + char down; + int keycode; + int unicode; +}; + +class QRfbPointerEvent +{ +public: + bool read(QTcpSocket *s); + + Qt::MouseButtons buttons; + enum { WheelNone, + WheelUp, + WheelDown, + WheelLeft, + WheelRight + } wheelDirection; + quint16 x; + quint16 y; +}; + +class QRfbClientCutText +{ +public: + bool read(QTcpSocket *s); + + quint32 length; +}; + +class QVNCGraphicsSystemScreenPrivate : public QObject +{ +public: + QVNCGraphicsSystemScreenPrivate(QVNCGraphicsSystemScreen *parent); + ~QVNCGraphicsSystemScreenPrivate(); + + void setDirty(const QRect &rect, bool force = false); + void configure(); + + qreal dpiX; + qreal dpiY; + bool doOnScreenSurface; + QVNCDirtyMap *dirty; + int refreshRate; + QVNCServer *vncServer; + +#if !defined(QT_NO_QWS_MULTIPROCESS) && !defined(QT_NO_SHAREDMEMORY) + QSharedMemory shm; +#endif + + QVNCGraphicsSystemScreen *q_ptr; +}; + +class QRfbEncoder +{ +public: + QRfbEncoder(QVNCServer *s) : server(s) {} + virtual ~QRfbEncoder() {} + + virtual void write() = 0; + +protected: + QVNCServer *server; +}; + +class QRfbRawEncoder : public QRfbEncoder +{ +public: + QRfbRawEncoder(QVNCServer *s) : QRfbEncoder(s) {} + + void write(); + +private: + QByteArray buffer; +}; + +template class QRfbHextileEncoder; + +template +class QRfbSingleColorHextile +{ +public: + QRfbSingleColorHextile(QRfbHextileEncoder *e) : encoder(e) {} + bool read(const uchar *data, int width, int height, int stride); + void write(QTcpSocket *socket) const; + +private: + QRfbHextileEncoder *encoder; +}; + +template +class QRfbDualColorHextile +{ +public: + QRfbDualColorHextile(QRfbHextileEncoder *e) : encoder(e) {} + bool read(const uchar *data, int width, int height, int stride); + void write(QTcpSocket *socket) const; + +private: + struct Rect { + quint8 xy; + quint8 wh; + } Q_PACKED rects[8 * 16]; + + quint8 numRects; + QRfbHextileEncoder *encoder; + +private: + inline int lastx() const { return rectx(numRects); } + inline int lasty() const { return recty(numRects); } + inline int rectx(int r) const { return rects[r].xy >> 4; } + inline int recty(int r) const { return rects[r].xy & 0x0f; } + inline int width(int r) const { return (rects[r].wh >> 4) + 1; } + inline int height(int r) const { return (rects[r].wh & 0x0f) + 1; } + + inline void setX(int r, int x) { + rects[r].xy = (x << 4) | (rects[r].xy & 0x0f); + } + inline void setY(int r, int y) { + rects[r].xy = (rects[r].xy & 0xf0) | y; + } + inline void setWidth(int r, int width) { + rects[r].wh = ((width - 1) << 4) | (rects[r].wh & 0x0f); + } + inline void setHeight(int r, int height) { + rects[r].wh = (rects[r].wh & 0xf0) | (height - 1); + } + + inline void setWidth(int width) { setWidth(numRects, width); } + inline void setHeight(int height) { setHeight(numRects, height); } + inline void setX(int x) { setX(numRects, x); } + inline void setY(int y) { setY(numRects, y); } + void next(); +}; + +template +class QRfbMultiColorHextile +{ +public: + QRfbMultiColorHextile(QRfbHextileEncoder *e) : encoder(e) {} + bool read(const uchar *data, int width, int height, int stride); + void write(QTcpSocket *socket) const; + +private: + inline quint8* rect(int r) { + return rects.data() + r * (bpp + 2); + } + inline const quint8* rect(int r) const { + return rects.constData() + r * (bpp + 2); + } + inline void setX(int r, int x) { + quint8 *ptr = rect(r) + bpp; + *ptr = (x << 4) | (*ptr & 0x0f); + } + inline void setY(int r, int y) { + quint8 *ptr = rect(r) + bpp; + *ptr = (*ptr & 0xf0) | y; + } + void setColor(SRC color); + inline int rectx(int r) const { + const quint8 *ptr = rect(r) + bpp; + return *ptr >> 4; + } + inline int recty(int r) const { + const quint8 *ptr = rect(r) + bpp; + return *ptr & 0x0f; + } + inline void setWidth(int r, int width) { + quint8 *ptr = rect(r) + bpp + 1; + *ptr = ((width - 1) << 4) | (*ptr & 0x0f); + } + inline void setHeight(int r, int height) { + quint8 *ptr = rect(r) + bpp + 1; + *ptr = (*ptr & 0xf0) | (height - 1); + } + + bool beginRect(); + void endRect(); + + static const int maxRectsSize = 16 * 16; + QVarLengthArray rects; + + quint8 bpp; + quint8 numRects; + QRfbHextileEncoder *encoder; +}; + +template +class QRfbHextileEncoder : public QRfbEncoder +{ +public: + QRfbHextileEncoder(QVNCServer *s); + void write(); + +private: + enum SubEncoding { + Raw = 1, + BackgroundSpecified = 2, + ForegroundSpecified = 4, + AnySubrects = 8, + SubrectsColoured = 16 + }; + + QByteArray buffer; + QRfbSingleColorHextile singleColorHextile; + QRfbDualColorHextile dualColorHextile; + QRfbMultiColorHextile multiColorHextile; + + SRC bg; + SRC fg; + bool newBg; + bool newFg; + + friend class QRfbSingleColorHextile; + friend class QRfbDualColorHextile; + friend class QRfbMultiColorHextile; +}; + +class QVNCServer : public QObject +{ + Q_OBJECT +public: + QVNCServer(QVNCGraphicsSystemScreen *screen); + QVNCServer(QVNCGraphicsSystemScreen *screen, int id); + ~QVNCServer(); + + void setDirty(); + void setDirtyCursor() { dirtyCursor = true; setDirty(); } + inline bool isConnected() const { return state == Connected; } + inline void setRefreshRate(int rate) { refreshRate = rate; } + + enum ClientMsg { SetPixelFormat = 0, + FixColourMapEntries = 1, + SetEncodings = 2, + FramebufferUpdateRequest = 3, + KeyEvent = 4, + PointerEvent = 5, + ClientCutText = 6 }; + + enum ServerMsg { FramebufferUpdate = 0, + SetColourMapEntries = 1 }; + + void convertPixels(char *dst, const char *src, int count) const; + + inline int clientBytesPerPixel() const { + return pixelFormat.bitsPerPixel / 8; + } + + inline QVNCGraphicsSystemScreen* screen() const { return qvnc_screen; } + inline QVNCDirtyMap* dirtyMap() const { return qvnc_screen->dirtyMap(); } + inline QTcpSocket* clientSocket() const { return client; } + QImage *screenImage() const; + inline bool doPixelConversion() const { return needConversion; } +#ifndef QT_NO_QWS_CURSOR + inline bool hasClientCursor() const { return qvnc_cursor != 0; } +#endif + + void setCursor(QVNCCursor * c) { cursor = c; } +private: + void setPixelFormat(); + void setEncodings(); + void frameBufferUpdateRequest(); + void pointerEvent(); + void keyEvent(); + void clientCutText(); + bool pixelConversionNeeded() const; + +private slots: + void newConnection(); + void readClient(); + void checkUpdate(); + void discardClient(); + void sendInputEvents(); + +private: + void init(uint port); + enum ClientState { Unconnected, Protocol, Init, Connected }; + QTimer *timer; + QTcpServer *serverSocket; + QTcpSocket *client; + ClientState state; + quint8 msgType; + bool handleMsg; + QRfbPixelFormat pixelFormat; + Qt::KeyboardModifiers keymod; + Qt::MouseButtons buttons; + int encodingsPending; + int cutTextPending; + uint supportCopyRect : 1; + uint supportRRE : 1; + uint supportCoRRE : 1; + uint supportHextile : 1; + uint supportZRLE : 1; + uint supportCursor : 1; + uint supportDesktopSize : 1; + bool wantUpdate; + bool sameEndian; + bool needConversion; +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + bool swapBytes; +#endif + bool dirtyCursor; + int refreshRate; + QVNCGraphicsSystemScreen *qvnc_screen; +#ifndef QT_NO_QWS_CURSOR + QVNCClientCursor *qvnc_cursor; +#endif + + QRfbEncoder *encoder; + QVNCCursor *cursor; +}; + + +QT_END_NAMESPACE +#endif // QT_NO_QWS_VNC +#endif // QSCREENVNC_P_H diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro new file mode 100644 index 0000000..0b73b5b --- /dev/null +++ b/src/plugins/platforms/vnc/vnc.pro @@ -0,0 +1,19 @@ +TARGET = qvncgraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +SOURCES = main.cpp qgraphicssystem_vnc.cpp +HEADERS = qgraphicssystem_vnc.h + +HEADERS += qvncserver.h +SOURCES += qvncserver.cpp + +HEADERS += qvnccursor.h +SOURCES += qvnccursor.cpp + +include(../fb_base/fb_base.pri) + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems + +INSTALLS += target -- cgit v0.12 From bf36f88b92fa95704f117124c15ef896f553939c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 31 Mar 2010 12:16:07 +0200 Subject: Compile fix --- src/gui/kernel/qplatformintegration_lite.cpp | 41 ++++++++++++++++++++++++++ src/gui/kernel/qplatformscreen_lite.cpp | 43 ++++++++++++++++++++++++++++ src/gui/kernel/qplatformscreen_lite.h | 41 ++++++++++++++++++++++++++ src/gui/painting/qblittable_p.h | 1 + 4 files changed, 126 insertions(+) diff --git a/src/gui/kernel/qplatformintegration_lite.cpp b/src/gui/kernel/qplatformintegration_lite.cpp index 0e28fc6..f9adc14 100644 --- a/src/gui/kernel/qplatformintegration_lite.cpp +++ b/src/gui/kernel/qplatformintegration_lite.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 "qplatformintegration_lite.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qplatformscreen_lite.cpp b/src/gui/kernel/qplatformscreen_lite.cpp index f2ea2f8..4492463 100644 --- a/src/gui/kernel/qplatformscreen_lite.cpp +++ b/src/gui/kernel/qplatformscreen_lite.cpp @@ -1,4 +1,47 @@ +/**************************************************************************** +** +** 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 "qplatformscreen_lite.h" +#include +#include QWidget *QPlatformScreen::topLevelAt(const QPoint & pos) const { diff --git a/src/gui/kernel/qplatformscreen_lite.h b/src/gui/kernel/qplatformscreen_lite.h index ef90dee..da0e26b 100644 --- a/src/gui/kernel/qplatformscreen_lite.h +++ b/src/gui/kernel/qplatformscreen_lite.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 QPLATFORMSCREEN_H #define QPLATFORMSCREEN_H diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h index 98caab7d..645f37e 100644 --- a/src/gui/painting/qblittable_p.h +++ b/src/gui/painting/qblittable_p.h @@ -2,6 +2,7 @@ #define QBLITTABLE_P_H #include +#include #ifndef QT_NO_BLITTABLE QT_BEGIN_NAMESPACE -- cgit v0.12 From 22b7de20fdc0f11d943f235227f59608a88992c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 31 Mar 2010 12:19:59 +0200 Subject: Make directfb plugin work with QPlatformIntegration --- src/plugins/platforms/directfb/directfb.pro | 29 ++ src/plugins/platforms/directfb/main.cpp | 71 +++++ .../platforms/directfb/qblitter_directfb.cpp | 109 +++++++ src/plugins/platforms/directfb/qblitter_directfb.h | 29 ++ .../platforms/directfb/qdirectfbconvenience.cpp | 335 +++++++++++++++++++++ .../platforms/directfb/qdirectfbconvenience.h | 43 +++ src/plugins/platforms/directfb/qdirectfbcursor.cpp | 42 +++ src/plugins/platforms/directfb/qdirectfbcursor.h | 22 ++ src/plugins/platforms/directfb/qdirectfbinput.cpp | 205 +++++++++++++ src/plugins/platforms/directfb/qdirectfbinput.h | 63 ++++ .../directfb/qplatformintegration_directfb.cpp | 118 ++++++++ .../directfb/qplatformintegration_directfb.h | 98 ++++++ .../platforms/directfb/qwindowsurface_directfb.cpp | 231 ++++++++++++++ .../platforms/directfb/qwindowsurface_directfb.h | 88 ++++++ src/plugins/platforms/minimaldfb/main.cpp | 71 ----- src/plugins/platforms/minimaldfb/minimaldfb.pro | 29 -- .../platforms/minimaldfb/qblitter_directfb.cpp | 110 ------- .../platforms/minimaldfb/qblitter_directfb.h | 29 -- .../platforms/minimaldfb/qdirectfbconvenience.cpp | 335 --------------------- .../platforms/minimaldfb/qdirectfbconvenience.h | 43 --- .../platforms/minimaldfb/qdirectfbcursor.cpp | 42 --- src/plugins/platforms/minimaldfb/qdirectfbcursor.h | 22 -- .../platforms/minimaldfb/qdirectfbinput.cpp | 205 ------------- src/plugins/platforms/minimaldfb/qdirectfbinput.h | 63 ---- .../minimaldfb/qgraphicssystem_minimaldfb.cpp | 118 -------- .../minimaldfb/qgraphicssystem_minimaldfb.h | 99 ------ .../minimaldfb/qwindowsurface_minimaldfb.cpp | 231 -------------- .../minimaldfb/qwindowsurface_minimaldfb.h | 88 ------ 28 files changed, 1483 insertions(+), 1485 deletions(-) create mode 100644 src/plugins/platforms/directfb/directfb.pro create mode 100644 src/plugins/platforms/directfb/main.cpp create mode 100644 src/plugins/platforms/directfb/qblitter_directfb.cpp create mode 100644 src/plugins/platforms/directfb/qblitter_directfb.h create mode 100644 src/plugins/platforms/directfb/qdirectfbconvenience.cpp create mode 100644 src/plugins/platforms/directfb/qdirectfbconvenience.h create mode 100644 src/plugins/platforms/directfb/qdirectfbcursor.cpp create mode 100644 src/plugins/platforms/directfb/qdirectfbcursor.h create mode 100644 src/plugins/platforms/directfb/qdirectfbinput.cpp create mode 100644 src/plugins/platforms/directfb/qdirectfbinput.h create mode 100644 src/plugins/platforms/directfb/qplatformintegration_directfb.cpp create mode 100644 src/plugins/platforms/directfb/qplatformintegration_directfb.h create mode 100644 src/plugins/platforms/directfb/qwindowsurface_directfb.cpp create mode 100644 src/plugins/platforms/directfb/qwindowsurface_directfb.h delete mode 100644 src/plugins/platforms/minimaldfb/main.cpp delete mode 100644 src/plugins/platforms/minimaldfb/minimaldfb.pro delete mode 100644 src/plugins/platforms/minimaldfb/qblitter_directfb.cpp delete mode 100644 src/plugins/platforms/minimaldfb/qblitter_directfb.h delete mode 100644 src/plugins/platforms/minimaldfb/qdirectfbconvenience.cpp delete mode 100644 src/plugins/platforms/minimaldfb/qdirectfbconvenience.h delete mode 100644 src/plugins/platforms/minimaldfb/qdirectfbcursor.cpp delete mode 100644 src/plugins/platforms/minimaldfb/qdirectfbcursor.h delete mode 100644 src/plugins/platforms/minimaldfb/qdirectfbinput.cpp delete mode 100644 src/plugins/platforms/minimaldfb/qdirectfbinput.h delete mode 100644 src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.cpp delete mode 100644 src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.h delete mode 100644 src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.cpp delete mode 100644 src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.h diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro new file mode 100644 index 0000000..f8fccaa --- /dev/null +++ b/src/plugins/platforms/directfb/directfb.pro @@ -0,0 +1,29 @@ +TARGET = qdirectfb +include(../../qpluginbase.pri) +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms + +isEmpty(DIRECTFB_LIBS) { + DIRECTFB_LIBS = -ldirectfb -lfusion -ldirect -lpthread +} +isEmpty(DIRECTFB_INCLUDEPATH) { + DIRECTFB_INCLUDEPATH = /usr/include/directfb +} + +INCLUDEPATH += $$DIRECTFB_INCLUDEPATH +LIBS += $$DIRECTFB_LIBS + +SOURCES = main.cpp \ + qplatformintegration_directfb.cpp \ + qwindowsurface_directfb.cpp \ + qblitter_directfb.cpp \ + qdirectfbconvenience.cpp \ + qdirectfbinput.cpp \ + qdirectfbcursor.cpp +HEADERS = qplatformintegration_directfb.h \ + qwindowsurface_directfb.h \ + qblitter_directfb.h \ + qdirectfbconvenience.h \ + qdirectfbinput.h \ + qdirectfbcursor.h +target.path += $$[QT_INSTALL_PLUGINS]/platforms +INSTALLS += target diff --git a/src/plugins/platforms/directfb/main.cpp b/src/plugins/platforms/directfb/main.cpp new file mode 100644 index 0000000..1f0f081 --- /dev/null +++ b/src/plugins/platforms/directfb/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qplatformintegration_directfb.h" + +QT_BEGIN_NAMESPACE + +class QDirectFbIntegrationPlugin : public QPlatformIntegrationPlugin +{ +public: + QStringList keys() const; + QPlatformIntegration *create(const QString&); +}; + +QStringList QDirectFbIntegrationPlugin::keys() const +{ + QStringList list; + list << "directfb"; + return list; +} + +QPlatformIntegration * QDirectFbIntegrationPlugin::create(const QString& system) +{ + if (system.toLower() == "directfb") + return new QDirectFbIntegration; + + return 0; +} + +Q_EXPORT_PLUGIN2(directfb, QDirectFbIntegrationPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/directfb/qblitter_directfb.cpp b/src/plugins/platforms/directfb/qblitter_directfb.cpp new file mode 100644 index 0000000..08dee0a --- /dev/null +++ b/src/plugins/platforms/directfb/qblitter_directfb.cpp @@ -0,0 +1,109 @@ +#include "qblitter_directfb.h" +#include "qdirectfbconvenience.h" + +#include + +#include + +#include + +QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, IDirectFBSurface *surface) + : QBlittable(rect, QBlittable::Capabilities(QBlittable::SolidRectCapability + |QBlittable::SourcePixmapCapability + |QBlittable::SourceOverPixmapCapability + |QBlittable::SourceOverScaledPixmapCapability)) +{ + if (surface) { + m_surface = surface; + } else { + DFBSurfaceDescription surfaceDesc; + memset(&surfaceDesc,0,sizeof(DFBSurfaceDescription)); + surfaceDesc.width = rect.width(); + surfaceDesc.height = rect.height(); + surfaceDesc.caps = DSCAPS_PREMULTIPLIED; + surfaceDesc.pixelformat = DSPF_ARGB; + surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT); + + IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); + dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); + m_surface->Clear(m_surface,0,0,0,0); + } +} + +QDirectFbBlitter::~QDirectFbBlitter() +{ + unlock(); + m_surface->Release(m_surface); +} + +void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color) +{ + m_surface->SetColor(m_surface, color.red(), color.green(), color.blue(), color.alpha()); +// When the blitter api supports non opaque blits, also remember to change +// qpixmap_blitter.cpp::fill +// DFBSurfaceDrawingFlags drawingFlags = color.alpha() ? DSDRAW_BLEND : DSDRAW_NOFX; +// m_surface->SetDrawingFlags(m_surface, drawingFlags); + m_surface->SetDrawingFlags(m_surface, DSDRAW_NOFX); + m_surface->FillRectangle(m_surface, rect.x(), rect.y(), + rect.width(), rect.height()); +} + +void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &srcRect) +{ + QPixmapData *data = pixmap.pixmapData(); + Q_ASSERT(data->width() && data->height()); + Q_ASSERT(data->classId() == QPixmapData::BlitterClass); + QBlittablePixmapData *blitPm = static_cast(data); + QDirectFbBlitter *dfbBlitter = static_cast(blitPm->blittable()); + dfbBlitter->unlock(); + + IDirectFBSurface *s = dfbBlitter->m_surface; + + quint32 blittingFlags = pixmap.hasAlpha()? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; + + s->SetBlittingFlags(s, DFBSurfaceBlittingFlags(blittingFlags)); + m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags)); + m_surface->SetPorterDuff(m_surface,DSPD_SRC_OVER); + m_surface->SetDstBlendFunction(m_surface,DSBF_INVSRCALPHA); + + const DFBRectangle sRect = { srcRect.x(), srcRect.y(), rect.width(), rect.height() }; + + DFBResult result; + if (rect.width() == srcRect.width() && rect.height() == srcRect.height()) + result = m_surface->Blit(m_surface, s, &sRect, rect.x(), rect.y()); + else { + const DFBRectangle dRect = { rect.x(), rect.y(), rect.width(), rect.height() }; + result = m_surface->StretchBlit(m_surface, s, &sRect, &dRect); + } + if (result != DFB_OK) + DirectFBError("QDirectFBBlitter::drawPixmap()", result); +} + +QImage *QDirectFbBlitter::doLock() +{ + Q_ASSERT(m_surface); + Q_ASSERT(size().isValid()); + + void *mem; + int bpl; + const DFBResult result = m_surface->Lock(m_surface, DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast(&mem), &bpl); + if (result == DFB_OK) { + DFBSurfacePixelFormat dfbFormat; + DFBSurfaceCapabilities dfbCaps; + m_surface->GetPixelFormat(m_surface,&dfbFormat); + m_surface->GetCapabilities(m_surface,&dfbCaps); + QImage::Format format = QDirectFbConvenience::imageFormatFromSurfaceFormat(dfbFormat, dfbCaps); + int w, h; + m_surface->GetSize(m_surface,&w,&h); + m_image = QImage(static_cast(mem),w,h,bpl,format); + } else { + DirectFBError("Failed to lock image", result); + } + + return &m_image; +} + +void QDirectFbBlitter::doUnlock() +{ + m_surface->Unlock(m_surface); +} diff --git a/src/plugins/platforms/directfb/qblitter_directfb.h b/src/plugins/platforms/directfb/qblitter_directfb.h new file mode 100644 index 0000000..85a303a --- /dev/null +++ b/src/plugins/platforms/directfb/qblitter_directfb.h @@ -0,0 +1,29 @@ +#ifndef QDIRECTFBBLITTER_H +#define QDIRECTFBBLITTER_H + +#include "qdirectfbconvenience.h" + +#include + +#include + +class QDirectFbBlitter : public QBlittable +{ +public: + QDirectFbBlitter(const QSize &size, IDirectFBSurface *surface = 0); + virtual ~QDirectFbBlitter(); + + virtual void fillRect(const QRectF &rect, const QColor &color); + virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect); + +protected: + virtual QImage *doLock(); + virtual void doUnlock(); + + IDirectFBSurface *m_surface; + QImage m_image; + + friend class QDirectFbConvenience; +}; + +#endif // QDIRECTFBBLITTER_H diff --git a/src/plugins/platforms/directfb/qdirectfbconvenience.cpp b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp new file mode 100644 index 0000000..8594c09 --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp @@ -0,0 +1,335 @@ +#include "qdirectfbconvenience.h" +#include "qblitter_directfb.h" + +#include + +IDirectFB *QDirectFbConvenience::dfbInterface() +{ + static IDirectFB *dfb = 0; + if (!dfb) { + DFBResult result = DirectFBCreate(&dfb); + if (result != DFB_OK) { + DirectFBError("QDirectFBConvenience: error creating DirectFB interface",result); + return 0; + } + } + return dfb; +} + +IDirectFBDisplayLayer *QDirectFbConvenience::dfbDisplayLayer(int display) +{ + IDirectFBDisplayLayer *layer; + DFBResult result = QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),display,&layer); + if (result != DFB_OK) { + DirectFBError("QDirectFbConvenience: " + "Unable to get primary display layer!", result); + } + return layer; +} + +QImage::Format QDirectFbConvenience::imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps) +{ + switch (format) { + case DSPF_LUT8: + return QImage::Format_Indexed8; + case DSPF_RGB24: + return QImage::Format_RGB888; + case DSPF_ARGB4444: + return QImage::Format_ARGB4444_Premultiplied; + case DSPF_RGB444: + return QImage::Format_RGB444; + case DSPF_RGB555: + case DSPF_ARGB1555: + return QImage::Format_RGB555; + case DSPF_RGB16: + return QImage::Format_RGB16; + case DSPF_ARGB6666: + return QImage::Format_ARGB6666_Premultiplied; + case DSPF_RGB18: + return QImage::Format_RGB666; + case DSPF_RGB32: + return QImage::Format_RGB32; + case DSPF_ARGB: { + if (caps & DSCAPS_PREMULTIPLIED) + return QImage::Format_ARGB32_Premultiplied; + else return QImage::Format_ARGB32; } + default: + break; + } + return QImage::Format_Invalid; + +} + +int QDirectFbConvenience::colorDepthForSurface(const DFBSurfacePixelFormat format) +{ + return ((0x1f << 7) & format) >> 7; +} + +IDirectFBSurface *QDirectFbConvenience::dfbSurfaceForPixmapData(QPixmapData *pixmapData) +{ + QBlittablePixmapData *blittablePmData = static_cast(pixmapData); + if (blittablePmData) { + QBlittable *blittable = blittablePmData->blittable(); + QDirectFbBlitter *dfbBlitter = static_cast(blittable); + return dfbBlitter->m_surface; + } + return 0; +} + +Qt::MouseButton QDirectFbConvenience::mouseButton(DFBInputDeviceButtonIdentifier identifier) +{ + switch (identifier){ + case DIBI_LEFT: + return Qt::LeftButton; + case DIBI_MIDDLE: + return Qt::MidButton; + case DIBI_RIGHT: + return Qt::RightButton; + default: + return Qt::NoButton; + } +} + +Qt::MouseButtons QDirectFbConvenience::mouseButtons(DFBInputDeviceButtonMask mask) +{ + Qt::MouseButtons buttons = Qt::NoButton; + + if (mask & DIBM_LEFT) { + buttons |= Qt::LeftButton; + } + if (mask & DIBM_MIDDLE) { + buttons |= Qt::MidButton; + } + if (mask & DIBM_RIGHT) { + buttons |= Qt::RightButton; + } + return buttons; +} + +Qt::KeyboardModifiers QDirectFbConvenience::keyboardModifiers(DFBInputDeviceModifierMask mask) +{ + Qt::KeyboardModifiers modifiers = Qt::NoModifier; + + if (mask & DIMM_SHIFT) { + modifiers |= Qt::ShiftModifier; + } + if (mask & DIMM_ALT) { + modifiers |= Qt::AltModifier; + } + if (mask & DIMM_ALTGR) { + modifiers |= Qt::MetaModifier; + } + if (mask & DIMM_CONTROL) { + modifiers |= Qt::ControlModifier; + } + if (mask & DIMM_META) { + modifiers | Qt::MetaModifier; + } + return modifiers; +} + +QEvent::Type QDirectFbConvenience::eventType(DFBWindowEventType type) +{ + switch(type) { + case DWET_BUTTONDOWN: + return QEvent::MouseButtonPress; + case DWET_BUTTONUP: + return QEvent::MouseButtonRelease; + case DWET_MOTION: + return QEvent::MouseMove; + case DWET_WHEEL: + return QEvent::Wheel; + case DWET_KEYDOWN: + return QEvent::KeyPress; + case DWET_KEYUP: + return QEvent::KeyRelease; + default: + return QEvent::None; + } +} +QDirectFbKeyMap *QDirectFbConvenience::dfbKeymap = 0; +QDirectFbKeyMap *QDirectFbConvenience::keyMap() +{ + if (!dfbKeymap) + dfbKeymap = new QDirectFbKeyMap(); + return dfbKeymap; +} + +QDirectFbKeyMap::QDirectFbKeyMap() +{ + insert(DIKS_BACKSPACE , Qt::Key_Backspace); + insert(DIKS_TAB , Qt::Key_Tab); + insert(DIKS_RETURN , Qt::Key_Return); + insert(DIKS_ESCAPE , Qt::Key_Escape); + insert(DIKS_DELETE , Qt::Key_Delete); + + insert(DIKS_CURSOR_LEFT , Qt::Key_Left); + insert(DIKS_CURSOR_RIGHT , Qt::Key_Right); + insert(DIKS_CURSOR_UP , Qt::Key_Up); + insert(DIKS_CURSOR_DOWN , Qt::Key_Down); + insert(DIKS_INSERT , Qt::Key_Insert); + insert(DIKS_HOME , Qt::Key_Home); + insert(DIKS_END , Qt::Key_End); + insert(DIKS_PAGE_UP , Qt::Key_PageUp); + insert(DIKS_PAGE_DOWN , Qt::Key_PageDown); + insert(DIKS_PRINT , Qt::Key_Print); + insert(DIKS_PAUSE , Qt::Key_Pause); + insert(DIKS_SELECT , Qt::Key_Select); + insert(DIKS_GOTO , Qt::Key_OpenUrl); + insert(DIKS_CLEAR , Qt::Key_Clear); + insert(DIKS_MENU , Qt::Key_Menu); + insert(DIKS_HELP , Qt::Key_Help); + + insert(DIKS_INTERNET , Qt::Key_HomePage); + insert(DIKS_MAIL , Qt::Key_LaunchMail); + insert(DIKS_FAVORITES , Qt::Key_Favorites); + + insert(DIKS_BACK , Qt::Key_Back); + insert(DIKS_FORWARD , Qt::Key_Forward); + insert(DIKS_VOLUME_UP , Qt::Key_VolumeUp); + insert(DIKS_VOLUME_DOWN , Qt::Key_VolumeDown); + insert(DIKS_MUTE , Qt::Key_VolumeMute); + insert(DIKS_PLAYPAUSE , Qt::Key_Pause); + insert(DIKS_PLAY , Qt::Key_MediaPlay); + insert(DIKS_STOP , Qt::Key_MediaStop); + insert(DIKS_RECORD , Qt::Key_MediaRecord); + insert(DIKS_PREVIOUS , Qt::Key_MediaPrevious); + insert(DIKS_NEXT , Qt::Key_MediaNext); + + insert(DIKS_F1 , Qt::Key_F1); + insert(DIKS_F2 , Qt::Key_F2); + insert(DIKS_F3 , Qt::Key_F3); + insert(DIKS_F4 , Qt::Key_F4); + insert(DIKS_F5 , Qt::Key_F5); + insert(DIKS_F6 , Qt::Key_F6); + insert(DIKS_F7 , Qt::Key_F7); + insert(DIKS_F8 , Qt::Key_F8); + insert(DIKS_F9 , Qt::Key_F9); + insert(DIKS_F10 , Qt::Key_F10); + insert(DIKS_F11 , Qt::Key_F11); + insert(DIKS_F12 , Qt::Key_F12); + + insert(DIKS_SHIFT , Qt::Key_Shift); + insert(DIKS_CONTROL , Qt::Key_Control); + insert(DIKS_ALT , Qt::Key_Alt); + insert(DIKS_ALTGR , Qt::Key_AltGr); + + insert(DIKS_META , Qt::Key_Meta); + insert(DIKS_SUPER , Qt::Key_Super_L); // ??? + insert(DIKS_HYPER , Qt::Key_Hyper_L); // ??? + + insert(DIKS_CAPS_LOCK , Qt::Key_CapsLock); + insert(DIKS_NUM_LOCK , Qt::Key_NumLock); + insert(DIKS_SCROLL_LOCK , Qt::Key_ScrollLock); + + insert(DIKS_DEAD_ABOVEDOT , Qt::Key_Dead_Abovedot); + insert(DIKS_DEAD_ABOVERING , Qt::Key_Dead_Abovering); + insert(DIKS_DEAD_ACUTE , Qt::Key_Dead_Acute); + insert(DIKS_DEAD_BREVE , Qt::Key_Dead_Breve); + insert(DIKS_DEAD_CARON , Qt::Key_Dead_Caron); + insert(DIKS_DEAD_CEDILLA , Qt::Key_Dead_Cedilla); + insert(DIKS_DEAD_CIRCUMFLEX , Qt::Key_Dead_Circumflex); + insert(DIKS_DEAD_DIAERESIS , Qt::Key_Dead_Diaeresis); + insert(DIKS_DEAD_DOUBLEACUTE , Qt::Key_Dead_Doubleacute); + insert(DIKS_DEAD_GRAVE , Qt::Key_Dead_Grave); + insert(DIKS_DEAD_IOTA , Qt::Key_Dead_Iota); + insert(DIKS_DEAD_MACRON , Qt::Key_Dead_Macron); + insert(DIKS_DEAD_OGONEK , Qt::Key_Dead_Ogonek); + insert(DIKS_DEAD_SEMIVOICED_SOUND , Qt::Key_Dead_Semivoiced_Sound); + insert(DIKS_DEAD_TILDE , Qt::Key_Dead_Tilde); + insert(DIKS_DEAD_VOICED_SOUND , Qt::Key_Dead_Voiced_Sound); + insert(DIKS_SPACE , Qt::Key_Space); + insert(DIKS_EXCLAMATION_MARK , Qt::Key_Exclam); + insert(DIKS_QUOTATION , Qt::Key_QuoteDbl); + insert(DIKS_NUMBER_SIGN , Qt::Key_NumberSign); + insert(DIKS_DOLLAR_SIGN , Qt::Key_Dollar); + insert(DIKS_PERCENT_SIGN , Qt::Key_Percent); + insert(DIKS_AMPERSAND , Qt::Key_Ampersand); + insert(DIKS_APOSTROPHE , Qt::Key_Apostrophe); + insert(DIKS_PARENTHESIS_LEFT , Qt::Key_ParenLeft); + insert(DIKS_PARENTHESIS_RIGHT , Qt::Key_ParenRight); + insert(DIKS_ASTERISK , Qt::Key_Asterisk); + insert(DIKS_PLUS_SIGN , Qt::Key_Plus); + insert(DIKS_COMMA , Qt::Key_Comma); + insert(DIKS_MINUS_SIGN , Qt::Key_Minus); + insert(DIKS_PERIOD , Qt::Key_Period); + insert(DIKS_SLASH , Qt::Key_Slash); + insert(DIKS_0 , Qt::Key_0); + insert(DIKS_1 , Qt::Key_1); + insert(DIKS_2 , Qt::Key_2); + insert(DIKS_3 , Qt::Key_3); + insert(DIKS_4 , Qt::Key_4); + insert(DIKS_5 , Qt::Key_5); + insert(DIKS_6 , Qt::Key_6); + insert(DIKS_7 , Qt::Key_7); + insert(DIKS_8 , Qt::Key_8); + insert(DIKS_9 , Qt::Key_9); + insert(DIKS_COLON , Qt::Key_Colon); + insert(DIKS_SEMICOLON , Qt::Key_Semicolon); + insert(DIKS_LESS_THAN_SIGN , Qt::Key_Less); + insert(DIKS_EQUALS_SIGN , Qt::Key_Equal); + insert(DIKS_GREATER_THAN_SIGN , Qt::Key_Greater); + insert(DIKS_QUESTION_MARK , Qt::Key_Question); + insert(DIKS_AT , Qt::Key_At); + insert(DIKS_CAPITAL_A , Qt::Key_A); + insert(DIKS_CAPITAL_B , Qt::Key_B); + insert(DIKS_CAPITAL_C , Qt::Key_C); + insert(DIKS_CAPITAL_D , Qt::Key_D); + insert(DIKS_CAPITAL_E , Qt::Key_E); + insert(DIKS_CAPITAL_F , Qt::Key_F); + insert(DIKS_CAPITAL_G , Qt::Key_G); + insert(DIKS_CAPITAL_H , Qt::Key_H); + insert(DIKS_CAPITAL_I , Qt::Key_I); + insert(DIKS_CAPITAL_J , Qt::Key_J); + insert(DIKS_CAPITAL_K , Qt::Key_K); + insert(DIKS_CAPITAL_L , Qt::Key_L); + insert(DIKS_CAPITAL_M , Qt::Key_M); + insert(DIKS_CAPITAL_N , Qt::Key_N); + insert(DIKS_CAPITAL_O , Qt::Key_O); + insert(DIKS_CAPITAL_P , Qt::Key_P); + insert(DIKS_CAPITAL_Q , Qt::Key_Q); + insert(DIKS_CAPITAL_R , Qt::Key_R); + insert(DIKS_CAPITAL_S , Qt::Key_S); + insert(DIKS_CAPITAL_T , Qt::Key_T); + insert(DIKS_CAPITAL_U , Qt::Key_U); + insert(DIKS_CAPITAL_V , Qt::Key_V); + insert(DIKS_CAPITAL_W , Qt::Key_W); + insert(DIKS_CAPITAL_X , Qt::Key_X); + insert(DIKS_CAPITAL_Y , Qt::Key_Y); + insert(DIKS_CAPITAL_Z , Qt::Key_Z); + insert(DIKS_SQUARE_BRACKET_LEFT , Qt::Key_BracketLeft); + insert(DIKS_BACKSLASH , Qt::Key_Backslash); + insert(DIKS_SQUARE_BRACKET_RIGHT , Qt::Key_BracketRight); + insert(DIKS_CIRCUMFLEX_ACCENT , Qt::Key_AsciiCircum); + insert(DIKS_UNDERSCORE , Qt::Key_Underscore); + insert(DIKS_SMALL_A , Qt::Key_A); + insert(DIKS_SMALL_B , Qt::Key_B); + insert(DIKS_SMALL_C , Qt::Key_C); + insert(DIKS_SMALL_D , Qt::Key_D); + insert(DIKS_SMALL_E , Qt::Key_E); + insert(DIKS_SMALL_F , Qt::Key_F); + insert(DIKS_SMALL_G , Qt::Key_G); + insert(DIKS_SMALL_H , Qt::Key_H); + insert(DIKS_SMALL_I , Qt::Key_I); + insert(DIKS_SMALL_J , Qt::Key_J); + insert(DIKS_SMALL_K , Qt::Key_K); + insert(DIKS_SMALL_L , Qt::Key_L); + insert(DIKS_SMALL_M , Qt::Key_M); + insert(DIKS_SMALL_N , Qt::Key_N); + insert(DIKS_SMALL_O , Qt::Key_O); + insert(DIKS_SMALL_P , Qt::Key_P); + insert(DIKS_SMALL_Q , Qt::Key_Q); + insert(DIKS_SMALL_R , Qt::Key_R); + insert(DIKS_SMALL_S , Qt::Key_S); + insert(DIKS_SMALL_T , Qt::Key_T); + insert(DIKS_SMALL_U , Qt::Key_U); + insert(DIKS_SMALL_V , Qt::Key_V); + insert(DIKS_SMALL_W , Qt::Key_W); + insert(DIKS_SMALL_X , Qt::Key_X); + insert(DIKS_SMALL_Y , Qt::Key_Y); + insert(DIKS_SMALL_Z , Qt::Key_Z); + insert(DIKS_CURLY_BRACKET_LEFT , Qt::Key_BraceLeft); + insert(DIKS_VERTICAL_BAR , Qt::Key_Bar); + insert(DIKS_CURLY_BRACKET_RIGHT , Qt::Key_BraceRight); + insert(DIKS_TILDE , Qt::Key_AsciiTilde); +} diff --git a/src/plugins/platforms/directfb/qdirectfbconvenience.h b/src/plugins/platforms/directfb/qdirectfbconvenience.h new file mode 100644 index 0000000..ab5b3de --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbconvenience.h @@ -0,0 +1,43 @@ +#ifndef QDIRECTFBCONVENIENCE_H +#define QDIRECTFBCONVENIENCE_H + +#include +#include +#include +#include + +#include + +class QDirectFbKeyMap: public QHash +{ +public: + QDirectFbKeyMap(); +}; + + +class QDirectFbConvenience +{ +public: + static QImage::Format imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps); + static bool pixelFomatHasAlpha(const DFBSurfacePixelFormat format) { return (1 << 16) & format; } + static int colorDepthForSurface(const DFBSurfacePixelFormat format); + + //This is set by the graphicssystem constructor + static IDirectFB *dfbInterface(); + static IDirectFBDisplayLayer *dfbDisplayLayer(int display = DLID_PRIMARY); + + static IDirectFBSurface *dfbSurfaceForPixmapData(QPixmapData *); + + static Qt::MouseButton mouseButton(DFBInputDeviceButtonIdentifier identifier); + static Qt::MouseButtons mouseButtons(DFBInputDeviceButtonMask mask); + static Qt::KeyboardModifiers keyboardModifiers(DFBInputDeviceModifierMask mask); + static QEvent::Type eventType(DFBWindowEventType type); + + static QDirectFbKeyMap *keyMap(); + +private: + static QDirectFbKeyMap *dfbKeymap; + friend class QDirectFbIntegration; +}; + +#endif // QDIRECTFBCONVENIENCE_H diff --git a/src/plugins/platforms/directfb/qdirectfbcursor.cpp b/src/plugins/platforms/directfb/qdirectfbcursor.cpp new file mode 100644 index 0000000..bb7088f --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbcursor.cpp @@ -0,0 +1,42 @@ +#include "qdirectfbcursor.h" +#include "qblitter_directfb.h" +#include "qplatformintegration_directfb.h" +#include "qdirectfbconvenience.h" + +#include + +QDirectFBCursor::QDirectFBCursor(QPlatformScreen* screen) : + QGraphicsSystemCursor(screen), surface(0) +{ + QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY, &m_layer); + image = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); +} + +void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) +{ + Q_UNUSED(widget); + int xSpot; + int ySpot; + QPixmap map; + + if (cursor->shape() != Qt::BitmapCursor) { + image->set(cursor->shape()); + xSpot = image->hotspot().x(); + ySpot = image->hotspot().y(); + QImage *i = image->image(); + map = QPixmap::fromImage(*i); + } else { + QPoint point = cursor->hotSpot(); + xSpot = point.x(); + ySpot = point.y(); + map = cursor->pixmap(); + } + + IDirectFBSurface *surface = QDirectFbConvenience::dfbSurfaceForPixmapData(map.pixmapData()); + + if (m_layer->SetCooperativeLevel(m_layer, DLSCL_ADMINISTRATIVE) != DFB_OK) { + return; + } + m_layer->SetCursorShape( m_layer, surface, xSpot, ySpot); + m_layer->SetCooperativeLevel(m_layer, DLSCL_SHARED); +} diff --git a/src/plugins/platforms/directfb/qdirectfbcursor.h b/src/plugins/platforms/directfb/qdirectfbcursor.h new file mode 100644 index 0000000..1566e7c --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbcursor.h @@ -0,0 +1,22 @@ +#ifndef QDIRECTFBCURSOR_H +#define QDIRECTFBCURSOR_H + +#include +#include +class QDirectFbScreen; +class QDirectFbBlitter; + +class QDirectFBCursor : public QGraphicsSystemCursor +{ +public: + QDirectFBCursor(QPlatformScreen *screem); + void changeCursor(QCursor * cursor, QWidget * widget); + +private: + IDirectFBDisplayLayer * m_layer; + IDirectFBSurface * surface; + QGraphicsSystemCursorImage * image; + QDirectFbBlitter *blitter; +}; + +#endif // QDIRECTFBCURSOR_H diff --git a/src/plugins/platforms/directfb/qdirectfbinput.cpp b/src/plugins/platforms/directfb/qdirectfbinput.cpp new file mode 100644 index 0000000..74a38a4 --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbinput.cpp @@ -0,0 +1,205 @@ +#include "qdirectfbinput.h" +#include "qdirectfbconvenience.h" + +#include +#include +#include +#include +#include +#include + +#include + +InputSocketWaiter::InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent) + : QThread(parent), m_eventBuffer(eventBuffer),m_shouldStop(false) +{ + this->start(); +} + +InputSocketWaiter::~InputSocketWaiter() +{ + m_shouldStop = true; + m_eventBuffer->WakeUp(m_eventBuffer); + m_cleanupMutex.lock(); +} + +void InputSocketWaiter::continueWaitingForEvents() +{ + m_finishedProcessingEvents.wakeAll(); +} + +void InputSocketWaiter::run() +{ + m_cleanupMutex.lock(); + while (1) { + m_eventBuffer->WaitForEvent(m_eventBuffer); + if (m_shouldStop) + break; + emit newEvent(); + QMutex waitForProcessingMutex; + waitForProcessingMutex.lock(); + m_finishedProcessingEvents.wait(&waitForProcessingMutex); + } + m_cleanupMutex.unlock(); +} + +QDirectFbInput *QDirectFbInput::instance() +{ + static QDirectFbInput *input = 0; + if (!input) { + input = new QDirectFbInput(); + } + return input; +} + +QDirectFbInput::QDirectFbInput() + : QObject() +{ + dfbInterface = QDirectFbConvenience::dfbInterface(); + + DFBResult ok = dfbInterface->CreateEventBuffer(dfbInterface,&eventBuffer); + if (ok != DFB_OK) + DirectFBError("Failed to initialise eventbuffer", ok); + + dfbInterface->GetDisplayLayer(dfbInterface,DLID_PRIMARY, &dfbDisplayLayer); + + m_inputHandler = new InputSocketWaiter(eventBuffer,this); + connect(m_inputHandler,SIGNAL(newEvent()),this,SLOT(handleEvents())); + + connect(QApplication::instance(),SIGNAL(aboutToQuit()),SLOT(applicationEnd())); +} + +void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) +{ + tlwMap.insert(id,tlw); + IDirectFBWindow *window; + dfbDisplayLayer->GetWindow(dfbDisplayLayer,id,&window); + + window->AttachEventBuffer(window,eventBuffer); +} + +void QDirectFbInput::removeWindow(QWidget *tlw) +{ + DFBWindowID id = tlwMap.key(tlw,0); + if (id) { + IDirectFBWindow *window; + dfbDisplayLayer->GetWindow(dfbDisplayLayer,id, &window); + + window->DetachEventBuffer(window,eventBuffer); + tlwMap.remove(id); + } +} + +void QDirectFbInput::handleEvents() +{ + DFBResult hasEvent = eventBuffer->HasEvent(eventBuffer); + while(hasEvent == DFB_OK){ + DFBEvent event; + DFBResult ok = eventBuffer->GetEvent(eventBuffer,&event); + if (ok != DFB_OK) + DirectFBError("Failed to get event",ok); + if (event.clazz == DFEC_WINDOW) { + switch (event.window.type) { + case DWET_BUTTONDOWN: + case DWET_BUTTONUP: + case DWET_MOTION: + handleMouseEvents(event); + break; + case DWET_WHEEL: + handleWheelEvent(event); + break; + case DWET_KEYDOWN: + case DWET_KEYUP: + handleKeyEvents(event); + break; + case DWET_ENTER: + case DWET_LEAVE: + handleEnterLeaveEvents(event); + default: + break; + } + + } + + hasEvent = eventBuffer->HasEvent(eventBuffer); + } + m_inputHandler->continueWaitingForEvents(); +} + +void QDirectFbInput::handleMouseEvents(const DFBEvent &event) +{ + QPoint p(event.window.x, event.window.y); + QPoint globalPos = globalPoint(event); + Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); + + IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); + IDirectFBWindow *window; + layer->GetWindow(layer,event.window.window_id,&window); + + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + + if (event.window.type == DWET_BUTTONDOWN) { + window->GrabPointer(window); + } else if (event.window.type == DWET_BUTTONUP) { + window->UngrabPointer(window); + } + QWidget *tlw = tlwMap.value(event.window.window_id); + QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons); +} + +void QDirectFbInput::applicationEnd() +{ + delete m_inputHandler; + m_inputHandler = 0; +} + +void QDirectFbInput::handleWheelEvent(const DFBEvent &event) +{ + QPoint p(event.window.cx, event.window.cy); + QPoint globalPos = globalPoint(event); + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + QWidget *tlw = tlwMap.value(event.window.window_id); + QWindowSystemInterface::handleWheelEvent(tlw, timestamp, p, globalPos, + event.window.step*120, + Qt::Vertical); +} + +void QDirectFbInput::handleKeyEvents(const DFBEvent &event) +{ + QEvent::Type type = QDirectFbConvenience::eventType(event.window.type); + Qt::Key key = QDirectFbConvenience::keyMap()->value(event.window.key_symbol); + Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers); + + long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); + + QChar character; + if (DFB_KEY_TYPE(event.window.key_symbol) == DIKT_UNICODE) + character = QChar(event.window.key_symbol); + QWidget *tlw = tlwMap.value(event.window.window_id); + QWindowSystemInterface::handleKeyEvent(tlw, timestamp, type, key, modifiers, character); +} + +void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) +{ + QWidget *tlw = tlwMap.value(event.window.window_id); + switch (event.window.type) { + case DWET_ENTER: + QWindowSystemInterface::handleEnterEvent(tlw); + break; + case DWET_LEAVE: + QWindowSystemInterface::handleLeaveEvent(tlw); + break; + default: + break; + } +} + +inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const +{ + IDirectFBWindow *window; + dfbDisplayLayer->GetWindow(dfbDisplayLayer,event.window.window_id,&window); + int x,y; + window->GetPosition(window,&x,&y); + return QPoint(event.window.cx +x, event.window.cy + y); +} + diff --git a/src/plugins/platforms/directfb/qdirectfbinput.h b/src/plugins/platforms/directfb/qdirectfbinput.h new file mode 100644 index 0000000..31aa082 --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbinput.h @@ -0,0 +1,63 @@ +#ifndef QDIRECTFBINPUT_H +#define QDIRECTFBINPUT_H + +#include +#include +#include +#include +#include +#include +#include + +#include + +class InputSocketWaiter : public QThread +{ + Q_OBJECT +public: + InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent); + virtual ~InputSocketWaiter(); + void continueWaitingForEvents(); +protected: + void run(); +signals: + void newEvent(); +private: + IDirectFBEventBuffer *m_eventBuffer; + bool m_shouldStop; + QMutex m_cleanupMutex; + QWaitCondition m_finishedProcessingEvents; +}; + +class QDirectFbInput : public QObject +{ + Q_OBJECT +public: + static QDirectFbInput *instance(); + void addWindow(DFBWindowID id, QWidget *tlw); + void removeWindow(QWidget *tlw); + +public slots: + void handleEvents(); + void applicationEnd(); + +private: + QDirectFbInput(); + + void handleMouseEvents(const DFBEvent &event); + void handleWheelEvent(const DFBEvent &event); + void handleKeyEvents(const DFBEvent &event); + void handleEnterLeaveEvents(const DFBEvent &event); + IDirectFB *dfbInterface; + IDirectFBDisplayLayer *dfbDisplayLayer; + IDirectFBEventBuffer *eventBuffer; + + QHashtlwMap; + + inline QPoint globalPoint(const DFBEvent &event) const; + + InputSocketWaiter *m_inputHandler; + +}; + +#endif // QDIRECTFBINPUT_H diff --git a/src/plugins/platforms/directfb/qplatformintegration_directfb.cpp b/src/plugins/platforms/directfb/qplatformintegration_directfb.cpp new file mode 100644 index 0000000..c70bb64 --- /dev/null +++ b/src/plugins/platforms/directfb/qplatformintegration_directfb.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qplatformintegration_directfb.h" +#include "qwindowsurface_directfb.h" +#include "qblitter_directfb.h" +#include "qdirectfbconvenience.h" +#include "qdirectfbcursor.h" + +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QDirectFbScreen::QDirectFbScreen(int display) + :QPlatformScreen() +{ + m_layer = QDirectFbConvenience::dfbDisplayLayer(display); + m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); + + DFBDisplayLayerConfig config; + m_layer->GetConfiguration(m_layer, &config); + + m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps); + m_geometry = QRect(0,0,config.width,config.height); + const int dpi = 72; + const qreal inch = 25.4; + m_depth = 32; + m_physicalSize = QSize(qRound(config.width * inch / dpi), qRound(config.height *inch / dpi)); + + cursor = new QDirectFBCursor(this); +} + +QDirectFbScreen::~QDirectFbScreen() +{ +} + +QDirectFbIntegration::QDirectFbIntegration() +{ + const QStringList args = QCoreApplication::arguments(); + int argc = args.size(); + char **argv = new char*[argc]; + + for (int i = 0; i < argc; ++i) + argv[i] = qstrdup(args.at(i).toLocal8Bit().constData()); + + DFBResult result = DirectFBInit(&argc, &argv); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen: error initializing DirectFB", + result); + } + delete[] argv; + + QDirectFbScreen *primaryScreen = new QDirectFbScreen(0); + mScreens.append(primaryScreen); +} + +QPixmapData *QDirectFbIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + if (type == QPixmapData::BitmapType) + return new QRasterPixmapData(type); + else + return new QBlittablePixmapData(type); +} + +QWindowSurface *QDirectFbIntegration::createWindowSurface(QWidget *widget) const +{ + return new QDirectFbWindowSurface (widget); +} + +QBlittable *QDirectFbIntegration::createBlittable(const QSize &size) const +{ + return new QDirectFbBlitter(size); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/directfb/qplatformintegration_directfb.h b/src/plugins/platforms/directfb/qplatformintegration_directfb.h new file mode 100644 index 0000000..f74a81d --- /dev/null +++ b/src/plugins/platforms/directfb/qplatformintegration_directfb.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMINTEGRATION_DIRECTFB_H +#define QPLATFORMINTEGRATION_DIRECTFB_H + +#include "qdirectfbinput.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QDirectFBCursor; + +class QDirectFbScreen : public QPlatformScreen +{ +public: + QDirectFbScreen(int display); + ~QDirectFbScreen(); + + 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; } + +public: + QRect m_geometry; + int m_depth; + QImage::Format m_format; + QSize m_physicalSize; + + IDirectFBDisplayLayer *m_layer; + +private: + QDirectFBCursor * cursor; + +}; + +class QDirectFbIntegration : public QPlatformIntegration +{ +public: + QDirectFbIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + QBlittable *createBlittable(const QSize &size) const; + + QList screens() const { return mScreens; } + + + +private: + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/directfb/qwindowsurface_directfb.cpp b/src/plugins/platforms/directfb/qwindowsurface_directfb.cpp new file mode 100644 index 0000000..afe34b7 --- /dev/null +++ b/src/plugins/platforms/directfb/qwindowsurface_directfb.cpp @@ -0,0 +1,231 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsurface_directfb.h" +#include "qplatformintegration_directfb.h" +#include "qblitter_directfb.h" +#include "qdirectfbconvenience.h" +#include + +#include + +QT_BEGIN_NAMESPACE + +QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window) + : QWindowSurface(window), m_pixmap(0), m_pmdata(0), + m_dfbWindow(0), m_dfbSurface(0) +{ + window->setWindowSurface(this); + + IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); + DFBDisplayLayerConfig layerConfig; + layer->GetConfiguration(layer,&layerConfig); + + DFBWindowDescription description; + memset(&description,0,sizeof(DFBWindowDescription)); + description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS +#if DIRECTFB_MINOR_VERSION >= 1 + |DWDESC_OPTIONS +#endif + |DWDESC_CAPS); + description.width = window->rect().width(); + description.height = window->rect().height(); + description.posx = window->rect().x(); + description.posy = window->rect().y(); + + if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED) + description.surface_caps = DSCAPS_PREMULTIPLIED; + description.pixelformat = layerConfig.pixelformat; + +#if DIRECTFB_MINOR_VERSION >= 1 + description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); +#endif + description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL); + description.surface_caps = DSCAPS_PREMULTIPLIED; + + DFBResult result = layer->CreateWindow(layer,&description,&m_dfbWindow); + if (result != DFB_OK) { + DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); + } + + DFBWindowID id; + m_dfbWindow->GetID(m_dfbWindow, &id); + QDirectFbInput::instance()->addWindow(id,window); + + m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); + + QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect().size(), m_dfbSurface); + m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); + m_pmdata->setBlittable(blitter); + m_pixmap = new QPixmap(m_pmdata); +} + +QDirectFbWindowSurface::~QDirectFbWindowSurface() +{ + QDirectFbInput::instance()->removeWindow(this->window()); + m_dfbWindow->Destroy(m_dfbWindow); +} + +QPaintDevice *QDirectFbWindowSurface::paintDevice() +{ + return m_pixmap; +} + +void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + m_pmdata->blittable()->unlock(); + + const quint8 windowOpacity = quint8(widget->windowOpacity() * 0xff); + m_dfbWindow->SetOpacity(m_dfbWindow,windowOpacity); + + QVector rects = region.rects(); + for (int i = 0 ; i < rects.size(); i++) { + const QRect rect = rects.at(i); + DFBRegion dfbReg = { rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()}; + m_dfbSurface->Flip(m_dfbSurface, &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC)); + } +} + +void QDirectFbWindowSurface::setGeometry(const QRect &rect) +{ + m_pmdata->blittable()->unlock(); + + QWindowSurface::setGeometry(rect); + m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), + rect.width(), rect.height()); + + //Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable + m_dfbSurface->AddRef(m_dfbSurface); + QDirectFbBlitter *blitter = new QDirectFbBlitter(rect.size(),m_dfbSurface); + m_pmdata->setBlittable(blitter); +} + +static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) +{ + const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; + surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy); + const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy }; + surface->Flip(surface, ®ion, DFBSurfaceFlipFlags(DSFLIP_BLIT)); +} + +bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + m_pmdata->blittable()->unlock(); + + if (!m_dfbSurface || area.isEmpty()) + return false; + m_dfbSurface->SetBlittingFlags(m_dfbSurface, DSBLIT_NOFX); + if (area.rectCount() == 1) { + scrollSurface(m_dfbSurface, area.boundingRect(), dx, dy); + } else { + const QVector rects = area.rects(); + const int n = rects.size(); + for (int i=0; iblittable()->unlock(); + + if (visible) { + int x = this->geometry().x(); + int y = this->geometry().y(); + m_dfbWindow->MoveTo(m_dfbWindow,x,y); + } else { + IDirectFBDisplayLayer *displayLayer; + QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY,&displayLayer); + + DFBDisplayLayerConfig config; + displayLayer->GetConfiguration(displayLayer,&config); + m_dfbWindow->MoveTo(m_dfbWindow,config.width+1,config.height + 1); + } +} + +Qt::WindowFlags QDirectFbWindowSurface::setWindowFlags(Qt::WindowFlags flags) +{ + switch (flags & Qt::WindowType_Mask) { + case Qt::ToolTip: { + DFBWindowOptions options; + m_dfbWindow->GetOptions(m_dfbWindow,&options); + options = DFBWindowOptions(options | DWOP_GHOST); + m_dfbWindow->SetOptions(m_dfbWindow,options); + break; } + default: + break; + } + + m_dfbWindow->SetStackingClass(m_dfbWindow, flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE); + return flags; +} + +void QDirectFbWindowSurface::raise() +{ + m_dfbWindow->RaiseToTop(m_dfbWindow); +} + +void QDirectFbWindowSurface::lower() +{ + m_dfbWindow->LowerToBottom(m_dfbWindow); +} + +WId QDirectFbWindowSurface::winId() const +{ + DFBWindowID id; + m_dfbWindow->GetID(m_dfbWindow, &id); + return WId(id); +} + + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/directfb/qwindowsurface_directfb.h b/src/plugins/platforms/directfb/qwindowsurface_directfb.h new file mode 100644 index 0000000..2f31513 --- /dev/null +++ b/src/plugins/platforms/directfb/qwindowsurface_directfb.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_DIRECTFB_H +#define QWINDOWSURFACE_DIRECTFB_H + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class QDirectFbGraphicsSystemScreen; + +class QDirectFbWindowSurface : public QWindowSurface +{ +public: + QDirectFbWindowSurface(QWidget *window); + ~QDirectFbWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + + void setVisible(bool visible); + Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); + + void raise(); + void lower(); + + WId winId() const; + +private: + void lockSurfaceToImage(); + + QPixmap *m_pixmap; + QBlittablePixmapData *m_pmdata; + + IDirectFBWindow *m_dfbWindow; + IDirectFBSurface *m_dfbSurface; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/minimaldfb/main.cpp b/src/plugins/platforms/minimaldfb/main.cpp deleted file mode 100644 index fe9407c..0000000 --- a/src/plugins/platforms/minimaldfb/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "qgraphicssystem_minimaldfb.h" - -QT_BEGIN_NAMESPACE - -class QDirectFbGraphicsSystemPlugin : public QGraphicsSystemPlugin -{ -public: - QStringList keys() const; - QGraphicsSystem *create(const QString&); -}; - -QStringList QDirectFbGraphicsSystemPlugin::keys() const -{ - QStringList list; - list << "MinimalDfb"; - return list; -} - -QGraphicsSystem* QDirectFbGraphicsSystemPlugin::create(const QString& system) -{ - if (system.toLower() == "minimaldfb") - return new QDirectFbGraphicsSystem; - - return 0; -} - -Q_EXPORT_PLUGIN2(directfb, QDirectFbGraphicsSystemPlugin) - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimaldfb/minimaldfb.pro b/src/plugins/platforms/minimaldfb/minimaldfb.pro deleted file mode 100644 index b6c2ea8..0000000 --- a/src/plugins/platforms/minimaldfb/minimaldfb.pro +++ /dev/null @@ -1,29 +0,0 @@ -TARGET = qminimaldfb -include(../../qpluginbase.pri) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - -isEmpty(DIRECTFB_LIBS) { - DIRECTFB_LIBS = -ldirectfb -lfusion -ldirect -lpthread -} -isEmpty(DIRECTFB_INCLUDEPATH) { - DIRECTFB_INCLUDEPATH = /usr/include/directfb -} - -INCLUDEPATH += $$DIRECTFB_INCLUDEPATH -LIBS += $$DIRECTFB_LIBS - -SOURCES = main.cpp \ - qgraphicssystem_minimaldfb.cpp \ - qwindowsurface_minimaldfb.cpp \ - qblitter_directfb.cpp \ - qdirectfbconvenience.cpp \ - qdirectfbinput.cpp \ - qdirectfbcursor.cpp -HEADERS = qgraphicssystem_minimaldfb.h \ - qwindowsurface_minimaldfb.h \ - qblitter_directfb.h \ - qdirectfbconvenience.h \ - qdirectfbinput.h \ - qdirectfbcursor.h -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -INSTALLS += target diff --git a/src/plugins/platforms/minimaldfb/qblitter_directfb.cpp b/src/plugins/platforms/minimaldfb/qblitter_directfb.cpp deleted file mode 100644 index 070c563..0000000 --- a/src/plugins/platforms/minimaldfb/qblitter_directfb.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "qblitter_directfb.h" -#include "qgraphicssystem_minimaldfb.h" -#include "qdirectfbconvenience.h" - -#include - -#include - -#include - -QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, IDirectFBSurface *surface) - : QBlittable(rect, QBlittable::Capabilities(QBlittable::SolidRectCapability - |QBlittable::SourcePixmapCapability - |QBlittable::SourceOverPixmapCapability - |QBlittable::SourceOverScaledPixmapCapability)) -{ - if (surface) { - m_surface = surface; - } else { - DFBSurfaceDescription surfaceDesc; - memset(&surfaceDesc,0,sizeof(DFBSurfaceDescription)); - surfaceDesc.width = rect.width(); - surfaceDesc.height = rect.height(); - surfaceDesc.caps = DSCAPS_PREMULTIPLIED; - surfaceDesc.pixelformat = DSPF_ARGB; - surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT); - - IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); - dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); - m_surface->Clear(m_surface,0,0,0,0); - } -} - -QDirectFbBlitter::~QDirectFbBlitter() -{ - unlock(); - m_surface->Release(m_surface); -} - -void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color) -{ - m_surface->SetColor(m_surface, color.red(), color.green(), color.blue(), color.alpha()); -// When the blitter api supports non opaque blits, also remember to change -// qpixmap_blitter.cpp::fill -// DFBSurfaceDrawingFlags drawingFlags = color.alpha() ? DSDRAW_BLEND : DSDRAW_NOFX; -// m_surface->SetDrawingFlags(m_surface, drawingFlags); - m_surface->SetDrawingFlags(m_surface, DSDRAW_NOFX); - m_surface->FillRectangle(m_surface, rect.x(), rect.y(), - rect.width(), rect.height()); -} - -void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &srcRect) -{ - QPixmapData *data = pixmap.pixmapData(); - Q_ASSERT(data->width() && data->height()); - Q_ASSERT(data->classId() == QPixmapData::BlitterClass); - QBlittablePixmapData *blitPm = static_cast(data); - QDirectFbBlitter *dfbBlitter = static_cast(blitPm->blittable()); - dfbBlitter->unlock(); - - IDirectFBSurface *s = dfbBlitter->m_surface; - - quint32 blittingFlags = pixmap.hasAlpha()? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; - - s->SetBlittingFlags(s, DFBSurfaceBlittingFlags(blittingFlags)); - m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags)); - m_surface->SetPorterDuff(m_surface,DSPD_SRC_OVER); - m_surface->SetDstBlendFunction(m_surface,DSBF_INVSRCALPHA); - - const DFBRectangle sRect = { srcRect.x(), srcRect.y(), rect.width(), rect.height() }; - - DFBResult result; - if (rect.width() == srcRect.width() && rect.height() == srcRect.height()) - result = m_surface->Blit(m_surface, s, &sRect, rect.x(), rect.y()); - else { - const DFBRectangle dRect = { rect.x(), rect.y(), rect.width(), rect.height() }; - result = m_surface->StretchBlit(m_surface, s, &sRect, &dRect); - } - if (result != DFB_OK) - DirectFBError("QDirectFBBlitter::drawPixmap()", result); -} - -QImage *QDirectFbBlitter::doLock() -{ - Q_ASSERT(m_surface); - Q_ASSERT(size().isValid()); - - void *mem; - int bpl; - const DFBResult result = m_surface->Lock(m_surface, DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast(&mem), &bpl); - if (result == DFB_OK) { - DFBSurfacePixelFormat dfbFormat; - DFBSurfaceCapabilities dfbCaps; - m_surface->GetPixelFormat(m_surface,&dfbFormat); - m_surface->GetCapabilities(m_surface,&dfbCaps); - QImage::Format format = QDirectFbConvenience::imageFormatFromSurfaceFormat(dfbFormat, dfbCaps); - int w, h; - m_surface->GetSize(m_surface,&w,&h); - m_image = QImage(static_cast(mem),w,h,bpl,format); - } else { - DirectFBError("Failed to lock image", result); - } - - return &m_image; -} - -void QDirectFbBlitter::doUnlock() -{ - m_surface->Unlock(m_surface); -} diff --git a/src/plugins/platforms/minimaldfb/qblitter_directfb.h b/src/plugins/platforms/minimaldfb/qblitter_directfb.h deleted file mode 100644 index 85a303a..0000000 --- a/src/plugins/platforms/minimaldfb/qblitter_directfb.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef QDIRECTFBBLITTER_H -#define QDIRECTFBBLITTER_H - -#include "qdirectfbconvenience.h" - -#include - -#include - -class QDirectFbBlitter : public QBlittable -{ -public: - QDirectFbBlitter(const QSize &size, IDirectFBSurface *surface = 0); - virtual ~QDirectFbBlitter(); - - virtual void fillRect(const QRectF &rect, const QColor &color); - virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect); - -protected: - virtual QImage *doLock(); - virtual void doUnlock(); - - IDirectFBSurface *m_surface; - QImage m_image; - - friend class QDirectFbConvenience; -}; - -#endif // QDIRECTFBBLITTER_H diff --git a/src/plugins/platforms/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/platforms/minimaldfb/qdirectfbconvenience.cpp deleted file mode 100644 index 8594c09..0000000 --- a/src/plugins/platforms/minimaldfb/qdirectfbconvenience.cpp +++ /dev/null @@ -1,335 +0,0 @@ -#include "qdirectfbconvenience.h" -#include "qblitter_directfb.h" - -#include - -IDirectFB *QDirectFbConvenience::dfbInterface() -{ - static IDirectFB *dfb = 0; - if (!dfb) { - DFBResult result = DirectFBCreate(&dfb); - if (result != DFB_OK) { - DirectFBError("QDirectFBConvenience: error creating DirectFB interface",result); - return 0; - } - } - return dfb; -} - -IDirectFBDisplayLayer *QDirectFbConvenience::dfbDisplayLayer(int display) -{ - IDirectFBDisplayLayer *layer; - DFBResult result = QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),display,&layer); - if (result != DFB_OK) { - DirectFBError("QDirectFbConvenience: " - "Unable to get primary display layer!", result); - } - return layer; -} - -QImage::Format QDirectFbConvenience::imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps) -{ - switch (format) { - case DSPF_LUT8: - return QImage::Format_Indexed8; - case DSPF_RGB24: - return QImage::Format_RGB888; - case DSPF_ARGB4444: - return QImage::Format_ARGB4444_Premultiplied; - case DSPF_RGB444: - return QImage::Format_RGB444; - case DSPF_RGB555: - case DSPF_ARGB1555: - return QImage::Format_RGB555; - case DSPF_RGB16: - return QImage::Format_RGB16; - case DSPF_ARGB6666: - return QImage::Format_ARGB6666_Premultiplied; - case DSPF_RGB18: - return QImage::Format_RGB666; - case DSPF_RGB32: - return QImage::Format_RGB32; - case DSPF_ARGB: { - if (caps & DSCAPS_PREMULTIPLIED) - return QImage::Format_ARGB32_Premultiplied; - else return QImage::Format_ARGB32; } - default: - break; - } - return QImage::Format_Invalid; - -} - -int QDirectFbConvenience::colorDepthForSurface(const DFBSurfacePixelFormat format) -{ - return ((0x1f << 7) & format) >> 7; -} - -IDirectFBSurface *QDirectFbConvenience::dfbSurfaceForPixmapData(QPixmapData *pixmapData) -{ - QBlittablePixmapData *blittablePmData = static_cast(pixmapData); - if (blittablePmData) { - QBlittable *blittable = blittablePmData->blittable(); - QDirectFbBlitter *dfbBlitter = static_cast(blittable); - return dfbBlitter->m_surface; - } - return 0; -} - -Qt::MouseButton QDirectFbConvenience::mouseButton(DFBInputDeviceButtonIdentifier identifier) -{ - switch (identifier){ - case DIBI_LEFT: - return Qt::LeftButton; - case DIBI_MIDDLE: - return Qt::MidButton; - case DIBI_RIGHT: - return Qt::RightButton; - default: - return Qt::NoButton; - } -} - -Qt::MouseButtons QDirectFbConvenience::mouseButtons(DFBInputDeviceButtonMask mask) -{ - Qt::MouseButtons buttons = Qt::NoButton; - - if (mask & DIBM_LEFT) { - buttons |= Qt::LeftButton; - } - if (mask & DIBM_MIDDLE) { - buttons |= Qt::MidButton; - } - if (mask & DIBM_RIGHT) { - buttons |= Qt::RightButton; - } - return buttons; -} - -Qt::KeyboardModifiers QDirectFbConvenience::keyboardModifiers(DFBInputDeviceModifierMask mask) -{ - Qt::KeyboardModifiers modifiers = Qt::NoModifier; - - if (mask & DIMM_SHIFT) { - modifiers |= Qt::ShiftModifier; - } - if (mask & DIMM_ALT) { - modifiers |= Qt::AltModifier; - } - if (mask & DIMM_ALTGR) { - modifiers |= Qt::MetaModifier; - } - if (mask & DIMM_CONTROL) { - modifiers |= Qt::ControlModifier; - } - if (mask & DIMM_META) { - modifiers | Qt::MetaModifier; - } - return modifiers; -} - -QEvent::Type QDirectFbConvenience::eventType(DFBWindowEventType type) -{ - switch(type) { - case DWET_BUTTONDOWN: - return QEvent::MouseButtonPress; - case DWET_BUTTONUP: - return QEvent::MouseButtonRelease; - case DWET_MOTION: - return QEvent::MouseMove; - case DWET_WHEEL: - return QEvent::Wheel; - case DWET_KEYDOWN: - return QEvent::KeyPress; - case DWET_KEYUP: - return QEvent::KeyRelease; - default: - return QEvent::None; - } -} -QDirectFbKeyMap *QDirectFbConvenience::dfbKeymap = 0; -QDirectFbKeyMap *QDirectFbConvenience::keyMap() -{ - if (!dfbKeymap) - dfbKeymap = new QDirectFbKeyMap(); - return dfbKeymap; -} - -QDirectFbKeyMap::QDirectFbKeyMap() -{ - insert(DIKS_BACKSPACE , Qt::Key_Backspace); - insert(DIKS_TAB , Qt::Key_Tab); - insert(DIKS_RETURN , Qt::Key_Return); - insert(DIKS_ESCAPE , Qt::Key_Escape); - insert(DIKS_DELETE , Qt::Key_Delete); - - insert(DIKS_CURSOR_LEFT , Qt::Key_Left); - insert(DIKS_CURSOR_RIGHT , Qt::Key_Right); - insert(DIKS_CURSOR_UP , Qt::Key_Up); - insert(DIKS_CURSOR_DOWN , Qt::Key_Down); - insert(DIKS_INSERT , Qt::Key_Insert); - insert(DIKS_HOME , Qt::Key_Home); - insert(DIKS_END , Qt::Key_End); - insert(DIKS_PAGE_UP , Qt::Key_PageUp); - insert(DIKS_PAGE_DOWN , Qt::Key_PageDown); - insert(DIKS_PRINT , Qt::Key_Print); - insert(DIKS_PAUSE , Qt::Key_Pause); - insert(DIKS_SELECT , Qt::Key_Select); - insert(DIKS_GOTO , Qt::Key_OpenUrl); - insert(DIKS_CLEAR , Qt::Key_Clear); - insert(DIKS_MENU , Qt::Key_Menu); - insert(DIKS_HELP , Qt::Key_Help); - - insert(DIKS_INTERNET , Qt::Key_HomePage); - insert(DIKS_MAIL , Qt::Key_LaunchMail); - insert(DIKS_FAVORITES , Qt::Key_Favorites); - - insert(DIKS_BACK , Qt::Key_Back); - insert(DIKS_FORWARD , Qt::Key_Forward); - insert(DIKS_VOLUME_UP , Qt::Key_VolumeUp); - insert(DIKS_VOLUME_DOWN , Qt::Key_VolumeDown); - insert(DIKS_MUTE , Qt::Key_VolumeMute); - insert(DIKS_PLAYPAUSE , Qt::Key_Pause); - insert(DIKS_PLAY , Qt::Key_MediaPlay); - insert(DIKS_STOP , Qt::Key_MediaStop); - insert(DIKS_RECORD , Qt::Key_MediaRecord); - insert(DIKS_PREVIOUS , Qt::Key_MediaPrevious); - insert(DIKS_NEXT , Qt::Key_MediaNext); - - insert(DIKS_F1 , Qt::Key_F1); - insert(DIKS_F2 , Qt::Key_F2); - insert(DIKS_F3 , Qt::Key_F3); - insert(DIKS_F4 , Qt::Key_F4); - insert(DIKS_F5 , Qt::Key_F5); - insert(DIKS_F6 , Qt::Key_F6); - insert(DIKS_F7 , Qt::Key_F7); - insert(DIKS_F8 , Qt::Key_F8); - insert(DIKS_F9 , Qt::Key_F9); - insert(DIKS_F10 , Qt::Key_F10); - insert(DIKS_F11 , Qt::Key_F11); - insert(DIKS_F12 , Qt::Key_F12); - - insert(DIKS_SHIFT , Qt::Key_Shift); - insert(DIKS_CONTROL , Qt::Key_Control); - insert(DIKS_ALT , Qt::Key_Alt); - insert(DIKS_ALTGR , Qt::Key_AltGr); - - insert(DIKS_META , Qt::Key_Meta); - insert(DIKS_SUPER , Qt::Key_Super_L); // ??? - insert(DIKS_HYPER , Qt::Key_Hyper_L); // ??? - - insert(DIKS_CAPS_LOCK , Qt::Key_CapsLock); - insert(DIKS_NUM_LOCK , Qt::Key_NumLock); - insert(DIKS_SCROLL_LOCK , Qt::Key_ScrollLock); - - insert(DIKS_DEAD_ABOVEDOT , Qt::Key_Dead_Abovedot); - insert(DIKS_DEAD_ABOVERING , Qt::Key_Dead_Abovering); - insert(DIKS_DEAD_ACUTE , Qt::Key_Dead_Acute); - insert(DIKS_DEAD_BREVE , Qt::Key_Dead_Breve); - insert(DIKS_DEAD_CARON , Qt::Key_Dead_Caron); - insert(DIKS_DEAD_CEDILLA , Qt::Key_Dead_Cedilla); - insert(DIKS_DEAD_CIRCUMFLEX , Qt::Key_Dead_Circumflex); - insert(DIKS_DEAD_DIAERESIS , Qt::Key_Dead_Diaeresis); - insert(DIKS_DEAD_DOUBLEACUTE , Qt::Key_Dead_Doubleacute); - insert(DIKS_DEAD_GRAVE , Qt::Key_Dead_Grave); - insert(DIKS_DEAD_IOTA , Qt::Key_Dead_Iota); - insert(DIKS_DEAD_MACRON , Qt::Key_Dead_Macron); - insert(DIKS_DEAD_OGONEK , Qt::Key_Dead_Ogonek); - insert(DIKS_DEAD_SEMIVOICED_SOUND , Qt::Key_Dead_Semivoiced_Sound); - insert(DIKS_DEAD_TILDE , Qt::Key_Dead_Tilde); - insert(DIKS_DEAD_VOICED_SOUND , Qt::Key_Dead_Voiced_Sound); - insert(DIKS_SPACE , Qt::Key_Space); - insert(DIKS_EXCLAMATION_MARK , Qt::Key_Exclam); - insert(DIKS_QUOTATION , Qt::Key_QuoteDbl); - insert(DIKS_NUMBER_SIGN , Qt::Key_NumberSign); - insert(DIKS_DOLLAR_SIGN , Qt::Key_Dollar); - insert(DIKS_PERCENT_SIGN , Qt::Key_Percent); - insert(DIKS_AMPERSAND , Qt::Key_Ampersand); - insert(DIKS_APOSTROPHE , Qt::Key_Apostrophe); - insert(DIKS_PARENTHESIS_LEFT , Qt::Key_ParenLeft); - insert(DIKS_PARENTHESIS_RIGHT , Qt::Key_ParenRight); - insert(DIKS_ASTERISK , Qt::Key_Asterisk); - insert(DIKS_PLUS_SIGN , Qt::Key_Plus); - insert(DIKS_COMMA , Qt::Key_Comma); - insert(DIKS_MINUS_SIGN , Qt::Key_Minus); - insert(DIKS_PERIOD , Qt::Key_Period); - insert(DIKS_SLASH , Qt::Key_Slash); - insert(DIKS_0 , Qt::Key_0); - insert(DIKS_1 , Qt::Key_1); - insert(DIKS_2 , Qt::Key_2); - insert(DIKS_3 , Qt::Key_3); - insert(DIKS_4 , Qt::Key_4); - insert(DIKS_5 , Qt::Key_5); - insert(DIKS_6 , Qt::Key_6); - insert(DIKS_7 , Qt::Key_7); - insert(DIKS_8 , Qt::Key_8); - insert(DIKS_9 , Qt::Key_9); - insert(DIKS_COLON , Qt::Key_Colon); - insert(DIKS_SEMICOLON , Qt::Key_Semicolon); - insert(DIKS_LESS_THAN_SIGN , Qt::Key_Less); - insert(DIKS_EQUALS_SIGN , Qt::Key_Equal); - insert(DIKS_GREATER_THAN_SIGN , Qt::Key_Greater); - insert(DIKS_QUESTION_MARK , Qt::Key_Question); - insert(DIKS_AT , Qt::Key_At); - insert(DIKS_CAPITAL_A , Qt::Key_A); - insert(DIKS_CAPITAL_B , Qt::Key_B); - insert(DIKS_CAPITAL_C , Qt::Key_C); - insert(DIKS_CAPITAL_D , Qt::Key_D); - insert(DIKS_CAPITAL_E , Qt::Key_E); - insert(DIKS_CAPITAL_F , Qt::Key_F); - insert(DIKS_CAPITAL_G , Qt::Key_G); - insert(DIKS_CAPITAL_H , Qt::Key_H); - insert(DIKS_CAPITAL_I , Qt::Key_I); - insert(DIKS_CAPITAL_J , Qt::Key_J); - insert(DIKS_CAPITAL_K , Qt::Key_K); - insert(DIKS_CAPITAL_L , Qt::Key_L); - insert(DIKS_CAPITAL_M , Qt::Key_M); - insert(DIKS_CAPITAL_N , Qt::Key_N); - insert(DIKS_CAPITAL_O , Qt::Key_O); - insert(DIKS_CAPITAL_P , Qt::Key_P); - insert(DIKS_CAPITAL_Q , Qt::Key_Q); - insert(DIKS_CAPITAL_R , Qt::Key_R); - insert(DIKS_CAPITAL_S , Qt::Key_S); - insert(DIKS_CAPITAL_T , Qt::Key_T); - insert(DIKS_CAPITAL_U , Qt::Key_U); - insert(DIKS_CAPITAL_V , Qt::Key_V); - insert(DIKS_CAPITAL_W , Qt::Key_W); - insert(DIKS_CAPITAL_X , Qt::Key_X); - insert(DIKS_CAPITAL_Y , Qt::Key_Y); - insert(DIKS_CAPITAL_Z , Qt::Key_Z); - insert(DIKS_SQUARE_BRACKET_LEFT , Qt::Key_BracketLeft); - insert(DIKS_BACKSLASH , Qt::Key_Backslash); - insert(DIKS_SQUARE_BRACKET_RIGHT , Qt::Key_BracketRight); - insert(DIKS_CIRCUMFLEX_ACCENT , Qt::Key_AsciiCircum); - insert(DIKS_UNDERSCORE , Qt::Key_Underscore); - insert(DIKS_SMALL_A , Qt::Key_A); - insert(DIKS_SMALL_B , Qt::Key_B); - insert(DIKS_SMALL_C , Qt::Key_C); - insert(DIKS_SMALL_D , Qt::Key_D); - insert(DIKS_SMALL_E , Qt::Key_E); - insert(DIKS_SMALL_F , Qt::Key_F); - insert(DIKS_SMALL_G , Qt::Key_G); - insert(DIKS_SMALL_H , Qt::Key_H); - insert(DIKS_SMALL_I , Qt::Key_I); - insert(DIKS_SMALL_J , Qt::Key_J); - insert(DIKS_SMALL_K , Qt::Key_K); - insert(DIKS_SMALL_L , Qt::Key_L); - insert(DIKS_SMALL_M , Qt::Key_M); - insert(DIKS_SMALL_N , Qt::Key_N); - insert(DIKS_SMALL_O , Qt::Key_O); - insert(DIKS_SMALL_P , Qt::Key_P); - insert(DIKS_SMALL_Q , Qt::Key_Q); - insert(DIKS_SMALL_R , Qt::Key_R); - insert(DIKS_SMALL_S , Qt::Key_S); - insert(DIKS_SMALL_T , Qt::Key_T); - insert(DIKS_SMALL_U , Qt::Key_U); - insert(DIKS_SMALL_V , Qt::Key_V); - insert(DIKS_SMALL_W , Qt::Key_W); - insert(DIKS_SMALL_X , Qt::Key_X); - insert(DIKS_SMALL_Y , Qt::Key_Y); - insert(DIKS_SMALL_Z , Qt::Key_Z); - insert(DIKS_CURLY_BRACKET_LEFT , Qt::Key_BraceLeft); - insert(DIKS_VERTICAL_BAR , Qt::Key_Bar); - insert(DIKS_CURLY_BRACKET_RIGHT , Qt::Key_BraceRight); - insert(DIKS_TILDE , Qt::Key_AsciiTilde); -} diff --git a/src/plugins/platforms/minimaldfb/qdirectfbconvenience.h b/src/plugins/platforms/minimaldfb/qdirectfbconvenience.h deleted file mode 100644 index 0b1a24f..0000000 --- a/src/plugins/platforms/minimaldfb/qdirectfbconvenience.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef QDIRECTFBCONVENIENCE_H -#define QDIRECTFBCONVENIENCE_H - -#include -#include -#include -#include - -#include - -class QDirectFbKeyMap: public QHash -{ -public: - QDirectFbKeyMap(); -}; - - -class QDirectFbConvenience -{ -public: - static QImage::Format imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps); - static bool pixelFomatHasAlpha(const DFBSurfacePixelFormat format) { return (1 << 16) & format; } - static int colorDepthForSurface(const DFBSurfacePixelFormat format); - - //This is set by the graphicssystem constructor - static IDirectFB *dfbInterface(); - static IDirectFBDisplayLayer *dfbDisplayLayer(int display = DLID_PRIMARY); - - static IDirectFBSurface *dfbSurfaceForPixmapData(QPixmapData *); - - static Qt::MouseButton mouseButton(DFBInputDeviceButtonIdentifier identifier); - static Qt::MouseButtons mouseButtons(DFBInputDeviceButtonMask mask); - static Qt::KeyboardModifiers keyboardModifiers(DFBInputDeviceModifierMask mask); - static QEvent::Type eventType(DFBWindowEventType type); - - static QDirectFbKeyMap *keyMap(); - -private: - static QDirectFbKeyMap *dfbKeymap; - friend class QDirectFbGraphicsSystem; -}; - -#endif // QDIRECTFBCONVENIENCE_H diff --git a/src/plugins/platforms/minimaldfb/qdirectfbcursor.cpp b/src/plugins/platforms/minimaldfb/qdirectfbcursor.cpp deleted file mode 100644 index 229a875..0000000 --- a/src/plugins/platforms/minimaldfb/qdirectfbcursor.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "qdirectfbcursor.h" -#include "qblitter_directfb.h" -#include "qgraphicssystem_minimaldfb.h" -#include "qdirectfbconvenience.h" - -#include - -QDirectFBCursor::QDirectFBCursor(QGraphicsSystemScreen * screen) : - QGraphicsSystemCursor(screen), surface(0) -{ - QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY, &m_layer); - image = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); -} - -void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) -{ - Q_UNUSED(widget); - int xSpot; - int ySpot; - QPixmap map; - - if (cursor->shape() != Qt::BitmapCursor) { - image->set(cursor->shape()); - xSpot = image->hotspot().x(); - ySpot = image->hotspot().y(); - QImage *i = image->image(); - map = QPixmap::fromImage(*i); - } else { - QPoint point = cursor->hotSpot(); - xSpot = point.x(); - ySpot = point.y(); - map = cursor->pixmap(); - } - - IDirectFBSurface *surface = QDirectFbConvenience::dfbSurfaceForPixmapData(map.pixmapData()); - - if (m_layer->SetCooperativeLevel(m_layer, DLSCL_ADMINISTRATIVE) != DFB_OK) { - return; - } - m_layer->SetCursorShape( m_layer, surface, xSpot, ySpot); - m_layer->SetCooperativeLevel(m_layer, DLSCL_SHARED); -} diff --git a/src/plugins/platforms/minimaldfb/qdirectfbcursor.h b/src/plugins/platforms/minimaldfb/qdirectfbcursor.h deleted file mode 100644 index 064a336..0000000 --- a/src/plugins/platforms/minimaldfb/qdirectfbcursor.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef QDIRECTFBCURSOR_H -#define QDIRECTFBCURSOR_H - -#include -#include -class QDirectFbGraphicsSystemScreen; -class QDirectFbBlitter; - -class QDirectFBCursor : public QGraphicsSystemCursor -{ -public: - QDirectFBCursor(QGraphicsSystemScreen *screem); - void changeCursor(QCursor * cursor, QWidget * widget); - -private: - IDirectFBDisplayLayer * m_layer; - IDirectFBSurface * surface; - QGraphicsSystemCursorImage * image; - QDirectFbBlitter *blitter; -}; - -#endif // QDIRECTFBCURSOR_H diff --git a/src/plugins/platforms/minimaldfb/qdirectfbinput.cpp b/src/plugins/platforms/minimaldfb/qdirectfbinput.cpp deleted file mode 100644 index 74a38a4..0000000 --- a/src/plugins/platforms/minimaldfb/qdirectfbinput.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include "qdirectfbinput.h" -#include "qdirectfbconvenience.h" - -#include -#include -#include -#include -#include -#include - -#include - -InputSocketWaiter::InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent) - : QThread(parent), m_eventBuffer(eventBuffer),m_shouldStop(false) -{ - this->start(); -} - -InputSocketWaiter::~InputSocketWaiter() -{ - m_shouldStop = true; - m_eventBuffer->WakeUp(m_eventBuffer); - m_cleanupMutex.lock(); -} - -void InputSocketWaiter::continueWaitingForEvents() -{ - m_finishedProcessingEvents.wakeAll(); -} - -void InputSocketWaiter::run() -{ - m_cleanupMutex.lock(); - while (1) { - m_eventBuffer->WaitForEvent(m_eventBuffer); - if (m_shouldStop) - break; - emit newEvent(); - QMutex waitForProcessingMutex; - waitForProcessingMutex.lock(); - m_finishedProcessingEvents.wait(&waitForProcessingMutex); - } - m_cleanupMutex.unlock(); -} - -QDirectFbInput *QDirectFbInput::instance() -{ - static QDirectFbInput *input = 0; - if (!input) { - input = new QDirectFbInput(); - } - return input; -} - -QDirectFbInput::QDirectFbInput() - : QObject() -{ - dfbInterface = QDirectFbConvenience::dfbInterface(); - - DFBResult ok = dfbInterface->CreateEventBuffer(dfbInterface,&eventBuffer); - if (ok != DFB_OK) - DirectFBError("Failed to initialise eventbuffer", ok); - - dfbInterface->GetDisplayLayer(dfbInterface,DLID_PRIMARY, &dfbDisplayLayer); - - m_inputHandler = new InputSocketWaiter(eventBuffer,this); - connect(m_inputHandler,SIGNAL(newEvent()),this,SLOT(handleEvents())); - - connect(QApplication::instance(),SIGNAL(aboutToQuit()),SLOT(applicationEnd())); -} - -void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) -{ - tlwMap.insert(id,tlw); - IDirectFBWindow *window; - dfbDisplayLayer->GetWindow(dfbDisplayLayer,id,&window); - - window->AttachEventBuffer(window,eventBuffer); -} - -void QDirectFbInput::removeWindow(QWidget *tlw) -{ - DFBWindowID id = tlwMap.key(tlw,0); - if (id) { - IDirectFBWindow *window; - dfbDisplayLayer->GetWindow(dfbDisplayLayer,id, &window); - - window->DetachEventBuffer(window,eventBuffer); - tlwMap.remove(id); - } -} - -void QDirectFbInput::handleEvents() -{ - DFBResult hasEvent = eventBuffer->HasEvent(eventBuffer); - while(hasEvent == DFB_OK){ - DFBEvent event; - DFBResult ok = eventBuffer->GetEvent(eventBuffer,&event); - if (ok != DFB_OK) - DirectFBError("Failed to get event",ok); - if (event.clazz == DFEC_WINDOW) { - switch (event.window.type) { - case DWET_BUTTONDOWN: - case DWET_BUTTONUP: - case DWET_MOTION: - handleMouseEvents(event); - break; - case DWET_WHEEL: - handleWheelEvent(event); - break; - case DWET_KEYDOWN: - case DWET_KEYUP: - handleKeyEvents(event); - break; - case DWET_ENTER: - case DWET_LEAVE: - handleEnterLeaveEvents(event); - default: - break; - } - - } - - hasEvent = eventBuffer->HasEvent(eventBuffer); - } - m_inputHandler->continueWaitingForEvents(); -} - -void QDirectFbInput::handleMouseEvents(const DFBEvent &event) -{ - QPoint p(event.window.x, event.window.y); - QPoint globalPos = globalPoint(event); - Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons); - - IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); - IDirectFBWindow *window; - layer->GetWindow(layer,event.window.window_id,&window); - - long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); - - if (event.window.type == DWET_BUTTONDOWN) { - window->GrabPointer(window); - } else if (event.window.type == DWET_BUTTONUP) { - window->UngrabPointer(window); - } - QWidget *tlw = tlwMap.value(event.window.window_id); - QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons); -} - -void QDirectFbInput::applicationEnd() -{ - delete m_inputHandler; - m_inputHandler = 0; -} - -void QDirectFbInput::handleWheelEvent(const DFBEvent &event) -{ - QPoint p(event.window.cx, event.window.cy); - QPoint globalPos = globalPoint(event); - long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); - QWidget *tlw = tlwMap.value(event.window.window_id); - QWindowSystemInterface::handleWheelEvent(tlw, timestamp, p, globalPos, - event.window.step*120, - Qt::Vertical); -} - -void QDirectFbInput::handleKeyEvents(const DFBEvent &event) -{ - QEvent::Type type = QDirectFbConvenience::eventType(event.window.type); - Qt::Key key = QDirectFbConvenience::keyMap()->value(event.window.key_symbol); - Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers); - - long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); - - QChar character; - if (DFB_KEY_TYPE(event.window.key_symbol) == DIKT_UNICODE) - character = QChar(event.window.key_symbol); - QWidget *tlw = tlwMap.value(event.window.window_id); - QWindowSystemInterface::handleKeyEvent(tlw, timestamp, type, key, modifiers, character); -} - -void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) -{ - QWidget *tlw = tlwMap.value(event.window.window_id); - switch (event.window.type) { - case DWET_ENTER: - QWindowSystemInterface::handleEnterEvent(tlw); - break; - case DWET_LEAVE: - QWindowSystemInterface::handleLeaveEvent(tlw); - break; - default: - break; - } -} - -inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const -{ - IDirectFBWindow *window; - dfbDisplayLayer->GetWindow(dfbDisplayLayer,event.window.window_id,&window); - int x,y; - window->GetPosition(window,&x,&y); - return QPoint(event.window.cx +x, event.window.cy + y); -} - diff --git a/src/plugins/platforms/minimaldfb/qdirectfbinput.h b/src/plugins/platforms/minimaldfb/qdirectfbinput.h deleted file mode 100644 index 31aa082..0000000 --- a/src/plugins/platforms/minimaldfb/qdirectfbinput.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef QDIRECTFBINPUT_H -#define QDIRECTFBINPUT_H - -#include -#include -#include -#include -#include -#include -#include - -#include - -class InputSocketWaiter : public QThread -{ - Q_OBJECT -public: - InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent); - virtual ~InputSocketWaiter(); - void continueWaitingForEvents(); -protected: - void run(); -signals: - void newEvent(); -private: - IDirectFBEventBuffer *m_eventBuffer; - bool m_shouldStop; - QMutex m_cleanupMutex; - QWaitCondition m_finishedProcessingEvents; -}; - -class QDirectFbInput : public QObject -{ - Q_OBJECT -public: - static QDirectFbInput *instance(); - void addWindow(DFBWindowID id, QWidget *tlw); - void removeWindow(QWidget *tlw); - -public slots: - void handleEvents(); - void applicationEnd(); - -private: - QDirectFbInput(); - - void handleMouseEvents(const DFBEvent &event); - void handleWheelEvent(const DFBEvent &event); - void handleKeyEvents(const DFBEvent &event); - void handleEnterLeaveEvents(const DFBEvent &event); - IDirectFB *dfbInterface; - IDirectFBDisplayLayer *dfbDisplayLayer; - IDirectFBEventBuffer *eventBuffer; - - QHashtlwMap; - - inline QPoint globalPoint(const DFBEvent &event) const; - - InputSocketWaiter *m_inputHandler; - -}; - -#endif // QDIRECTFBINPUT_H diff --git a/src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.cpp b/src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.cpp deleted file mode 100644 index 212f3a9..0000000 --- a/src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_minimaldfb.h" -#include "qwindowsurface_minimaldfb.h" -#include "qblitter_directfb.h" -#include "qdirectfbconvenience.h" -#include "qdirectfbcursor.h" - -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QDirectFbGraphicsSystemScreen::QDirectFbGraphicsSystemScreen(int display) - :QGraphicsSystemScreen() -{ - m_layer = QDirectFbConvenience::dfbDisplayLayer(display); - m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); - - DFBDisplayLayerConfig config; - m_layer->GetConfiguration(m_layer, &config); - - m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps); - m_geometry = QRect(0,0,config.width,config.height); - const int dpi = 72; - const qreal inch = 25.4; - m_depth = 32; - m_physicalSize = QSize(qRound(config.width * inch / dpi), qRound(config.height *inch / dpi)); - - cursor = new QDirectFBCursor(this); -} - -QDirectFbGraphicsSystemScreen::~QDirectFbGraphicsSystemScreen() -{ -} - -QDirectFbGraphicsSystem::QDirectFbGraphicsSystem() -{ - const QStringList args = QCoreApplication::arguments(); - int argc = args.size(); - char **argv = new char*[argc]; - - for (int i = 0; i < argc; ++i) - argv[i] = qstrdup(args.at(i).toLocal8Bit().constData()); - - DFBResult result = DirectFBInit(&argc, &argv); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreen: error initializing DirectFB", - result); - } - delete[] argv; - - mPrimaryScreen = new QDirectFbGraphicsSystemScreen(0); - mScreens.append(mPrimaryScreen); -} - -QPixmapData *QDirectFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - if (type == QPixmapData::BitmapType) - return new QRasterPixmapData(type); - else - return new QBlittablePixmapData(type); -} - -QWindowSurface *QDirectFbGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - return new QDirectFbWindowSurface (widget); -} - -QBlittable *QDirectFbGraphicsSystem::createBlittable(const QSize &size) const -{ - return new QDirectFbBlitter(size); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.h b/src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.h deleted file mode 100644 index 27bddfb..0000000 --- a/src/plugins/platforms/minimaldfb/qgraphicssystem_minimaldfb.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_MINIMAL_H -#define QGRAPHICSSYSTEM_MINIMAL_H - -#include "qdirectfbinput.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDirectFBCursor; - -class QDirectFbGraphicsSystemScreen : public QGraphicsSystemScreen -{ -public: - QDirectFbGraphicsSystemScreen(int display); - ~QDirectFbGraphicsSystemScreen(); - - 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; } - -public: - QRect m_geometry; - int m_depth; - QImage::Format m_format; - QSize m_physicalSize; - - IDirectFBDisplayLayer *m_layer; - -private: - QDirectFBCursor * cursor; - -}; - -class QDirectFbGraphicsSystem : public QGraphicsSystem -{ -public: - QDirectFbGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - QBlittable *createBlittable(const QSize &size) const; - - QList screens() const { return mScreens; } - - - -private: - QDirectFbGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.cpp b/src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.cpp deleted file mode 100644 index 68d5aa0..0000000 --- a/src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindowsurface_minimaldfb.h" -#include "qgraphicssystem_minimaldfb.h" -#include "qblitter_directfb.h" -#include "qdirectfbconvenience.h" -#include - -#include - -QT_BEGIN_NAMESPACE - -QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window) - : QWindowSurface(window), m_pixmap(0), m_pmdata(0), - m_dfbWindow(0), m_dfbSurface(0) -{ - window->setWindowSurface(this); - - IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); - DFBDisplayLayerConfig layerConfig; - layer->GetConfiguration(layer,&layerConfig); - - DFBWindowDescription description; - memset(&description,0,sizeof(DFBWindowDescription)); - description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS -#if DIRECTFB_MINOR_VERSION >= 1 - |DWDESC_OPTIONS -#endif - |DWDESC_CAPS); - description.width = window->rect().width(); - description.height = window->rect().height(); - description.posx = window->rect().x(); - description.posy = window->rect().y(); - - if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED) - description.surface_caps = DSCAPS_PREMULTIPLIED; - description.pixelformat = layerConfig.pixelformat; - -#if DIRECTFB_MINOR_VERSION >= 1 - description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); -#endif - description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL); - description.surface_caps = DSCAPS_PREMULTIPLIED; - - DFBResult result = layer->CreateWindow(layer,&description,&m_dfbWindow); - if (result != DFB_OK) { - DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); - } - - DFBWindowID id; - m_dfbWindow->GetID(m_dfbWindow, &id); - QDirectFbInput::instance()->addWindow(id,window); - - m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); - - QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect().size(), m_dfbSurface); - m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); - m_pmdata->setBlittable(blitter); - m_pixmap = new QPixmap(m_pmdata); -} - -QDirectFbWindowSurface::~QDirectFbWindowSurface() -{ - QDirectFbInput::instance()->removeWindow(this->window()); - m_dfbWindow->Destroy(m_dfbWindow); -} - -QPaintDevice *QDirectFbWindowSurface::paintDevice() -{ - return m_pixmap; -} - -void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - m_pmdata->blittable()->unlock(); - - const quint8 windowOpacity = quint8(widget->windowOpacity() * 0xff); - m_dfbWindow->SetOpacity(m_dfbWindow,windowOpacity); - - QVector rects = region.rects(); - for (int i = 0 ; i < rects.size(); i++) { - const QRect rect = rects.at(i); - DFBRegion dfbReg = { rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()}; - m_dfbSurface->Flip(m_dfbSurface, &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC)); - } -} - -void QDirectFbWindowSurface::setGeometry(const QRect &rect) -{ - m_pmdata->blittable()->unlock(); - - QWindowSurface::setGeometry(rect); - m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), - rect.width(), rect.height()); - - //Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable - m_dfbSurface->AddRef(m_dfbSurface); - QDirectFbBlitter *blitter = new QDirectFbBlitter(rect.size(),m_dfbSurface); - m_pmdata->setBlittable(blitter); -} - -static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) -{ - const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; - surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy); - const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy }; - surface->Flip(surface, ®ion, DFBSurfaceFlipFlags(DSFLIP_BLIT)); -} - -bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - m_pmdata->blittable()->unlock(); - - if (!m_dfbSurface || area.isEmpty()) - return false; - m_dfbSurface->SetBlittingFlags(m_dfbSurface, DSBLIT_NOFX); - if (area.rectCount() == 1) { - scrollSurface(m_dfbSurface, area.boundingRect(), dx, dy); - } else { - const QVector rects = area.rects(); - const int n = rects.size(); - for (int i=0; iblittable()->unlock(); - - if (visible) { - int x = this->geometry().x(); - int y = this->geometry().y(); - m_dfbWindow->MoveTo(m_dfbWindow,x,y); - } else { - IDirectFBDisplayLayer *displayLayer; - QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY,&displayLayer); - - DFBDisplayLayerConfig config; - displayLayer->GetConfiguration(displayLayer,&config); - m_dfbWindow->MoveTo(m_dfbWindow,config.width+1,config.height + 1); - } -} - -Qt::WindowFlags QDirectFbWindowSurface::setWindowFlags(Qt::WindowFlags flags) -{ - switch (flags & Qt::WindowType_Mask) { - case Qt::ToolTip: { - DFBWindowOptions options; - m_dfbWindow->GetOptions(m_dfbWindow,&options); - options = DFBWindowOptions(options | DWOP_GHOST); - m_dfbWindow->SetOptions(m_dfbWindow,options); - break; } - default: - break; - } - - m_dfbWindow->SetStackingClass(m_dfbWindow, flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE); - return flags; -} - -void QDirectFbWindowSurface::raise() -{ - m_dfbWindow->RaiseToTop(m_dfbWindow); -} - -void QDirectFbWindowSurface::lower() -{ - m_dfbWindow->LowerToBottom(m_dfbWindow); -} - -WId QDirectFbWindowSurface::winId() const -{ - DFBWindowID id; - m_dfbWindow->GetID(m_dfbWindow, &id); - return WId(id); -} - - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.h b/src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.h deleted file mode 100644 index ca34cbf..0000000 --- a/src/plugins/platforms/minimaldfb/qwindowsurface_minimaldfb.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_MINIMAL_H -#define QWINDOWSURFACE_MINIMAL_H - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class QDirectFbGraphicsSystemScreen; - -class QDirectFbWindowSurface : public QWindowSurface -{ -public: - QDirectFbWindowSurface(QWidget *window); - ~QDirectFbWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - - void setVisible(bool visible); - Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); - - void raise(); - void lower(); - - WId winId() const; - -private: - void lockSurfaceToImage(); - - QPixmap *m_pixmap; - QBlittablePixmapData *m_pmdata; - - IDirectFBWindow *m_dfbWindow; - IDirectFBSurface *m_dfbSurface; -}; - -QT_END_NAMESPACE - -#endif -- cgit v0.12 From 7cb41f111706542da7e5391c99720acee6d2ac43 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 31 Mar 2010 12:32:15 +0200 Subject: Stub out QtOpenGL on Lighthouse & get it compiling --- config.tests/unix/opengldesktop/opengldesktop.cpp | 52 +++++ config.tests/unix/opengldesktop/opengldesktop.pro | 9 + configure | 77 +++++++- mkspecs/common/qws.conf | 4 - src/opengl/opengl.pro | 12 ++ src/opengl/qgl.cpp | 2 +- src/opengl/qgl_lite.cpp | 227 ++++++++++++++++++++++ src/opengl/qglpixelbuffer_p.h | 5 + src/opengl/qglpixelbuffer_stub.cpp | 84 ++++++++ 9 files changed, 457 insertions(+), 15 deletions(-) create mode 100644 config.tests/unix/opengldesktop/opengldesktop.cpp create mode 100644 config.tests/unix/opengldesktop/opengldesktop.pro create mode 100644 src/opengl/qgl_lite.cpp create mode 100644 src/opengl/qglpixelbuffer_stub.cpp diff --git a/config.tests/unix/opengldesktop/opengldesktop.cpp b/config.tests/unix/opengldesktop/opengldesktop.cpp new file mode 100644 index 0000000..969767c --- /dev/null +++ b/config.tests/unix/opengldesktop/opengldesktop.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** 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 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 + +int main(int, char **) +{ + glBegin(GL_TRIANGLES); + glVertex2f(20.0f, 10.0f); + glVertex2f(10.0f, 30.0f); + glVertex2f(20.0f, 50.0f); + glEnd(); + return 0; +} diff --git a/config.tests/unix/opengldesktop/opengldesktop.pro b/config.tests/unix/opengldesktop/opengldesktop.pro new file mode 100644 index 0000000..ac70ca3 --- /dev/null +++ b/config.tests/unix/opengldesktop/opengldesktop.pro @@ -0,0 +1,9 @@ +SOURCES = opengldesktop.cpp +INCLUDEPATH += $$QMAKE_INCDIR_OPENGL + +for(p, QMAKE_LIBDIR_OPENGL) { + exists($$p):LIBS += -L$$p +} + +CONFIG -= qt +LIBS += $$QMAKE_LIBS_OPENGL diff --git a/configure b/configure index b27d6dd..ffaa498 100755 --- a/configure +++ b/configure @@ -5560,14 +5560,68 @@ if [ "$PLATFORM_MAC" = "yes" ]; then fi fi + +if [ "$PLATFORM_EMBLITE" = "yes" ]; then + # auto-detect OpenGL support (es1 = OpenGL ES 1.x Common, es2 = OpenGL ES 2.x) + if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengldesktop "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then + CFG_OPENGL=desktop + elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS; then + CFG_OPENGL=es2 + elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS; then + CFG_OPENGL=es1 + else + if [ "$CFG_OPENGL" = "yes" ]; then + echo "All the OpenGL functionality tests failed!" + echo " You might need to modify the include and library search paths by editing" + echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" + echo " ${XQMAKESPEC}." + exit 1 + fi + CFG_OPENGL=no + fi + elif [ "$CFG_OPENGL" = "es1" ]; then + # OpenGL ES 1.x + "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS + if [ $? != "0" ]; then + echo "The OpenGL ES 1.x functionality test failed!" + echo " You might need to modify the include and library search paths by editing" + echo " QMAKE_INCDIR_OPENGL_ES1, QMAKE_LIBDIR_OPENGL_ES1 and QMAKE_LIBS_OPENGL_ES1 in" + echo " ${XQMAKESPEC}." + exit 1 + fi + elif [ "$CFG_OPENGL" = "es2" ]; then + #OpenGL ES 2.x + "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS + if [ $? != "0" ]; then + echo "The OpenGL ES 2.0 functionality test failed!" + echo " You might need to modify the include and library search paths by editing" + echo " QMAKE_INCDIR_OPENGL_ES2, QMAKE_LIBDIR_OPENGL_ES2 and QMAKE_LIBS_OPENGL_ES2 in" + echo " ${XQMAKESPEC}." + exit 1 + fi + elif [ "$CFG_OPENGL" = "desktop" ]; then + # Desktop OpenGL support + "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengldesktop "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS + if [ $? != "0" ]; then + echo "The OpenGL functionality test failed!" + echo " You might need to modify the include and library search paths by editing" + echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" + echo " ${XQMAKESPEC}." + exit 1 + fi + fi +fi + + # QWS -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" ]; then # auto-detect OpenGL support (es1 = OpenGL ES 1.x Common, es2 = OpenGL ES 2.x) if [ "$CFG_OPENGL" = "yes" ]; then if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS; then CFG_OPENGL=es2 - elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS; then + elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS; then CFG_OPENGL=es1 else echo "All the OpenGL ES functionality tests failed!" @@ -5578,22 +5632,22 @@ if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then fi elif [ "$CFG_OPENGL" = "es1" ]; then # OpenGL ES 1.x - "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS + "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS if [ $? != "0" ]; then - echo "The OpenGL ES 1.x functionality test failed!" + echo "The OpenGL ES 1.x functionality test failed!" echo " You might need to modify the include and library search paths by editing" - echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" - echo " ${XQMAKESPEC}." + echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" + echo " ${XQMAKESPEC}." exit 1 fi elif [ "$CFG_OPENGL" = "es2" ]; then #OpenGL ES 2.x - "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS + "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS if [ $? != "0" ]; then - echo "The OpenGL ES 2.0 functionality test failed!" + echo "The OpenGL ES 2.0 functionality test failed!" echo " You might need to modify the include and library search paths by editing" - echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" - echo " ${XQMAKESPEC}." + echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" + echo " ${XQMAKESPEC}." exit 1 fi elif [ "$CFG_OPENGL" = "desktop" ]; then @@ -5601,6 +5655,9 @@ if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then echo "Desktop OpenGL support is not avaliable on Qt for Embedded Linux" exit 1 fi +fi + +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then # screen drivers for screen in ${CFG_GFX_ON} ${CFG_GFX_PLUGIN}; do diff --git a/mkspecs/common/qws.conf b/mkspecs/common/qws.conf index 96341a7..2e8ae2c 100644 --- a/mkspecs/common/qws.conf +++ b/mkspecs/common/qws.conf @@ -12,9 +12,5 @@ QMAKE_INCREMENTAL_STYLE = sublib # modifications to linux.conf QMAKE_INCDIR_X11 = QMAKE_LIBDIR_X11 = -QMAKE_INCDIR_OPENGL = -QMAKE_LIBDIR_OPENGL = QMAKE_LIBS_X11 = QMAKE_LIBS_X11SM = -QMAKE_LIBS_OPENGL = -QMAKE_LIBS_OPENGL_QT = diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index c111a8e..60d4b17 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -76,6 +76,18 @@ SOURCES += qgl.cpp \ } +embedded_lite { + SOURCES += qgl_lite.cpp + + # If we have EGL, use the EGL implementation of QGLPixelBuffer, otherwise we just provide + # a stubbed out one. PBuffers aren't too interesting anyway. + contains(QT_CONFIG, egl) { + SOURCES += qglpixelbuffer_egl.cpp + } else { + SOURCES += qglpixelbuffer_stub.cpp + } +} + x11 { contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2) { SOURCES += qgl_x11egl.cpp \ diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index e0030ad..7fcf390 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -95,7 +95,7 @@ QT_BEGIN_NAMESPACE -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_LITE) QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs; #endif diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp new file mode 100644 index 0000000..40417b1 --- /dev/null +++ b/src/opengl/qgl_lite.cpp @@ -0,0 +1,227 @@ +/**************************************************************************** +** +** 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 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 "qgl.h" +#include "qgl_p.h" + +#include "qmap.h" +#include "qapplication.h" +#include "qcolormap.h" +#include "qdesktopwidget.h" +#include "qpixmap.h" +#include "qhash.h" +#include "qlibrary.h" +#include "qdebug.h" +#include + +QT_BEGIN_NAMESPACE + +bool QGLFormat::hasOpenGL() +{ + return true; // IMPLEMENT ME PROPERLY! +} + + + +bool QGLContext::chooseContext(const QGLContext* shareContext) +{ + // IMPLEMENT ME + return false; +} + + +void QGLContext::reset() +{ + Q_D(QGLContext); + if (!d->valid) + return; + d->cleanup(); + doneCurrent(); + + // IMPLEMENT ME + + d->crWin = false; + d->sharing = false; + d->valid = false; + d->transpColor = QColor(); + d->initDone = false; + QGLContextGroup::removeShare(this); +} + + +void QGLContext::makeCurrent() +{ + // IMPLEMENT ME +} + +void QGLContext::doneCurrent() +{ + // IMPLEMENT ME +} + + +void QGLContext::swapBuffers() const +{ + // IMPLEMENT ME +} + +void *QGLContext::getProcAddress(const QString &proc) const +{ + // IMPLEMENT ME +} + +void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) +{ + // IMPLEMENT ME +} + + +void QGLWidget::setContext(QGLContext *context, + const QGLContext* shareContext, + bool deleteOldContext) +{ + // IMPLEMENT ME +} + + + + + + + +bool QGLFormat::hasOpenGLOverlays() +{ + return false; +} + +QColor QGLContext::overlayTransparentColor() const +{ + return QColor(); // Invalid color +} + +uint QGLContext::colorIndex(const QColor& c) const +{ + return 0; +} + +void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase) +{ + Q_UNUSED(fnt); + Q_UNUSED(listBase); +} + +/* + QGLTemporaryContext implementation +*/ +class QGLTemporaryContextPrivate +{ +public: + QGLWidget *widget; +}; + +QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) + : d(new QGLTemporaryContextPrivate) +{ + d->widget = new QGLWidget; + d->widget->makeCurrent(); +} + +QGLTemporaryContext::~QGLTemporaryContext() +{ + delete d->widget; +} + + +bool QGLWidgetPrivate::renderCxPm(QPixmap* pm) +{ + return false; +} + +/*! \internal + Free up any allocated colormaps. This fn is only called for + top-level widgets. +*/ +void QGLWidgetPrivate::cleanupColormaps() +{ +} + +void QGLWidget::setMouseTracking(bool enable) +{ + Q_UNUSED(enable); +} + +void QGLWidget::resizeEvent(QResizeEvent *) +{ + Q_D(QGLWidget); + if (!isValid()) + return; + makeCurrent(); + if (!d->glcx->initialized()) + glInit(); + resizeGL(width(), height()); +} + +const QGLContext* QGLWidget::overlayContext() const +{ + return 0; +} + +void QGLWidget::makeOverlayCurrent() +{ +} + + +void QGLWidget::updateOverlayGL() +{ +} + +const QGLColormap & QGLWidget::colormap() const +{ + Q_D(const QGLWidget); + return d->cmap; +} + +void QGLWidget::setColormap(const QGLColormap & c) +{ + Q_UNUSED(c); +} + +QT_END_NAMESPACE diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h index c85dc5a..bff35f5 100644 --- a/src/opengl/qglpixelbuffer_p.h +++ b/src/opengl/qglpixelbuffer_p.h @@ -200,6 +200,11 @@ public: QEglContext *ctx; int textureFormat; #endif +#if defined(Q_WS_LITE) + // Stubs + int pbuf; + int ctx; +#endif }; QT_END_NAMESPACE diff --git a/src/opengl/qglpixelbuffer_stub.cpp b/src/opengl/qglpixelbuffer_stub.cpp new file mode 100644 index 0000000..2caef6b --- /dev/null +++ b/src/opengl/qglpixelbuffer_stub.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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 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 +#include "qglpixelbuffer.h" +#include "qglpixelbuffer_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget) +{ + Q_UNUSED(size); + Q_UNUSED(f); + Q_UNUSED(shareWidget); + return false; +} + +bool QGLPixelBufferPrivate::cleanup() +{ + return false; +} + +bool QGLPixelBuffer::bindToDynamicTexture(GLuint texture_id) +{ + Q_UNUSED(texture_id); + return false; +} + +void QGLPixelBuffer::releaseFromDynamicTexture() +{ +} + +GLuint QGLPixelBuffer::generateDynamicTexture() const +{ + return 0; +} + +bool QGLPixelBuffer::hasOpenGLPbuffers() +{ + return false; +} + +QT_END_NAMESPACE -- cgit v0.12 From c1cb9ed008ab489f209d0a628d41d62d75a5bab2 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 31 Mar 2010 13:15:09 +0200 Subject: Port "testlite" to the new plugin API --- src/plugins/platforms/testlite/main.cpp | 16 +-- .../testlite/qgraphicssystem_testlite.cpp | 121 --------------------- .../platforms/testlite/qgraphicssystem_testlite.h | 91 ---------------- .../testlite/qplatformintegration_testlite.cpp | 121 +++++++++++++++++++++ .../testlite/qplatformintegration_testlite.h | 92 ++++++++++++++++ .../platforms/testlite/qwindowsurface_testlite.cpp | 14 +-- .../platforms/testlite/qwindowsurface_testlite.h | 12 +- src/plugins/platforms/testlite/testlite.pro | 6 +- 8 files changed, 237 insertions(+), 236 deletions(-) delete mode 100644 src/plugins/platforms/testlite/qgraphicssystem_testlite.cpp delete mode 100644 src/plugins/platforms/testlite/qgraphicssystem_testlite.h create mode 100644 src/plugins/platforms/testlite/qplatformintegration_testlite.cpp create mode 100644 src/plugins/platforms/testlite/qplatformintegration_testlite.h diff --git a/src/plugins/platforms/testlite/main.cpp b/src/plugins/platforms/testlite/main.cpp index 28caea7..c1759ef 100644 --- a/src/plugins/platforms/testlite/main.cpp +++ b/src/plugins/platforms/testlite/main.cpp @@ -39,33 +39,33 @@ ** ****************************************************************************/ -#include -#include "qgraphicssystem_testlite.h" +#include +#include "qplatformintegration_testlite.h" QT_BEGIN_NAMESPACE -class QTestLiteGraphicsSystemPlugin : public QGraphicsSystemPlugin +class QTestLiteIntegrationPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QGraphicsSystem *create(const QString&); + QPlatformIntegration *create(const QString&); }; -QStringList QTestLiteGraphicsSystemPlugin::keys() const +QStringList QTestLiteIntegrationPlugin::keys() const { QStringList list; list << "TestLite"; return list; } -QGraphicsSystem* QTestLiteGraphicsSystemPlugin::create(const QString& system) +QPlatformIntegration* QTestLiteIntegrationPlugin::create(const QString& system) { if (system.toLower() == "testlite") - return new QTestLiteGraphicsSystem; + return new QTestLiteIntegration; return 0; } -Q_EXPORT_PLUGIN2(testlite, QTestLiteGraphicsSystemPlugin) +Q_EXPORT_PLUGIN2(testlite, QTestLiteIntegrationPlugin) QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qgraphicssystem_testlite.cpp b/src/plugins/platforms/testlite/qgraphicssystem_testlite.cpp deleted file mode 100644 index 92e0ebc..0000000 --- a/src/plugins/platforms/testlite/qgraphicssystem_testlite.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_testlite.h" -#include "qwindowsurface_testlite.h" -#include -#include - -#include - - -#include "x11util.h" - -QT_BEGIN_NAMESPACE - -class MyCursor : QGraphicsSystemCursor -{ -public: - MyCursor(QGraphicsSystemScreen *screen) : QGraphicsSystemCursor(screen) {} - - void changeCursor(QCursor * cursor, QWidget * widget) { - QTestLiteWindowSurface *ws = 0; - if (widget) { - QWidget *window = widget->window(); - ws = static_cast(window->windowSurface()); - } else { - // No X11 cursor control when there is no widget under the cursor - return; - } - - //qDebug() << "changeCursor" << widget << ws; - if (!ws) - return; - - ws->setCursor(cursor); - } -}; - - -QTestLiteGraphicsSystem::QTestLiteGraphicsSystem() -{ - - xd = new MyDisplay; - - mPrimaryScreen = new QTestLiteGraphicsSystemScreen(); - - mPrimaryScreen->mGeometry = QRect - (0, 0, xd->width, xd->height); - mPrimaryScreen->mDepth = 32; - mPrimaryScreen->mFormat = QImage::Format_RGB32; - mPrimaryScreen->mPhysicalSize = - QSize(xd->physicalWidth, xd->physicalHeight); - - mScreens.append(mPrimaryScreen); - - - (void)new MyCursor(mPrimaryScreen); - -} - -QPixmapData *QTestLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -QWindowSurface *QTestLiteGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - if (widget->windowType() == Qt::Desktop) - return 0; // Don't create an explicit window surface for the destkop. - return new QTestLiteWindowSurface - (const_cast(this), mPrimaryScreen, widget); -} - - -QPixmap QTestLiteGraphicsSystem::grabWindow(WId window, int x, int y, int width, int height) const -{ - QImage img = xd->grabWindow(window, x, y, width, height); - return QPixmap::fromImage(img); -} - - - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qgraphicssystem_testlite.h b/src/plugins/platforms/testlite/qgraphicssystem_testlite.h deleted file mode 100644 index b2cd496..0000000 --- a/src/plugins/platforms/testlite/qgraphicssystem_testlite.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_TESTLITE_H -#define QGRAPHICSSYSTEM_TESTLITE_H - -#include - -QT_BEGIN_NAMESPACE - -class MyDisplay; - -class QTestLiteGraphicsSystemScreen : public QGraphicsSystemScreen -{ -public: - QTestLiteGraphicsSystemScreen() - : mDepth(16), mFormat(QImage::Format_RGB16) {} - ~QTestLiteGraphicsSystemScreen() {} - - QRect geometry() const { return mGeometry; } - int depth() const { return mDepth; } - QImage::Format format() const { return mFormat; } - QSize physicalSize() const { return mPhysicalSize; } - -public: - QRect mGeometry; - int mDepth; - QImage::Format mFormat; - QSize mPhysicalSize; -}; - -class QTestLiteGraphicsSystem : public QGraphicsSystem -{ -public: - QTestLiteGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - - QPixmap grabWindow(WId window, int x, int y, int width, int height) const; - - QList screens() const { return mScreens; } - - MyDisplay *xd; - -private: - QTestLiteGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp new file mode 100644 index 0000000..6811e2e --- /dev/null +++ b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qplatformintegration_testlite.h" +#include "qwindowsurface_testlite.h" +#include +#include + +#include + + +#include "x11util.h" + +QT_BEGIN_NAMESPACE + +class MyCursor : QGraphicsSystemCursor +{ +public: + MyCursor(QPlatformScreen *screen) : QGraphicsSystemCursor(screen) {} + + void changeCursor(QCursor * cursor, QWidget * widget) { + QTestLiteWindowSurface *ws = 0; + if (widget) { + QWidget *window = widget->window(); + ws = static_cast(window->windowSurface()); + } else { + // No X11 cursor control when there is no widget under the cursor + return; + } + + //qDebug() << "changeCursor" << widget << ws; + if (!ws) + return; + + ws->setCursor(cursor); + } +}; + + +QTestLiteIntegration::QTestLiteIntegration() +{ + + xd = new MyDisplay; + + mPrimaryScreen = new QTestLiteScreen(); + + mPrimaryScreen->mGeometry = QRect + (0, 0, xd->width, xd->height); + mPrimaryScreen->mDepth = 32; + mPrimaryScreen->mFormat = QImage::Format_RGB32; + mPrimaryScreen->mPhysicalSize = + QSize(xd->physicalWidth, xd->physicalHeight); + + mScreens.append(mPrimaryScreen); + + + (void)new MyCursor(mPrimaryScreen); + +} + +QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QTestLiteIntegration::createWindowSurface(QWidget *widget) const +{ + if (widget->windowType() == Qt::Desktop) + return 0; // Don't create an explicit window surface for the destkop. + return new QTestLiteWindowSurface + (const_cast(this), mPrimaryScreen, widget); +} + + +QPixmap QTestLiteIntegration::grabWindow(WId window, int x, int y, int width, int height) const +{ + QImage img = xd->grabWindow(window, x, y, width, height); + return QPixmap::fromImage(img); +} + + + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qplatformintegration_testlite.h b/src/plugins/platforms/testlite/qplatformintegration_testlite.h new file mode 100644 index 0000000..c540c48 --- /dev/null +++ b/src/plugins/platforms/testlite/qplatformintegration_testlite.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_TESTLITE_H +#define QGRAPHICSSYSTEM_TESTLITE_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class MyDisplay; + +class QTestLiteScreen : public QPlatformScreen +{ +public: + QTestLiteScreen() + : mDepth(16), mFormat(QImage::Format_RGB16) {} + ~QTestLiteScreen() {} + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; +}; + +class QTestLiteIntegration : public QPlatformIntegration +{ +public: + QTestLiteIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QPixmap grabWindow(WId window, int x, int y, int width, int height) const; + + QList screens() const { return mScreens; } + + MyDisplay *xd; + +private: + QTestLiteScreen *mPrimaryScreen; + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp index c54f6eb..e2574f9 100644 --- a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qwindowsurface_testlite.h" -#include "qgraphicssystem_testlite.h" +#include "qplatformintegration_testlite.h" #include #include @@ -50,16 +50,16 @@ QT_BEGIN_NAMESPACE QTestLiteWindowSurface::QTestLiteWindowSurface - (QTestLiteGraphicsSystem *graphicsSystem, - QTestLiteGraphicsSystemScreen *screen, QWidget *window) + (QTestLiteIntegration *platformIntegration, + QTestLiteScreen *screen, QWidget *window) : QWindowSurface(window), - mGraphicsSystem(graphicsSystem), + mPlatformIntegration(platformIntegration), mScreen(screen), xw(0) { - xw = new MyWindow(graphicsSystem->xd, 0,0,300,300); + xw = new MyWindow(platformIntegration->xd, 0,0,300,300); xw->windowSurface = this; // qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window; @@ -640,13 +640,13 @@ WId QTestLiteWindowSurface::winId() const void QTestLiteWindowSurface::raise() { WId window = winId(); - XRaiseWindow(mGraphicsSystem->xd->display, window); + XRaiseWindow(mPlatformIntegration->xd->display, window); } void QTestLiteWindowSurface::lower() { WId window = winId(); - XLowerWindow(mGraphicsSystem->xd->display, window); + XLowerWindow(mPlatformIntegration->xd->display, window); } void QTestLiteWindowSurface::setWindowTitle(const QString &title) diff --git a/src/plugins/platforms/testlite/qwindowsurface_testlite.h b/src/plugins/platforms/testlite/qwindowsurface_testlite.h index 0c4df1a..ffd2d3a 100644 --- a/src/plugins/platforms/testlite/qwindowsurface_testlite.h +++ b/src/plugins/platforms/testlite/qwindowsurface_testlite.h @@ -48,15 +48,15 @@ QT_BEGIN_NAMESPACE class MyWindow; -class QTestLiteGraphicsSystem; -class QTestLiteGraphicsSystemScreen; +class QTestLiteIntegration; +class QTestLiteScreen; class QTestLiteWindowSurface : public QWindowSurface { public: QTestLiteWindowSurface - (QTestLiteGraphicsSystem *graphicsSystem, - QTestLiteGraphicsSystemScreen *screen, QWidget *window); + (QTestLiteIntegration *platformIntegration, + QTestLiteScreen *screen, QWidget *window); ~QTestLiteWindowSurface(); QPaintDevice *paintDevice(); @@ -85,8 +85,8 @@ public: void setCursor(QCursor * cursor); private: - QTestLiteGraphicsSystem *mGraphicsSystem; - QTestLiteGraphicsSystemScreen *mScreen; + QTestLiteIntegration *mPlatformIntegration; + QTestLiteScreen *mScreen; Qt::WindowFlags window_flags; MyWindow *xw; }; diff --git a/src/plugins/platforms/testlite/testlite.pro b/src/plugins/platforms/testlite/testlite.pro index d483f45..442dd68 100644 --- a/src/plugins/platforms/testlite/testlite.pro +++ b/src/plugins/platforms/testlite/testlite.pro @@ -1,10 +1,10 @@ TARGET = qtestlitegraphicssystem include(../../qpluginbase.pri) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms -SOURCES = main.cpp qgraphicssystem_testlite.cpp qwindowsurface_testlite.cpp -HEADERS = qgraphicssystem_testlite.h qwindowsurface_testlite.h +SOURCES = main.cpp qplatformintegration_testlite.cpp qwindowsurface_testlite.cpp +HEADERS = qplatformintegration_testlite.h qwindowsurface_testlite.h HEADERS += x11util.h -- cgit v0.12 From fcec5d444f1e37e7b53ab503fa46b4d7f7d90b41 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 6 Apr 2010 14:45:51 +0200 Subject: Introduce QPlatformGLContext to enable QtOpenGL in Lighthouse This patch basically takes the stubbed-out code and makes it call into the new abstract base class. --- src/gui/kernel/qplatformintegration_lite.cpp | 12 ++++ src/gui/kernel/qplatformintegration_lite.h | 10 ++++ src/opengl/opengl.pro | 1 + src/opengl/qgl.cpp | 4 +- src/opengl/qgl_lite.cpp | 85 ++++++++++++++++++---------- src/opengl/qgl_p.h | 8 ++- src/opengl/qplatformglcontext_lite.h | 70 +++++++++++++++++++++++ 7 files changed, 158 insertions(+), 32 deletions(-) create mode 100644 src/opengl/qplatformglcontext_lite.h diff --git a/src/gui/kernel/qplatformintegration_lite.cpp b/src/gui/kernel/qplatformintegration_lite.cpp index f9adc14..71beded 100644 --- a/src/gui/kernel/qplatformintegration_lite.cpp +++ b/src/gui/kernel/qplatformintegration_lite.cpp @@ -56,4 +56,16 @@ QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, in return QPixmap(); } +#ifndef QT_NO_OPENGL +bool QPlatformIntegration::hasOpenGL() const +{ + return false; +} + +QPlatformGLContext * QPlatformIntegration::createGLContext() +{ + return 0; +} +#endif + QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h index 543b7bc..9125bd1 100644 --- a/src/gui/kernel/qplatformintegration_lite.h +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -51,6 +51,10 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) +#ifndef QT_NO_OPENGL +class QPlatformGLContext; +#endif + class Q_GUI_EXPORT QPlatformIntegration { public: @@ -64,6 +68,12 @@ public: // Window System functions virtual QList screens() const = 0; virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; + +// OpenGL Integration functions +#ifndef QT_NO_OPENGL + virtual bool hasOpenGL() const; + virtual QPlatformGLContext * createGLContext(); +#endif }; QT_END_NAMESPACE diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 60d4b17..cebb677 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -78,6 +78,7 @@ SOURCES += qgl.cpp \ embedded_lite { SOURCES += qgl_lite.cpp + HEADERS += qplatformglcontext_lite.h # If we have EGL, use the EGL implementation of QGLPixelBuffer, otherwise we just provide # a stubbed out one. PBuffers aren't too interesting anyway. diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 7fcf390..1e522d6 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1582,7 +1582,9 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) # endif vi = 0; #endif -#if defined(QT_OPENGL_ES) +#if defined(Q_WS_LITE) + platformContext = 0; +#elif defined(QT_OPENGL_ES) ownsEglContext = false; eglContext = 0; eglSurface = EGL_NO_SURFACE; diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp index 40417b1..a1d9bb8 100644 --- a/src/opengl/qgl_lite.cpp +++ b/src/opengl/qgl_lite.cpp @@ -39,35 +39,33 @@ ** ****************************************************************************/ +#include +#include +#include + +#include + #include "qgl.h" #include "qgl_p.h" +#include "qplatformglcontext_lite.h" -#include "qmap.h" -#include "qapplication.h" -#include "qcolormap.h" -#include "qdesktopwidget.h" -#include "qpixmap.h" -#include "qhash.h" -#include "qlibrary.h" -#include "qdebug.h" -#include QT_BEGIN_NAMESPACE bool QGLFormat::hasOpenGL() { - return true; // IMPLEMENT ME PROPERLY! + return QApplicationPrivate::platformIntegration()->hasOpenGL(); } - - bool QGLContext::chooseContext(const QGLContext* shareContext) { - // IMPLEMENT ME + Q_D(QGLContext); + d->platformContext = QApplicationPrivate::platformIntegration()->createGLContext(); + d->platformContext->create(d->paintDevice, d->glFormat, shareContext ? shareContext->d_func()->platformContext : 0); + return false; } - void QGLContext::reset() { Q_D(QGLContext); @@ -76,7 +74,10 @@ void QGLContext::reset() d->cleanup(); doneCurrent(); - // IMPLEMENT ME + if (d->platformContext) { + delete d->platformContext; + d->platformContext = 0; + } d->crWin = false; d->sharing = false; @@ -86,46 +87,70 @@ void QGLContext::reset() QGLContextGroup::removeShare(this); } - void QGLContext::makeCurrent() { - // IMPLEMENT ME + Q_D(QGLContext); + d->platformContext->makeCurrent(); } void QGLContext::doneCurrent() { - // IMPLEMENT ME + Q_D(QGLContext); + d->platformContext->doneCurrent(); } - void QGLContext::swapBuffers() const { - // IMPLEMENT ME -} - -void *QGLContext::getProcAddress(const QString &proc) const -{ - // IMPLEMENT ME + Q_D(const QGLContext); + d->platformContext->swapBuffers(); } -void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) +void *QGLContext::getProcAddress(const QString &procName) const { - // IMPLEMENT ME + Q_D(const QGLContext); + return d->platformContext->getProcAddress(procName); } - void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, bool deleteOldContext) { - // IMPLEMENT ME -} + Q_D(QGLWidget); + if (context == 0) { + qWarning("QGLWidget::setContext: Cannot set null context"); + return; + } + if (!context->deviceIsPixmap() && context->device() != this) { + qWarning("QGLWidget::setContext: Context must refer to this widget"); + return; + } + if (d->glcx) + d->glcx->doneCurrent(); + QGLContext* oldcx = d->glcx; + d->glcx = context; + // If the application has set WA_TranslucentBackground and not explicitly set + // the alpha buffer size to zero, modify the format so it have an alpha channel + QGLFormat& fmt = d->glcx->d_func()->glFormat; + if (testAttribute(Qt::WA_TranslucentBackground) && fmt.alphaBufferSize() == -1) + fmt.setAlphaBufferSize(1); + + bool success = false; + if (!d->glcx->isValid()) + success = !d->glcx->create(shareContext ? shareContext : oldcx); + + if (deleteOldContext) + delete oldcx; +} +void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) +{ + initContext(context, shareWidget); +} bool QGLFormat::hasOpenGLOverlays() { diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index a4d5cb7..f53b3e2 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -68,6 +68,10 @@ #include #endif +#if defined(Q_WS_LITE) +#include +#endif + QT_BEGIN_NAMESPACE class QGLContext; @@ -344,7 +348,9 @@ public: HBITMAP hbitmap; HDC hbitmap_hdc; #endif -#if defined(QT_OPENGL_ES) +#if defined(Q_WS_LITE) + QPlatformGLContext *platformContext; +#elif defined(QT_OPENGL_ES) bool ownsEglContext; QEglContext *eglContext; EGLSurface eglSurface; diff --git a/src/opengl/qplatformglcontext_lite.h b/src/opengl/qplatformglcontext_lite.h new file mode 100644 index 0000000..19a2074 --- /dev/null +++ b/src/opengl/qplatformglcontext_lite.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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$ +** +****************************************************************************/ + +#ifndef QPLATFORM_GL_CONTEXT_H +#define QPLATFORM_GL_CONTEXT_H + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QPlatformGLContext +{ +public: + QPlatformGLContext(); + virtual ~QPlatformGLContext(); + + virtual bool create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext) = 0; + + virtual void makeCurrent() = 0; + virtual void doneCurrent() = 0; + virtual void swapBuffers() = 0; + virtual void* getProcAddress(const QString& procName) = 0; + +}; + + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QPLATFORM_GL_INTEGRATION_P_H -- cgit v0.12 From c13076a30e5ae3d0f6795261ad00ca1eb73ad0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 7 Apr 2010 16:13:19 +0200 Subject: Added QPlatformWindow --- src/gui/kernel/kernel.pri | 4 +- src/gui/kernel/qplatformintegration_lite.h | 2 +- src/gui/kernel/qplatformwindow_lite.cpp | 72 +++++++++++++++++++ src/gui/kernel/qplatformwindow_lite.h | 79 +++++++++++++++++++++ src/gui/kernel/qwidget.cpp | 38 ++++++++++ src/gui/kernel/qwidget.h | 6 ++ src/gui/kernel/qwidget_lite.cpp | 82 +++++++++++----------- src/gui/kernel/qwidget_p.h | 5 ++ src/gui/painting/painting.pri | 2 +- src/gui/painting/qbackingstore.cpp | 16 ++++- src/gui/painting/qgraphicssystem_lite.cpp | 3 +- src/gui/painting/qwindowsurface.cpp | 53 +++++--------- src/gui/painting/qwindowsurface_p.h | 16 ++--- .../minimal/qplatformintegration_minimal.cpp | 7 +- .../minimal/qplatformintegration_minimal.h | 2 +- .../platforms/minimal/qwindowsurface_minimal.cpp | 8 +-- .../platforms/minimal/qwindowsurface_minimal.h | 4 +- src/plugins/plugins.pro | 2 +- 18 files changed, 298 insertions(+), 103 deletions(-) create mode 100644 src/gui/kernel/qplatformwindow_lite.cpp create mode 100644 src/gui/kernel/qplatformwindow_lite.h diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index cf5ec92..049637f 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -207,6 +207,7 @@ embedded_lite { kernel/qplatformscreen_lite.h \ kernel/qplatformintegrationfactory_lite_p.h \ kernel/qplatformintegrationplugin_lite.h \ + kernel/qplatformwindow_lite.h SOURCES += \ kernel/qapplication_lite.cpp \ @@ -224,7 +225,8 @@ embedded_lite { kernel/qplatformintegration_lite.cpp \ kernel/qplatformscreen_lite.cpp \ kernel/qplatformintegrationfactory_lite.cpp \ - kernel/qplatformintegrationplugin_lite.cpp + kernel/qplatformintegrationplugin_lite.cpp \ + kernel/qplatformwindow_lite.cpp contains(QT_CONFIG, glib) { SOURCES += \ diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h index 9125bd1..389dcfb 100644 --- a/src/gui/kernel/qplatformintegration_lite.h +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -62,7 +62,7 @@ public: // GraphicsSystem functions virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; - virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0; + virtual void createWindowAndSurface(QPlatformWindow **window, QWindowSurface **surface, QWidget *widget, WId winId = 0) const = 0; virtual QBlittable *createBlittable(const QSize &size) const; // Window System functions diff --git a/src/gui/kernel/qplatformwindow_lite.cpp b/src/gui/kernel/qplatformwindow_lite.cpp new file mode 100644 index 0000000..ff1bf48 --- /dev/null +++ b/src/gui/kernel/qplatformwindow_lite.cpp @@ -0,0 +1,72 @@ +#include "qplatformwindow_lite.h" + +#include + +class QPlatformWindowPrivate +{ + QWidget *tlw; + QRect rect; + friend class QPlatformWindow; +}; + +QPlatformWindow::QPlatformWindow(QWidget *tlw) + : d_ptr(new QPlatformWindowPrivate) +{ + Q_D(QPlatformWindow); + d->tlw = tlw; + tlw->setPlatformWindow(this); +} + +QPlatformWindow::~QPlatformWindow() +{ +} + +QWidget *QPlatformWindow::widget() const +{ + Q_D(const QPlatformWindow); + return d->tlw; +} + +void QPlatformWindow::setGeometry(const QRect &rect) +{ + Q_D(QPlatformWindow); + d->rect = rect; +} + +QRect QPlatformWindow::geometry() const +{ + Q_D(const QPlatformWindow); + return d->rect; +} + +/*! +Reimplemented in subclasses to show the surface if \a visible is \c true, and hide it if \a visible is \c false. +*/ +void QPlatformWindow::setVisible(bool visible) +{ + Q_UNUSED(visible); +} +/*! +Requests setting the window flags of this surface to \a type. Returns the actual flags set. +*/ +Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags) +{ + Q_UNUSED(flags); + return Qt::Window; +} + +/*! + Returns the effective window flags for this surface. +*/ +Qt::WindowFlags QPlatformWindow::windowFlags() const +{ + return Qt::Window; +} + +WId QPlatformWindow::winId() const { return WId(0); } + +void QPlatformWindow::setWindowTitle(const QString &) {} + +void QPlatformWindow::raise() { qWarning("This plugin does not support raise()"); } + +void QPlatformWindow::lower() { qWarning("This plugin does not support lower()"); } diff --git a/src/gui/kernel/qplatformwindow_lite.h b/src/gui/kernel/qplatformwindow_lite.h new file mode 100644 index 0000000..3fa97b5 --- /dev/null +++ b/src/gui/kernel/qplatformwindow_lite.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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 QPLATFORMWINDOW_H +#define QPLATFORMWINDOW_H + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +#include + +class QPlatformWindowPrivate; + +class Q_GUI_EXPORT QPlatformWindow +{ + Q_DECLARE_PRIVATE(QPlatformWindow); +public: + QPlatformWindow(QWidget *tlw); + virtual ~QPlatformWindow(); + + QWidget *widget() const; + virtual void setGeometry(const QRect &rect); + virtual QRect geometry() const; + + virtual void setVisible(bool visible); + virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); + virtual Qt::WindowFlags windowFlags() const; + virtual WId winId() const; + + virtual void setWindowTitle(const QString &); + virtual void raise(); + virtual void lower(); + +protected: + QScopedPointer d_ptr; +}; + +QT_END_NAMESPACE + +QT_END_HEADER +#endif //QPLATFORMWINDOW_H diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 3ca7591..4bcec93 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11836,6 +11836,44 @@ QWindowSurface *QWidget::windowSurface() const return bs ? bs->windowSurface : 0; } +/*! + \preliminary + + Sets the window to be the \a window specified. + The QWidget takes ownership of the \a surface. +*/ +void QWidget::setPlatformWindow(QPlatformWindow *window) +{ +#ifndef Q_BACKINGSTORE_SUBSURFACES + if (!isTopLevel()) + return; +#endif + + Q_D(QWidget); + + QTLWExtra *topData = d->topData(); + if (topData->platformWindow == window) + return; + + delete topData->platformWindow; + topData->platformWindow = window; +} + +/*! + \preliminary + + Returns the QPlatformWindow this widget will be drawn into. +*/ +QPlatformWindow *QWidget::platformWindow() const +{ + Q_D(const QWidget); + QTLWExtra *extra = d->maybeTopData(); + if (extra && extra->platformWindow) + return extra->platformWindow; + + return 0; +} + void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const { if (left) diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index e12148b..7dff703 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -94,6 +94,7 @@ class QHideEvent; class QInputContext; class QIcon; class QWindowSurface; +class QPlatformWindow; class QLocale; class QGraphicsProxyWidget; class QGraphicsEffect; @@ -625,6 +626,11 @@ public: void setWindowSurface(QWindowSurface *surface); QWindowSurface *windowSurface() const; +#if defined(Q_WS_LITE) + void setPlatformWindow(QPlatformWindow *window); + QPlatformWindow *platformWindow() const; +#endif + Q_SIGNALS: void customContextMenuRequested(const QPoint &pos); diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index add5592..7915d7f 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -39,26 +39,28 @@ ** ****************************************************************************/ -#include "qwidget.h" -#include "qevent.h" -#include "qapplication.h" -#include "private/qbackingstore_p.h" -#include "private/qwidget_p.h" -#include "private/qgraphicssystem_p.h" -#include "private/qapplication_p.h" -#include "qdesktopwidget.h" - -#include +#include "QtGui/qwidget.h" +#include "QtGui/qevent.h" +#include "QtGui/qapplication.h" +#include "QtGui/private/qbackingstore_p.h" +#include "QtGui/private/qwidget_p.h" +#include "QtGui/private/qgraphicssystem_p.h" +#include "QtGui/private/qapplication_p.h" +#include "QtGui/qdesktopwidget.h" +#include "QtGui/qplatformwindow_lite.h" + +#include QT_BEGIN_NAMESPACE static QPlatformScreen *qt_screenForWidget(const QWidget *w); -void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool /*destroyOldWindow*/) +void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) { Q_Q(QWidget); Q_UNUSED(window); Q_UNUSED(initializeWindow); + Q_UNUSED(destroyOldWindow); // XXX Qt::WindowFlags flags = data.window_flags; @@ -67,15 +69,16 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool /*destro return; // we only care about real toplevels QWindowSurface *surface = q->windowSurface(); + QPlatformWindow *platformWindow = q->platformWindow(); - if (!surface) - surface = createDefaultWindowSurface(); - + if (!surface) { + QApplicationPrivate::platformIntegration()->createWindowAndSurface(&platformWindow,&surface,q); + } Q_ASSERT(surface); - data.window_flags = surface->setWindowFlags(data.window_flags); + data.window_flags = q->platformWindow()->setWindowFlags(data.window_flags); - setWinId(surface->winId()); + setWinId(q->platformWindow()->winId()); // qDebug() << "create_sys" << q << q->internalWinId(); } @@ -119,8 +122,8 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) if (f & Qt::Window) { //qDebug() << "setParent_sys" << q << newparent << hex << f; - if (QWindowSurface *surface = q->windowSurface()) - data.window_flags = surface->setWindowFlags(data.window_flags); + if (QPlatformWindow *window = q->platformWindow()) + data.window_flags = window->setWindowFlags(data.window_flags); } // XXX Reparenting child to toplevel or vice versa ### if ((f&Qt::Window) && !(oldFlags&Qt::Window)) { @@ -191,8 +194,8 @@ void QWidgetPrivate::setWindowTitle_sys(const QString &caption) if (!q->isWindow()) return; - if (QWindowSurface *surface = q->windowSurface()) - surface->setWindowTitle(caption); + if (QPlatformWindow *window = q->platformWindow()) + window->setWindowTitle(caption); } @@ -299,9 +302,14 @@ void QWidgetPrivate::show_sys() if (QWindowSurface *surface = q->windowSurface()) { const QRect geomRect = q->geometry(); - if (surface->geometry() != geomRect) - surface->setGeometry(geomRect); - surface->setVisible(true); + const QRect windowRect = q->platformWindow()->geometry(); + if (windowRect != geomRect) { + q->platformWindow()->setGeometry(geomRect); + if (windowRect.size() != geomRect.size()) { + surface->resize(geomRect.size()); + } + } + q->platformWindow()->setVisible(true); } if (q->windowType() != Qt::Popup && q->windowType() != Qt::ToolTip && !(q->windowFlags() & Qt::X11BypassWindowManagerHint)) @@ -320,8 +328,8 @@ void QWidgetPrivate::hide_sys() } return; } - if (QWindowSurface *surface = q->windowSurface()) { - surface->setVisible(false); + if (QPlatformWindow *window = q->platformWindow()) { + window->setVisible(false); } //### we don't yet have proper focus event handling @@ -427,8 +435,7 @@ void QWidgetPrivate::raise_sys() { Q_Q(QWidget); if (q->isWindow()) { - QWindowSurface *surface = q->windowSurface(); - surface->raise(); + q->platformWindow()->raise(); } } @@ -437,8 +444,7 @@ void QWidgetPrivate::lower_sys() Q_Q(QWidget); if (q->isWindow()) { Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - QWindowSurface *surface = q->windowSurface(); - surface->lower(); + q->platformWindow()->lower(); } else if (QWidget *p = q->parentWidget()) { setDirtyOpaqueRegion(); p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); @@ -491,8 +497,11 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (q->isWindow()) { const QWidgetBackingStore *bs = maybeBackingStore(); - if (bs->windowSurface) - bs->windowSurface->setGeometry(q->frameGeometry()); + if (bs->windowSurface) { + q->platformWindow()->setGeometry(q->frameGeometry()); + if (isResize) + bs->windowSurface->resize(r.size()); + } } else { if (isMove && !isResize) moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y()); @@ -653,16 +662,7 @@ QPaintEngine *QWidget::paintEngine() const QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys() { - Q_Q(QWidget); - if (q->windowType() == Qt::Desktop) - return 0; - q->ensurePolished(); - - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return 0; - - return gs->createWindowSurface(q); + qFatal("CreateDefaultWindowSurface_sys should not be used on lighthouse"); } void QWidgetPrivate::setModal_sys() diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 0f34ae0..4ca493e 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -102,6 +102,9 @@ class QWSManager; #if defined(Q_WS_MAC) class QCoreGraphicsPaintEnginePrivate; #endif +#if defined(Q_WS_LITE) +class QPlatformWindow; +#endif class QPaintEngine; class QPixmap; class QWidgetBackingStore; @@ -176,6 +179,8 @@ struct QTLWExtra { #endif #elif defined(Q_OS_SYMBIAN) uint inExpose : 1; // Prevents drawing recursion +#elif defined(Q_WS_LITE) + QPlatformWindow *platformWindow; #endif }; diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index c4e8f7a..972bac2 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -117,7 +117,7 @@ embedded { SOURCES += \ painting/qgraphicssystem_qws.cpp \ -} else { +} else: if(!embedded_lite) { HEADERS += \ painting/qgraphicssystem_raster_p.h \ painting/qgraphicssystemfactory_p.h \ diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index f2cd7e6..30c042e 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -286,7 +286,11 @@ bool QWidgetBackingStore::bltRect(const QRect &rect, int dx, int dy, QWidget *wi void QWidgetBackingStore::releaseBuffer() { if (windowSurface) +#if defined(Q_WS_LITE) + windowSurface->resize(QSize()); +#else windowSurface->setGeometry(QRect()); +#endif #ifdef Q_BACKINGSTORE_SUBSURFACES for (int i = 0; i < subSurfaces.size(); ++i) subSurfaces.at(i)->setGeometry(QRect()); @@ -415,6 +419,7 @@ void QWidgetBackingStore::endPaint(const QRegion &cleaned, QWindowSurface *windo QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const { const bool widgetDirty = widget && widget != tlw; +#if !defined(Q_WS_LITE) const QRect tlwRect(topLevelRect()); const QRect surfaceGeometry(windowSurface->geometry()); if (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size()) { @@ -426,6 +431,7 @@ QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const } return QRect(QPoint(), tlwRect.size()); } +#endif // Calculate the region that needs repaint. QRegion r(dirty); @@ -467,7 +473,11 @@ QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const QRegion QWidgetBackingStore::staticContents(QWidget *parent, const QRect &withinClipRect) const { if (!parent && tlw->testAttribute(Qt::WA_StaticContents)) { +#if defined(Q_WS_LITE) + const QSize surfaceGeometry(windowSurface->size()); +#else const QRect surfaceGeometry(windowSurface->geometry()); +#endif QRect surfaceRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height()); if (!withinClipRect.isEmpty()) surfaceRect &= withinClipRect; @@ -1144,11 +1154,12 @@ void QWidgetBackingStore::sync() return; } - const bool inTopLevelResize = tlwExtra->inTopLevelResize; const bool updatesDisabled = !tlw->updatesEnabled(); + bool repaintAllWidgets = false; +#if !defined(Q_WS_LITE) + const bool inTopLevelResize = tlwExtra->inTopLevelResize; const QRect tlwRect(topLevelRect()); const QRect surfaceGeometry(windowSurface->geometry()); - bool repaintAllWidgets = false; if (inTopLevelResize || surfaceGeometry != tlwRect) { if ((inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) { @@ -1171,6 +1182,7 @@ void QWidgetBackingStore::sync() } windowSurface->setGeometry(tlwRect); } +#endif if (updatesDisabled) return; diff --git a/src/gui/painting/qgraphicssystem_lite.cpp b/src/gui/painting/qgraphicssystem_lite.cpp index 42e7238..a62abbb 100644 --- a/src/gui/painting/qgraphicssystem_lite.cpp +++ b/src/gui/painting/qgraphicssystem_lite.cpp @@ -51,7 +51,8 @@ QPixmapData *QLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) QWindowSurface *QLiteGraphicsSystem::createWindowSurface(QWidget *widget) const { - return QApplicationPrivate::platformIntegration()->createWindowSurface(widget); + qFatal("should not use QLiteGraphicsSystem::createWindowSurface"); + return 0; } QBlittable *QLiteGraphicsSystem::createBlittable(const QSize &size) const diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp index 34c2936..20594c4 100644 --- a/src/gui/painting/qwindowsurface.cpp +++ b/src/gui/painting/qwindowsurface.cpp @@ -52,7 +52,11 @@ public: QWindowSurfacePrivate(QWidget *w) : window(w), staticContentsSupport(false) {} QWidget *window; +#if !defined(Q_WS_LITE) QRect geometry; +#else + QSize size; +#endif //Q_WS_LITE QRegion staticContents; QList bufferImages; bool staticContentsSupport; @@ -144,6 +148,7 @@ void QWindowSurface::endPaint(const QRegion &) d_ptr->bufferImages.clear(); } +#if !defined(Q_WS_LITE) /*! Sets the currently allocated area to be the given \a rect. @@ -164,6 +169,17 @@ QRect QWindowSurface::geometry() const { return d_ptr->geometry; } +#else +void QWindowSurface::resize(const QSize &size) +{ + d_ptr->size = size; +} + +QSize QWindowSurface::size() const +{ + return d_ptr->size; +} +#endif //Q_WS_LITE /*! Scrolls the given \a area \a dx pixels to the right and \a dy @@ -349,41 +365,4 @@ void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) } } - -#ifdef Q_WS_LITE -/*! -Requests setting the window flags of this surface to \a type. Returns the actual flags set. -*/ -Qt::WindowFlags QWindowSurface::setWindowFlags(Qt::WindowFlags type) -{ - Q_UNUSED(type); - qDebug() << "QWindowSurface::setWindowFlags" << hex << type; - return Qt::Window; -} - -/*! - Returns the effective window flags for this surface. -*/ -Qt::WindowFlags QWindowSurface::windowFlags() const -{ - return Qt::Window; -} - -/*! -Reimplemented in subclasses to show the surface if \a visible is \c true, and hide it if \a visible is \c false. -*/ - -void QWindowSurface::setVisible(bool visible) -{ - Q_UNUSED(visible); -} - - -WId QWindowSurface::winId() const -{ - return WId(0); -} - -#endif - QT_END_NAMESPACE diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h index 5930704..3a14b0f 100644 --- a/src/gui/painting/qwindowsurface_p.h +++ b/src/gui/painting/qwindowsurface_p.h @@ -63,6 +63,7 @@ class QRect; class QPoint; class QImage; class QWindowSurfacePrivate; +class QPlatformWindow; class Q_GUI_EXPORT QWindowSurface { @@ -75,8 +76,13 @@ public: virtual QPaintDevice *paintDevice() = 0; virtual void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) = 0; +#if !defined(Q_WS_LITE) virtual void setGeometry(const QRect &rect); QRect geometry() const; +#else + virtual void resize(const QSize &size); + QSize size() const; +#endif virtual bool scroll(const QRegion &area, int dx, int dy); @@ -89,16 +95,6 @@ public: virtual QPoint offset(const QWidget *widget) const; inline QRect rect(const QWidget *widget) const; -#ifdef Q_WS_LITE - virtual void setVisible(bool visible); - virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); - virtual Qt::WindowFlags windowFlags() const; - virtual WId winId() const; - - virtual void setWindowTitle(const QString &) {} - virtual void raise() { qWarning("This plugin does not support raise()"); } - virtual void lower() { qWarning("This plugin does not support lower()"); } -#endif bool hasStaticContentsSupport() const; void setStaticContents(const QRegion ®ion); diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp index 693e0c3..2f03127 100644 --- a/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp +++ b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp @@ -2,6 +2,7 @@ #include "qwindowsurface_minimal.h" #include +#include QMinimalIntegration::QMinimalIntegration() { @@ -19,7 +20,9 @@ QPixmapData *QMinimalIntegration::createPixmapData(QPixmapData::PixelType type) { return new QRasterPixmapData(type); } -QWindowSurface *QMinimalIntegration::createWindowSurface(QWidget *widget) const +void QMinimalIntegration::createWindowAndSurface(QPlatformWindow**window, QWindowSurface**surface, QWidget *widget, WId winId) const { - return new QMinimalWindowSurface(widget); + qDebug() << "createWindow"; + *surface = new QMinimalWindowSurface(widget); + *window = new QPlatformWindow(widget); } diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.h b/src/plugins/platforms/minimal/qplatformintegration_minimal.h index d4eb78b..127c573 100644 --- a/src/plugins/platforms/minimal/qplatformintegration_minimal.h +++ b/src/plugins/platforms/minimal/qplatformintegration_minimal.h @@ -72,7 +72,7 @@ public: QMinimalIntegration(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; + void createWindowAndSurface(QPlatformWindow**window, QWindowSurface**surface, QWidget *widget, WId winId) const; QList screens() const { return mScreens; } diff --git a/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp b/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp index 0b2bdd2..2f8b1f0 100644 --- a/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp +++ b/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp @@ -73,13 +73,13 @@ void QMinimalWindowSurface::flush(QWidget *widget, const QRegion ®ion, const mImage.save(filename); } -void QMinimalWindowSurface::setGeometry(const QRect &rect) +void QMinimalWindowSurface::resize(const QSize &size) { //qDebug() << "QMinimalWindowSurface::setGeometry:" << (long)this << rect; - QWindowSurface::setGeometry(rect); + QWindowSurface::resize(size); QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format(); - if (mImage.size() != rect.size()) - mImage = QImage(rect.size(), format); + if (mImage.size() != size) + mImage = QImage(size, format); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimal/qwindowsurface_minimal.h b/src/plugins/platforms/minimal/qwindowsurface_minimal.h index 959a731..96f989d 100644 --- a/src/plugins/platforms/minimal/qwindowsurface_minimal.h +++ b/src/plugins/platforms/minimal/qwindowsurface_minimal.h @@ -44,6 +44,8 @@ #include +#include + QT_BEGIN_NAMESPACE class QMinimalWindowSurface : public QWindowSurface @@ -54,7 +56,7 @@ public: QPaintDevice *paintDevice(); void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); + void resize(const QSize &size); private: QImage mImage; diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 730fdc5..73ab3e9 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -6,7 +6,7 @@ unix:!symbian { } else { SUBDIRS *= codecs } -!embedded:SUBDIRS *= graphicssystems +!embedded:!embedded-lite:SUBDIRS *= graphicssystems embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers !win32:!embedded:!mac:!symbian:SUBDIRS *= inputmethods symbian:SUBDIRS += s60 -- cgit v0.12 From a914500cbccc4569d7f681eaa0f9453413fc988c Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 8 Apr 2010 08:35:49 +0200 Subject: Fixup QPlatformGLContext --- src/opengl/qgl_lite.cpp | 15 +++++++++++++-- src/opengl/qplatformglcontext_lite.h | 4 +++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp index a1d9bb8..db1077d 100644 --- a/src/opengl/qgl_lite.cpp +++ b/src/opengl/qgl_lite.cpp @@ -52,6 +52,15 @@ QT_BEGIN_NAMESPACE +QPlatformGLContext::QPlatformGLContext() +{ +} + +QPlatformGLContext::~QPlatformGLContext() +{ +} + + bool QGLFormat::hasOpenGL() { return QApplicationPrivate::platformIntegration()->hasOpenGL(); @@ -61,9 +70,9 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) { Q_D(QGLContext); d->platformContext = QApplicationPrivate::platformIntegration()->createGLContext(); - d->platformContext->create(d->paintDevice, d->glFormat, shareContext ? shareContext->d_func()->platformContext : 0); + d->valid = d->platformContext->create(d->paintDevice, d->glFormat, shareContext ? shareContext->d_func()->platformContext : 0); - return false; + return d->valid; } void QGLContext::reset() @@ -91,12 +100,14 @@ void QGLContext::makeCurrent() { Q_D(QGLContext); d->platformContext->makeCurrent(); + QGLContextPrivate::setCurrentContext(this); } void QGLContext::doneCurrent() { Q_D(QGLContext); d->platformContext->doneCurrent(); + QGLContextPrivate::setCurrentContext(0); } void QGLContext::swapBuffers() const diff --git a/src/opengl/qplatformglcontext_lite.h b/src/opengl/qplatformglcontext_lite.h index 19a2074..10c05f6 100644 --- a/src/opengl/qplatformglcontext_lite.h +++ b/src/opengl/qplatformglcontext_lite.h @@ -42,11 +42,13 @@ #ifndef QPLATFORM_GL_CONTEXT_H #define QPLATFORM_GL_CONTEXT_H +#include + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class QPlatformGLContext +class Q_OPENGL_EXPORT QPlatformGLContext { public: QPlatformGLContext(); -- cgit v0.12 From 0e342cd341f8d71b41de89340cbbf455694becc9 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 8 Apr 2010 08:36:49 +0200 Subject: Implement OpenGL support for testlite plugin using GLX Note: Doesn't actually work yet. ;-) --- src/plugins/platforms/testlite/qglxglcontext.cpp | 148 +++++++++++++++++++++ src/plugins/platforms/testlite/qglxglcontext.h | 73 ++++++++++ .../testlite/qplatformintegration_testlite.cpp | 18 ++- .../testlite/qplatformintegration_testlite.h | 5 + src/plugins/platforms/testlite/testlite.pro | 5 + 5 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 src/plugins/platforms/testlite/qglxglcontext.cpp create mode 100644 src/plugins/platforms/testlite/qglxglcontext.h diff --git a/src/plugins/platforms/testlite/qglxglcontext.cpp b/src/plugins/platforms/testlite/qglxglcontext.cpp new file mode 100644 index 0000000..0739567 --- /dev/null +++ b/src/plugins/platforms/testlite/qglxglcontext.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "x11util.h" +#include "qglxglcontext.h" +#include + +#include + +#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) +#include +#endif + + +QT_BEGIN_NAMESPACE + +QGLXGLContext::QGLXGLContext(Display *xdpy) + : QPlatformGLContext() + , m_display(xdpy) + , m_context(0) + , m_widget(0) +{ +} + +QGLXGLContext::~QGLXGLContext() +{ + if (m_context) + glXDestroyContext(m_display, m_context); +} + +bool QGLXGLContext::create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext) +{ + if (device->devType() != QInternal::Widget) { + qWarning("Creating a GL context is only supported on QWidgets"); + return false; + } + + m_widget = static_cast(device); + if (!m_widget->isTopLevel()) { + qWarning("Creating a GL context is only supported on top-level QWidgets"); + return false; + } + + // Get the XVisualInfo for the window: +// XWindowAttributes windowAttribs; +// XGetWindowAttributes(m_display, m_widget->winId(), &windowAttribs); + XVisualInfo visualInfoTemplate; + visualInfoTemplate.visualid = 33; //XVisualIDFromVisual(windowAttribs.visual); + XVisualInfo *visualInfo; + int matchingCount = 0; + visualInfo = XGetVisualInfo(m_display, VisualIDMask, &visualInfoTemplate, &matchingCount); + + qDebug("Creating a GLX context for visual ID %d", visualInfoTemplate.visualid); + + m_context = glXCreateContext(m_display, visualInfo, 0, True); + + return true; +} + +void QGLXGLContext::makeCurrent() +{ + Window win = m_widget->winId(); + qDebug("QGLXGLContext::makeCurrent(window=0x%x, ctx=0x%x)", win, m_context); + + glXMakeCurrent(m_display, win, m_context); +} + +void QGLXGLContext::doneCurrent() +{ + glXMakeCurrent(m_display, 0, 0); +} + +void QGLXGLContext::swapBuffers() +{ + glXSwapBuffers(m_display, m_widget->winId()); +} + +void* QGLXGLContext::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 glxExt = QByteArray(glXGetClientString(m_display, GLX_EXTENSIONS)).split(' '); + if (glxExt.contains("GLX_ARB_get_proc_address")) { +#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) + void *handle = dlopen(NULL, RTLD_LAZY); + 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()); + glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB"); + } + } + resolved = true; + } + if (!glXGetProcAddressARB) + return 0; + return glXGetProcAddressARB(reinterpret_cast(procName.toLatin1().data())); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qglxglcontext.h b/src/plugins/platforms/testlite/qglxglcontext.h new file mode 100644 index 0000000..54e5c2f --- /dev/null +++ b/src/plugins/platforms/testlite/qglxglcontext.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef Q_GLX_CONTEXT_H +#define Q_GLX_CONTEXT_H + +#include +#include "x11util.h" +#include + +QT_BEGIN_NAMESPACE + +class QGLXGLContext : public QPlatformGLContext +{ +public: + QGLXGLContext(Display* xdpy); + ~QGLXGLContext(); + + bool create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString& procName); + +private: + Display *m_display; + GLXContext m_context; + QWidget *m_widget; +}; + + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp index 6811e2e..6776e0c 100644 --- a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp +++ b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp @@ -46,9 +46,13 @@ #include - #include "x11util.h" +#ifndef QT_NO_OPENGL +#include +#include "qglxglcontext.h" +#endif + QT_BEGIN_NAMESPACE class MyCursor : QGraphicsSystemCursor @@ -116,6 +120,18 @@ QPixmap QTestLiteIntegration::grabWindow(WId window, int x, int y, int width, in return QPixmap::fromImage(img); } +#ifndef QT_NO_OPENGL +bool QTestLiteIntegration::hasOpenGL() const +{ + return glXQueryExtension(xd->display, 0, 0) != 0; +} + +QPlatformGLContext * QTestLiteIntegration::createGLContext() +{ + return new QGLXGLContext(xd->display); +} + +#endif // QT_NO_OPENGL QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qplatformintegration_testlite.h b/src/plugins/platforms/testlite/qplatformintegration_testlite.h index c540c48..8dbbc50 100644 --- a/src/plugins/platforms/testlite/qplatformintegration_testlite.h +++ b/src/plugins/platforms/testlite/qplatformintegration_testlite.h @@ -80,6 +80,11 @@ public: QList screens() const { return mScreens; } +#ifndef QT_NO_OPENGL + bool hasOpenGL() const; + QPlatformGLContext * createGLContext(); +#endif + MyDisplay *xd; private: diff --git a/src/plugins/platforms/testlite/testlite.pro b/src/plugins/platforms/testlite/testlite.pro index 442dd68..5f7eb2a 100644 --- a/src/plugins/platforms/testlite/testlite.pro +++ b/src/plugins/platforms/testlite/testlite.pro @@ -12,6 +12,11 @@ SOURCES += x11util.cpp LIBS += -lX11 -lXext +contains(QT_CONFIG, opengl) { + QT += opengl + HEADERS += qglxglcontext.h + SOURCES += qglxglcontext.cpp +} target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems INSTALLS += target -- cgit v0.12 From d6cf18d036df1ecead4c8471944880c7f9a414f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 8 Apr 2010 09:58:08 +0200 Subject: QPlatformWindow refactoring and ported the directfb plugin to use QPlatformWindow --- src/gui/kernel/qplatformintegration_lite.h | 3 +- src/gui/kernel/qplatformwindow_lite.cpp | 6 + src/gui/kernel/qplatformwindow_lite.h | 12 +- src/gui/kernel/qwidget.cpp | 6 + src/gui/kernel/qwidget_lite.cpp | 15 +- src/plugins/platforms/directfb/qdirectfbinput.cpp | 13 +- src/plugins/platforms/directfb/qdirectfbinput.h | 4 +- src/plugins/platforms/directfb/qdirectfbwindow.cpp | 157 +++++++++++++++++++++ src/plugins/platforms/directfb/qdirectfbwindow.h | 73 ++++++++++ .../directfb/qplatformintegration_directfb.cpp | 11 +- .../directfb/qplatformintegration_directfb.h | 3 +- .../platforms/directfb/qwindowsurface_directfb.cpp | 114 ++------------- .../platforms/directfb/qwindowsurface_directfb.h | 15 +- src/plugins/platforms/minimal/minimal.pro | 2 +- .../minimal/qplatformintegration_minimal.cpp | 14 +- .../minimal/qplatformintegration_minimal.h | 3 +- 16 files changed, 309 insertions(+), 142 deletions(-) create mode 100644 src/plugins/platforms/directfb/qdirectfbwindow.cpp create mode 100644 src/plugins/platforms/directfb/qdirectfbwindow.h diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h index 389dcfb..b13260e 100644 --- a/src/gui/kernel/qplatformintegration_lite.h +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -62,7 +62,8 @@ public: // GraphicsSystem functions virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; - virtual void createWindowAndSurface(QPlatformWindow **window, QWindowSurface **surface, QWidget *widget, WId winId = 0) const = 0; + virtual QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const = 0; + virtual QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const = 0; virtual QBlittable *createBlittable(const QSize &size) const; // Window System functions diff --git a/src/gui/kernel/qplatformwindow_lite.cpp b/src/gui/kernel/qplatformwindow_lite.cpp index ff1bf48..c8a3ed5 100644 --- a/src/gui/kernel/qplatformwindow_lite.cpp +++ b/src/gui/kernel/qplatformwindow_lite.cpp @@ -70,3 +70,9 @@ void QPlatformWindow::setWindowTitle(const QString &) {} void QPlatformWindow::raise() { qWarning("This plugin does not support raise()"); } void QPlatformWindow::lower() { qWarning("This plugin does not support lower()"); } + +void QPlatformWindow::setOpacity(qreal level) +{ + Q_UNUSED(level); + qWarning("This plugin does not support setting window opacity"); +} diff --git a/src/gui/kernel/qplatformwindow_lite.h b/src/gui/kernel/qplatformwindow_lite.h index 3fa97b5..8771cfe 100644 --- a/src/gui/kernel/qplatformwindow_lite.h +++ b/src/gui/kernel/qplatformwindow_lite.h @@ -41,13 +41,18 @@ #ifndef QPLATFORMWINDOW_H #define QPLATFORMWINDOW_H -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE #include +#include +#include +#include class QPlatformWindowPrivate; +class QWidget; + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE class Q_GUI_EXPORT QPlatformWindow { @@ -69,6 +74,7 @@ public: virtual void raise(); virtual void lower(); + virtual void setOpacity(qreal level); protected: QScopedPointer d_ptr; }; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 4bcec93..7eaf03c 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -74,6 +74,9 @@ # include "qpaintengine.h" // for PorterDuff # include "private/qwindowsurface_qws_p.h" #endif +#if defined(Q_WS_LITE) +#include "qplatformwindow_lite.h" +#endif #include "qpainter.h" #include "qtooltip.h" #include "qwhatsthis.h" @@ -1574,6 +1577,9 @@ void QWidgetPrivate::createTLExtra() static int count = 0; qDebug() << "tlextra" << ++count; #endif +#if defined(Q_WS_LITE) + x->platformWindow = 0; +#endif } } diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 7915d7f..cf93c5e 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -71,8 +71,13 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO QWindowSurface *surface = q->windowSurface(); QPlatformWindow *platformWindow = q->platformWindow(); + if (!platformWindow) { + platformWindow = QApplicationPrivate::platformIntegration()->createPlatformWindow(q); + } + Q_ASSERT(platformWindow); + if (!surface) { - QApplicationPrivate::platformIntegration()->createWindowAndSurface(&platformWindow,&surface,q); + surface = QApplicationPrivate::platformIntegration()->createWindowSurfaceForWindow(q,platformWindow->winId()); } Q_ASSERT(surface); @@ -102,8 +107,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) { Q_Q(QWidget); - - QWidget *oldParent = q->parentWidget(); +// QWidget *oldParent = q->parentWidget(); Qt::WindowFlags oldFlags = data.window_flags; if (parent != newparent) { QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? @@ -643,8 +647,8 @@ void QWidgetPrivate::updateFrameStrut() void QWidgetPrivate::setWindowOpacity_sys(qreal level) { - Q_UNUSED(level); - // XXX + Q_Q(QWidget); + q->platformWindow()->setOpacity(level); } void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect) @@ -663,6 +667,7 @@ QPaintEngine *QWidget::paintEngine() const QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys() { qFatal("CreateDefaultWindowSurface_sys should not be used on lighthouse"); + return 0; } void QWidgetPrivate::setModal_sys() diff --git a/src/plugins/platforms/directfb/qdirectfbinput.cpp b/src/plugins/platforms/directfb/qdirectfbinput.cpp index 74a38a4..90c3348 100644 --- a/src/plugins/platforms/directfb/qdirectfbinput.cpp +++ b/src/plugins/platforms/directfb/qdirectfbinput.cpp @@ -78,16 +78,13 @@ void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) window->AttachEventBuffer(window,eventBuffer); } -void QDirectFbInput::removeWindow(QWidget *tlw) +void QDirectFbInput::removeWindow(WId wId) { - DFBWindowID id = tlwMap.key(tlw,0); - if (id) { - IDirectFBWindow *window; - dfbDisplayLayer->GetWindow(dfbDisplayLayer,id, &window); + IDirectFBWindow *window; + dfbDisplayLayer->GetWindow(dfbDisplayLayer,wId, &window); - window->DetachEventBuffer(window,eventBuffer); - tlwMap.remove(id); - } + window->DetachEventBuffer(window,eventBuffer); + tlwMap.remove(wId); } void QDirectFbInput::handleEvents() diff --git a/src/plugins/platforms/directfb/qdirectfbinput.h b/src/plugins/platforms/directfb/qdirectfbinput.h index 31aa082..016e7f1 100644 --- a/src/plugins/platforms/directfb/qdirectfbinput.h +++ b/src/plugins/platforms/directfb/qdirectfbinput.h @@ -9,6 +9,8 @@ #include #include +#include + #include class InputSocketWaiter : public QThread @@ -35,7 +37,7 @@ class QDirectFbInput : public QObject public: static QDirectFbInput *instance(); void addWindow(DFBWindowID id, QWidget *tlw); - void removeWindow(QWidget *tlw); + void removeWindow(WId wId); public slots: void handleEvents(); diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.cpp b/src/plugins/platforms/directfb/qdirectfbwindow.cpp new file mode 100644 index 0000000..d88953e --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbwindow.cpp @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qdirectfbwindow.h" +#include "qdirectfbinput.h" + +#include + +#include + +QDirectFbWindow::QDirectFbWindow(QWidget *tlw) + : QPlatformWindow(tlw) +{ + IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); + DFBDisplayLayerConfig layerConfig; + layer->GetConfiguration(layer,&layerConfig); + + DFBWindowDescription description; + memset(&description,0,sizeof(DFBWindowDescription)); + description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS +#if DIRECTFB_MINOR_VERSION >= 1 + |DWDESC_OPTIONS +#endif + |DWDESC_CAPS); + description.width = tlw->rect().width(); + description.height = tlw->rect().height(); + description.posx = tlw->rect().x(); + description.posy = tlw->rect().y(); + + if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED) + description.surface_caps = DSCAPS_PREMULTIPLIED; + description.pixelformat = layerConfig.pixelformat; + +#if DIRECTFB_MINOR_VERSION >= 1 + description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); +#endif + description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL); + description.surface_caps = DSCAPS_PREMULTIPLIED; + + DFBResult result = layer->CreateWindow(layer,&description,&m_dfbWindow); + if (result != DFB_OK) { + DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); + } + + m_dfbWindow->SetOpacity(m_dfbWindow,0xff); + + DFBWindowID id; + m_dfbWindow->GetID(m_dfbWindow, &id); + QDirectFbInput::instance()->addWindow(id,tlw); +} + +QDirectFbWindow::~QDirectFbWindow() +{ + QDirectFbInput::instance()->removeWindow(winId()); + m_dfbWindow->Destroy(m_dfbWindow); +} + +void QDirectFbWindow::setGeometry(const QRect &rect) +{ + QPlatformWindow::setGeometry(rect); + m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), + rect.width(), rect.height()); + +} + +void QDirectFbWindow::setOpacity(qreal level) +{ + const quint8 windowOpacity = quint8(level * 0xff); + m_dfbWindow->SetOpacity(m_dfbWindow,windowOpacity); +} + +void QDirectFbWindow::setVisible(bool visible) +{ + if (visible) { + int x = geometry().x(); + int y = geometry().y(); + m_dfbWindow->MoveTo(m_dfbWindow,x,y); + } else { + IDirectFBDisplayLayer *displayLayer; + QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY,&displayLayer); + + DFBDisplayLayerConfig config; + displayLayer->GetConfiguration(displayLayer,&config); + m_dfbWindow->MoveTo(m_dfbWindow,config.width+1,config.height + 1); + } +} + +Qt::WindowFlags QDirectFbWindow::setWindowFlags(Qt::WindowFlags flags) +{ + switch (flags & Qt::WindowType_Mask) { + case Qt::ToolTip: { + DFBWindowOptions options; + m_dfbWindow->GetOptions(m_dfbWindow,&options); + options = DFBWindowOptions(options | DWOP_GHOST); + m_dfbWindow->SetOptions(m_dfbWindow,options); + break; } + default: + break; + } + + m_dfbWindow->SetStackingClass(m_dfbWindow, flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE); + return flags; +} + +void QDirectFbWindow::raise() +{ + m_dfbWindow->RaiseToTop(m_dfbWindow); +} + +void QDirectFbWindow::lower() +{ + m_dfbWindow->LowerToBottom(m_dfbWindow); +} + +WId QDirectFbWindow::winId() const +{ + DFBWindowID id; + m_dfbWindow->GetID(m_dfbWindow, &id); + return WId(id); +} diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.h b/src/plugins/platforms/directfb/qdirectfbwindow.h new file mode 100644 index 0000000..d5fd408 --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbwindow.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 QDIRECTFBWINDOW_H +#define QDIRECTFBWINDOW_H + +#include + +#include "qdirectfbconvenience.h" + +QT_BEGIN_NAMESPACE + +class QDirectFbWindow : public QPlatformWindow +{ +public: + QDirectFbWindow(QWidget *tlw); + ~QDirectFbWindow(); + + void setGeometry(const QRect &rect); + void setOpacity(qreal level); + + void setVisible(bool visible); + + Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); + void raise(); + void lower(); + WId winId() const; + +private: + IDirectFBWindow *m_dfbWindow; +}; + +QT_END_NAMESPACE + +#endif // QDIRECTFBWINDOW_H diff --git a/src/plugins/platforms/directfb/qplatformintegration_directfb.cpp b/src/plugins/platforms/directfb/qplatformintegration_directfb.cpp index c70bb64..5f428ef 100644 --- a/src/plugins/platforms/directfb/qplatformintegration_directfb.cpp +++ b/src/plugins/platforms/directfb/qplatformintegration_directfb.cpp @@ -44,6 +44,7 @@ #include "qblitter_directfb.h" #include "qdirectfbconvenience.h" #include "qdirectfbcursor.h" +#include "qdirectfbwindow.h" #include #include @@ -105,9 +106,15 @@ QPixmapData *QDirectFbIntegration::createPixmapData(QPixmapData::PixelType type) return new QBlittablePixmapData(type); } -QWindowSurface *QDirectFbIntegration::createWindowSurface(QWidget *widget) const +QPlatformWindow *QDirectFbIntegration::createPlatformWindow(QWidget *widget, WId winId) const { - return new QDirectFbWindowSurface (widget); + Q_UNUSED(winId); + return new QDirectFbWindow(widget); +} + +QWindowSurface *QDirectFbIntegration::createWindowSurfaceForWindow(QWidget *widget, WId winId) const +{ + return new QDirectFbWindowSurface(widget,winId); } QBlittable *QDirectFbIntegration::createBlittable(const QSize &size) const diff --git a/src/plugins/platforms/directfb/qplatformintegration_directfb.h b/src/plugins/platforms/directfb/qplatformintegration_directfb.h index f74a81d..a8489c0 100644 --- a/src/plugins/platforms/directfb/qplatformintegration_directfb.h +++ b/src/plugins/platforms/directfb/qplatformintegration_directfb.h @@ -82,7 +82,8 @@ public: QDirectFbIntegration(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; + QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const; QBlittable *createBlittable(const QSize &size) const; QList screens() const { return mScreens; } diff --git a/src/plugins/platforms/directfb/qwindowsurface_directfb.cpp b/src/plugins/platforms/directfb/qwindowsurface_directfb.cpp index afe34b7..e978cae 100644 --- a/src/plugins/platforms/directfb/qwindowsurface_directfb.cpp +++ b/src/plugins/platforms/directfb/qwindowsurface_directfb.cpp @@ -49,49 +49,19 @@ QT_BEGIN_NAMESPACE -QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window) - : QWindowSurface(window), m_pixmap(0), m_pmdata(0), - m_dfbWindow(0), m_dfbSurface(0) +QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window, WId wId) + : QWindowSurface(window), m_pixmap(0), m_pmdata(0), m_dfbSurface(0) { - window->setWindowSurface(this); IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); - DFBDisplayLayerConfig layerConfig; - layer->GetConfiguration(layer,&layerConfig); - - DFBWindowDescription description; - memset(&description,0,sizeof(DFBWindowDescription)); - description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS -#if DIRECTFB_MINOR_VERSION >= 1 - |DWDESC_OPTIONS -#endif - |DWDESC_CAPS); - description.width = window->rect().width(); - description.height = window->rect().height(); - description.posx = window->rect().x(); - description.posy = window->rect().y(); - - if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED) - description.surface_caps = DSCAPS_PREMULTIPLIED; - description.pixelformat = layerConfig.pixelformat; - -#if DIRECTFB_MINOR_VERSION >= 1 - description.options = DFBWindowOptions(DWOP_ALPHACHANNEL); -#endif - description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL); - description.surface_caps = DSCAPS_PREMULTIPLIED; - - DFBResult result = layer->CreateWindow(layer,&description,&m_dfbWindow); - if (result != DFB_OK) { - DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result); - } - DFBWindowID id; - m_dfbWindow->GetID(m_dfbWindow, &id); - QDirectFbInput::instance()->addWindow(id,window); + DFBWindowID id(wId); + IDirectFBWindow *dfbWindow; - m_dfbWindow->GetSurface(m_dfbWindow,&m_dfbSurface); + layer->GetWindow(layer,id,&dfbWindow); + dfbWindow->GetSurface(dfbWindow,&m_dfbSurface); +//WRONGSIZE QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect().size(), m_dfbSurface); m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); m_pmdata->setBlittable(blitter); @@ -100,8 +70,7 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window) QDirectFbWindowSurface::~QDirectFbWindowSurface() { - QDirectFbInput::instance()->removeWindow(this->window()); - m_dfbWindow->Destroy(m_dfbWindow); + } QPaintDevice *QDirectFbWindowSurface::paintDevice() @@ -111,11 +80,9 @@ QPaintDevice *QDirectFbWindowSurface::paintDevice() void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { + Q_UNUSED(widget); m_pmdata->blittable()->unlock(); - const quint8 windowOpacity = quint8(widget->windowOpacity() * 0xff); - m_dfbWindow->SetOpacity(m_dfbWindow,windowOpacity); - QVector rects = region.rects(); for (int i = 0 ; i < rects.size(); i++) { const QRect rect = rects.at(i); @@ -124,17 +91,13 @@ void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const } } -void QDirectFbWindowSurface::setGeometry(const QRect &rect) +void QDirectFbWindowSurface::resize(const QSize &size) { - m_pmdata->blittable()->unlock(); - - QWindowSurface::setGeometry(rect); - m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), - rect.width(), rect.height()); + QWindowSurface::resize(size); //Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable m_dfbSurface->AddRef(m_dfbSurface); - QDirectFbBlitter *blitter = new QDirectFbBlitter(rect.size(),m_dfbSurface); + QDirectFbBlitter *blitter = new QDirectFbBlitter(size,m_dfbSurface); m_pmdata->setBlittable(blitter); } @@ -175,57 +138,4 @@ void QDirectFbWindowSurface::endPaint(const QRegion ®ion) Q_UNUSED(region); } -void QDirectFbWindowSurface::setVisible(bool visible) -{ - m_pmdata->blittable()->unlock(); - - if (visible) { - int x = this->geometry().x(); - int y = this->geometry().y(); - m_dfbWindow->MoveTo(m_dfbWindow,x,y); - } else { - IDirectFBDisplayLayer *displayLayer; - QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY,&displayLayer); - - DFBDisplayLayerConfig config; - displayLayer->GetConfiguration(displayLayer,&config); - m_dfbWindow->MoveTo(m_dfbWindow,config.width+1,config.height + 1); - } -} - -Qt::WindowFlags QDirectFbWindowSurface::setWindowFlags(Qt::WindowFlags flags) -{ - switch (flags & Qt::WindowType_Mask) { - case Qt::ToolTip: { - DFBWindowOptions options; - m_dfbWindow->GetOptions(m_dfbWindow,&options); - options = DFBWindowOptions(options | DWOP_GHOST); - m_dfbWindow->SetOptions(m_dfbWindow,options); - break; } - default: - break; - } - - m_dfbWindow->SetStackingClass(m_dfbWindow, flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE); - return flags; -} - -void QDirectFbWindowSurface::raise() -{ - m_dfbWindow->RaiseToTop(m_dfbWindow); -} - -void QDirectFbWindowSurface::lower() -{ - m_dfbWindow->LowerToBottom(m_dfbWindow); -} - -WId QDirectFbWindowSurface::winId() const -{ - DFBWindowID id; - m_dfbWindow->GetID(m_dfbWindow, &id); - return WId(id); -} - - QT_END_NAMESPACE diff --git a/src/plugins/platforms/directfb/qwindowsurface_directfb.h b/src/plugins/platforms/directfb/qwindowsurface_directfb.h index 2f31513..d48f534 100644 --- a/src/plugins/platforms/directfb/qwindowsurface_directfb.h +++ b/src/plugins/platforms/directfb/qwindowsurface_directfb.h @@ -49,37 +49,26 @@ QT_BEGIN_NAMESPACE -class QDirectFbGraphicsSystemScreen; - class QDirectFbWindowSurface : public QWindowSurface { public: - QDirectFbWindowSurface(QWidget *window); + QDirectFbWindowSurface(QWidget *window, WId wid); ~QDirectFbWindowSurface(); QPaintDevice *paintDevice(); void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); + void resize (const QSize &size); bool scroll(const QRegion &area, int dx, int dy); void beginPaint(const QRegion ®ion); void endPaint(const QRegion ®ion); - void setVisible(bool visible); - Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); - - void raise(); - void lower(); - - WId winId() const; - private: void lockSurfaceToImage(); QPixmap *m_pixmap; QBlittablePixmapData *m_pmdata; - IDirectFBWindow *m_dfbWindow; IDirectFBSurface *m_dfbSurface; }; diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro index 567b551..6c97f07 100644 --- a/src/plugins/platforms/minimal/minimal.pro +++ b/src/plugins/platforms/minimal/minimal.pro @@ -1,4 +1,4 @@ -TARGET = qminimalgraphicssystem +TARGET = qminimal include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp index 2f03127..404ffbc 100644 --- a/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp +++ b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp @@ -20,9 +20,15 @@ QPixmapData *QMinimalIntegration::createPixmapData(QPixmapData::PixelType type) { return new QRasterPixmapData(type); } -void QMinimalIntegration::createWindowAndSurface(QPlatformWindow**window, QWindowSurface**surface, QWidget *widget, WId winId) const + +QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWidget *widget, WId winId) const +{ + Q_UNUSED(winId); + return new QPlatformWindow(widget); +} + +QWindowSurface *QMinimalIntegration::createWindowSurfaceForWindow(QWidget *widget, WId winId) const { - qDebug() << "createWindow"; - *surface = new QMinimalWindowSurface(widget); - *window = new QPlatformWindow(widget); + Q_UNUSED(winId); + return new QMinimalWindowSurface(widget); } diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.h b/src/plugins/platforms/minimal/qplatformintegration_minimal.h index 127c573..2e8a8cf 100644 --- a/src/plugins/platforms/minimal/qplatformintegration_minimal.h +++ b/src/plugins/platforms/minimal/qplatformintegration_minimal.h @@ -72,7 +72,8 @@ public: QMinimalIntegration(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - void createWindowAndSurface(QPlatformWindow**window, QWindowSurface**surface, QWidget *widget, WId winId) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const; QList screens() const { return mScreens; } -- cgit v0.12 From 7b3f1a992e25739a8a28cf0470ba58fd31a46e7b Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 8 Apr 2010 12:29:07 +0200 Subject: Rename qglplatformintegration_lite.h & add QGLWidget surface --- src/gui/kernel/qplatformintegration_lite.cpp | 5 ++ src/gui/kernel/qplatformintegration_lite.h | 5 +- src/opengl/opengl.pro | 2 +- src/opengl/qgl_lite.cpp | 10 +++- src/opengl/qgl_p.h | 2 +- src/opengl/qglplatformintegration_lite.h | 83 ++++++++++++++++++++++++++ src/opengl/qplatformglcontext_lite.h | 72 ---------------------- src/plugins/platforms/testlite/qglxglcontext.h | 2 +- 8 files changed, 104 insertions(+), 77 deletions(-) create mode 100644 src/opengl/qglplatformintegration_lite.h delete mode 100644 src/opengl/qplatformglcontext_lite.h diff --git a/src/gui/kernel/qplatformintegration_lite.cpp b/src/gui/kernel/qplatformintegration_lite.cpp index 71beded..3fa874c 100644 --- a/src/gui/kernel/qplatformintegration_lite.cpp +++ b/src/gui/kernel/qplatformintegration_lite.cpp @@ -66,6 +66,11 @@ QPlatformGLContext * QPlatformIntegration::createGLContext() { return 0; } + +QPlatformGLWidgetSurface * QPlatformIntegration::createGLWidgetSurface(QGLWidget*) +{ + return 0; +} #endif QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h index 9125bd1..2018c70 100644 --- a/src/gui/kernel/qplatformintegration_lite.h +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -53,6 +53,8 @@ QT_MODULE(Gui) #ifndef QT_NO_OPENGL class QPlatformGLContext; +class QPlatformGLWidgetSurface; +class QGLWidget; #endif class Q_GUI_EXPORT QPlatformIntegration @@ -72,7 +74,8 @@ public: // OpenGL Integration functions #ifndef QT_NO_OPENGL virtual bool hasOpenGL() const; - virtual QPlatformGLContext * createGLContext(); + virtual QPlatformGLContext * createGLContext(); + virtual QPlatformGLWidgetSurface * createGLWidgetSurface(QGLWidget*); #endif }; diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index cebb677..42608e3 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -78,7 +78,7 @@ SOURCES += qgl.cpp \ embedded_lite { SOURCES += qgl_lite.cpp - HEADERS += qplatformglcontext_lite.h + HEADERS += qglplatformintegration_lite.h # If we have EGL, use the EGL implementation of QGLPixelBuffer, otherwise we just provide # a stubbed out one. PBuffers aren't too interesting anyway. diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp index db1077d..a46593e 100644 --- a/src/opengl/qgl_lite.cpp +++ b/src/opengl/qgl_lite.cpp @@ -47,7 +47,7 @@ #include "qgl.h" #include "qgl_p.h" -#include "qplatformglcontext_lite.h" +#include "qglplatformintegration_lite.h" QT_BEGIN_NAMESPACE @@ -60,6 +60,14 @@ QPlatformGLContext::~QPlatformGLContext() { } +QPlatformGLWidgetSurface::QPlatformGLWidgetSurface(QGLWidget*) +{ +} + +QPlatformGLWidgetSurface::~QPlatformGLWidgetSurface() +{ +} + bool QGLFormat::hasOpenGL() { diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index f53b3e2..6405a54 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -69,7 +69,7 @@ #endif #if defined(Q_WS_LITE) -#include +#include #endif QT_BEGIN_NAMESPACE diff --git a/src/opengl/qglplatformintegration_lite.h b/src/opengl/qglplatformintegration_lite.h new file mode 100644 index 0000000..d5bae45 --- /dev/null +++ b/src/opengl/qglplatformintegration_lite.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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 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$ +** +****************************************************************************/ + +#ifndef QPLATFORM_GL_CONTEXT_H +#define QPLATFORM_GL_CONTEXT_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class Q_OPENGL_EXPORT QPlatformGLContext +{ +public: + QPlatformGLContext(); + virtual ~QPlatformGLContext(); + + virtual bool create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext) = 0; + + virtual void makeCurrent() = 0; + virtual void doneCurrent() = 0; + virtual void swapBuffers() = 0; + virtual void* getProcAddress(const QString& procName) = 0; + +}; + +// QGLPlatformWidgetSurface does _not_ inherit from QWindowSurface +// - The backing store may be totally unaware of it's existance. +class QPlatformGLWidgetSurface +{ +public: + QPlatformGLWidgetSurface(QGLWidget*); + virtual ~QPlatformGLWidgetSurface(); + + virtual void setGeometry(const QRect&) = 0; +}; + + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QPLATFORM_GL_INTEGRATION_P_H diff --git a/src/opengl/qplatformglcontext_lite.h b/src/opengl/qplatformglcontext_lite.h deleted file mode 100644 index 10c05f6..0000000 --- a/src/opengl/qplatformglcontext_lite.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** 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 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$ -** -****************************************************************************/ - -#ifndef QPLATFORM_GL_CONTEXT_H -#define QPLATFORM_GL_CONTEXT_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class Q_OPENGL_EXPORT QPlatformGLContext -{ -public: - QPlatformGLContext(); - virtual ~QPlatformGLContext(); - - virtual bool create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext) = 0; - - virtual void makeCurrent() = 0; - virtual void doneCurrent() = 0; - virtual void swapBuffers() = 0; - virtual void* getProcAddress(const QString& procName) = 0; - -}; - - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QPLATFORM_GL_INTEGRATION_P_H diff --git a/src/plugins/platforms/testlite/qglxglcontext.h b/src/plugins/platforms/testlite/qglxglcontext.h index 54e5c2f..ff8fe85 100644 --- a/src/plugins/platforms/testlite/qglxglcontext.h +++ b/src/plugins/platforms/testlite/qglxglcontext.h @@ -42,7 +42,7 @@ #ifndef Q_GLX_CONTEXT_H #define Q_GLX_CONTEXT_H -#include +#include #include "x11util.h" #include -- cgit v0.12 From 6e41376f73cc54efd2e82df8b7bdd5797438e6c5 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 8 Apr 2010 15:02:17 +0200 Subject: Compile on Lighthouse after the windowsurface API change. --- src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp index 6bf9d6b..695050e 100644 --- a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp +++ b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp @@ -98,7 +98,11 @@ QPaintDevice *QTraceWindowSurface::paintDevice() { if (!buffer) { buffer = new QPaintBuffer; +#ifdef Q_WS_LITE + buffer->setBoundingRect(QRect(QPoint(), size())); +#else buffer->setBoundingRect(geometry()); +#endif } return buffer; } -- cgit v0.12 From c3be673a149201d15cd8a7ca0a5047a7e24331fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 8 Apr 2010 14:57:36 +0200 Subject: Add the DirectFbWindow to the pro file --- src/plugins/platforms/directfb/directfb.pro | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro index f8fccaa..ec5f0f1 100644 --- a/src/plugins/platforms/directfb/directfb.pro +++ b/src/plugins/platforms/directfb/directfb.pro @@ -18,12 +18,14 @@ SOURCES = main.cpp \ qblitter_directfb.cpp \ qdirectfbconvenience.cpp \ qdirectfbinput.cpp \ - qdirectfbcursor.cpp + qdirectfbcursor.cpp \ + qdirectfbwindow.cpp HEADERS = qplatformintegration_directfb.h \ qwindowsurface_directfb.h \ qblitter_directfb.h \ qdirectfbconvenience.h \ qdirectfbinput.h \ - qdirectfbcursor.h + qdirectfbcursor.h \ + qdirectfbwindow.h target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target -- cgit v0.12 From b773920624a3420fb01071fe75c304a03051cfd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 8 Apr 2010 15:02:51 +0200 Subject: Fix "bug" in plugins.pro Dont build graphicssystems for lighthouse anymore --- src/plugins/plugins.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 73ab3e9..0e9a14c 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -6,7 +6,7 @@ unix:!symbian { } else { SUBDIRS *= codecs } -!embedded:!embedded-lite:SUBDIRS *= graphicssystems +!embedded:!embedded_lite:SUBDIRS *= graphicssystems embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers !win32:!embedded:!mac:!symbian:SUBDIRS *= inputmethods symbian:SUBDIRS += s60 -- cgit v0.12 From d64b2ad5417fec750cd3f31364fb216e61acb8cf Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 8 Apr 2010 16:06:33 +0200 Subject: Make a top-level QGLWidget work once, 50% of the time --- src/opengl/qgl.cpp | 6 +++++- src/opengl/qgl_lite.cpp | 12 +++++++++--- src/plugins/platforms/testlite/qglxglcontext.cpp | 8 +++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 1e522d6..6c6f6d9 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1361,6 +1361,10 @@ QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags() } } +#ifdef Q_WS_LITE + hasOpenGL(); // ### I have no idea why this is needed here, but it makes things work for testlite +#endif + QString versionString(QLatin1String(reinterpret_cast(glGetString(GL_VERSION)))); OpenGLVersionFlags versionFlags = qOpenGLVersionFlagsFromString(versionString); if (currentCtx) { @@ -3907,7 +3911,7 @@ void QGLWidget::resizeOverlayGL(int, int) /*! \fn bool QGLWidget::event(QEvent *e) \reimp */ -#if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS) +#if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS) && !defined(Q_WS_LITE) bool QGLWidget::event(QEvent *e) { Q_D(QGLWidget); diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp index a46593e..2a70545 100644 --- a/src/opengl/qgl_lite.cpp +++ b/src/opengl/qgl_lite.cpp @@ -232,17 +232,23 @@ void QGLWidget::setMouseTracking(bool enable) Q_UNUSED(enable); } +bool QGLWidget::event(QEvent *e) +{ + QWidget::event(e); +} + void QGLWidget::resizeEvent(QResizeEvent *) { Q_D(QGLWidget); if (!isValid()) return; makeCurrent(); - if (!d->glcx->initialized()) - glInit(); - resizeGL(width(), height()); +// if (!d->glcx->initialized()) +// glInit(); +// resizeGL(width(), height()); } + const QGLContext* QGLWidget::overlayContext() const { return 0; diff --git a/src/plugins/platforms/testlite/qglxglcontext.cpp b/src/plugins/platforms/testlite/qglxglcontext.cpp index 0739567..6fdbb56 100644 --- a/src/plugins/platforms/testlite/qglxglcontext.cpp +++ b/src/plugins/platforms/testlite/qglxglcontext.cpp @@ -62,8 +62,10 @@ QGLXGLContext::QGLXGLContext(Display *xdpy) QGLXGLContext::~QGLXGLContext() { - if (m_context) + if (m_context) { + qDebug("Destroying GLX context 0x%x", m_context); glXDestroyContext(m_display, m_context); + } } bool QGLXGLContext::create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext) @@ -88,10 +90,10 @@ bool QGLXGLContext::create(QPaintDevice* device, const QGLFormat& format, QPlatf int matchingCount = 0; visualInfo = XGetVisualInfo(m_display, VisualIDMask, &visualInfoTemplate, &matchingCount); - qDebug("Creating a GLX context for visual ID %d", visualInfoTemplate.visualid); - m_context = glXCreateContext(m_display, visualInfo, 0, True); + qDebug("Created GLX context 0x%x for visual ID %d", m_context, visualInfoTemplate.visualid); + return true; } -- cgit v0.12 From 6362d2a751294242296dd1bf06f24cf5961a9561 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 8 Apr 2010 17:05:08 +0200 Subject: port VNC plugin to platform api name change --- src/gui/kernel/qplatformscreen_lite.h | 3 +- src/plugins/platforms/fb_base/fb_base.cpp | 56 +++++++++++------------ src/plugins/platforms/fb_base/fb_base.h | 30 ++++++------ src/plugins/platforms/vnc/main.cpp | 14 +++--- src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp | 24 +++++----- src/plugins/platforms/vnc/qgraphicssystem_vnc.h | 22 ++++----- src/plugins/platforms/vnc/qvnccursor.cpp | 2 +- src/plugins/platforms/vnc/qvnccursor.h | 4 +- src/plugins/platforms/vnc/qvncserver.cpp | 16 +++---- src/plugins/platforms/vnc/qvncserver.h | 26 +++++------ src/plugins/platforms/vnc/vnc.pro | 4 +- 11 files changed, 101 insertions(+), 100 deletions(-) diff --git a/src/gui/kernel/qplatformscreen_lite.h b/src/gui/kernel/qplatformscreen_lite.h index da0e26b..abdf362 100644 --- a/src/gui/kernel/qplatformscreen_lite.h +++ b/src/gui/kernel/qplatformscreen_lite.h @@ -44,6 +44,7 @@ #include #include +#include QT_BEGIN_HEADER @@ -51,7 +52,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) -class Q_GUI_EXPORT QPlatformScreen +class Q_GUI_EXPORT QPlatformScreen : public QObject { public: virtual ~QPlatformScreen() { } diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index d30746a..a2a6609 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -6,7 +6,7 @@ #include #include -QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen *scr) +QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QPlatformScreen *scr) : QGraphicsSystemCursor(scr), currentRect(QRect()), prevRect(QRect()) { graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); @@ -81,7 +81,7 @@ void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget screen->setDirty(currentRect); } -QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false) +QFbPlatformScreen::QFbPlatformScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false) { mScreenImage = new QImage(mGeometry.size(), mFormat); redrawTimer.setSingleShot(true); @@ -89,7 +89,7 @@ QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() : cursor(0), mGeometry(), mDe QObject::connect(&redrawTimer, SIGNAL(timeout()), this, SLOT(doRedraw())); } -void QGraphicsSystemFbScreen::setGeometry(QRect rect) +void QFbPlatformScreen::setGeometry(QRect rect) { delete mScreenImage; mGeometry = rect; @@ -99,17 +99,17 @@ void QGraphicsSystemFbScreen::setGeometry(QRect rect) invalidateRectCache(); } -void QGraphicsSystemFbScreen::setDepth(int depth) +void QFbPlatformScreen::setDepth(int depth) { mDepth = depth; } -void QGraphicsSystemFbScreen::setPhysicalSize(QSize size) +void QFbPlatformScreen::setPhysicalSize(QSize size) { mPhysicalSize = size; } -void QGraphicsSystemFbScreen::setFormat(QImage::Format format) +void QFbPlatformScreen::setFormat(QImage::Format format) { mFormat = format; delete mScreenImage; @@ -118,13 +118,13 @@ void QGraphicsSystemFbScreen::setFormat(QImage::Format format) compositePainter = 0; } -QGraphicsSystemFbScreen::~QGraphicsSystemFbScreen() +QFbPlatformScreen::~QFbPlatformScreen() { delete compositePainter; delete mScreenImage; } -void QGraphicsSystemFbScreen::setDirty(const QRect &rect) +void QFbPlatformScreen::setDirty(const QRect &rect) { repaintRegion += rect; if (!redrawTimer.isActive()) { @@ -132,7 +132,7 @@ void QGraphicsSystemFbScreen::setDirty(const QRect &rect) } } -void QGraphicsSystemFbScreen::generateRects() +void QFbPlatformScreen::generateRects() { cachedRects.clear(); QRegion remainingScreen(mGeometry); @@ -157,7 +157,7 @@ void QGraphicsSystemFbScreen::generateRects() -QRegion QGraphicsSystemFbScreen::doRedraw() +QRegion QFbPlatformScreen::doRedraw() { QRegion touchedRegion; if (cursor) @@ -227,21 +227,21 @@ QRegion QGraphicsSystemFbScreen::doRedraw() return touchedRegion; } -void QGraphicsSystemFbScreen::removeWindowSurface(QGraphicsSystemFbWindowSurface * surface) +void QFbPlatformScreen::removeWindowSurface(QFbWindowSurface * surface) { windowStack.removeOne(surface); invalidateRectCache(); setDirty(surface->geometry()); } -void QGraphicsSystemFbWindowSurface::raise() +void QFbWindowSurface::raise() { mScreen->raise(this); } -void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) +void QFbPlatformScreen::raise(QWindowSurface * surface) { - QGraphicsSystemFbWindowSurface *s = static_cast(surface); + QFbWindowSurface *s = static_cast(surface); int index = windowStack.indexOf(s); if (index <= 0) return; @@ -250,14 +250,14 @@ void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) setDirty(s->geometry()); } -void QGraphicsSystemFbWindowSurface::lower() +void QFbWindowSurface::lower() { mScreen->lower(this); } -void QGraphicsSystemFbScreen::lower(QWindowSurface * surface) +void QFbPlatformScreen::lower(QWindowSurface * surface) { - QGraphicsSystemFbWindowSurface *s = static_cast(surface); + QFbWindowSurface *s = static_cast(surface); int index = windowStack.indexOf(s); if (index == -1 || index == (windowStack.size() - 1)) return; @@ -266,7 +266,7 @@ void QGraphicsSystemFbScreen::lower(QWindowSurface * surface) setDirty(s->geometry()); } -QWidget * QGraphicsSystemFbScreen::topLevelAt(const QPoint & p) const +QWidget * QFbPlatformScreen::topLevelAt(const QPoint & p) const { for(int i = 0; i < windowStack.size(); i++) { if (windowStack[i]->geometry().contains(p, false) && @@ -278,7 +278,7 @@ QWidget * QGraphicsSystemFbScreen::topLevelAt(const QPoint & p) const return 0; } -QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window) +QFbWindowSurface::QFbWindowSurface(QFbPlatformScreen *screen, QWidget *window) : QWindowSurface(window), mScreen(screen), visibleFlag(false) @@ -289,12 +289,12 @@ QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFb windowId = winIdGenerator.fetchAndAddRelaxed(1); } -QGraphicsSystemFbWindowSurface::~QGraphicsSystemFbWindowSurface() +QFbWindowSurface::~QFbWindowSurface() { mScreen->removeWindowSurface(this); } -void QGraphicsSystemFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +void QFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(widget); Q_UNUSED(offset); @@ -314,7 +314,7 @@ void QGraphicsSystemFbWindowSurface::flush(QWidget *widget, const QRegion ®io mScreen->setDirty(dirtyRegion); } -void QGraphicsSystemFbWindowSurface::setGeometry(const QRect &rect) +void QFbWindowSurface::setGeometry(const QRect &rect) { // store previous geometry for screen update oldGeometry = geometry(); @@ -329,36 +329,36 @@ void QGraphicsSystemFbWindowSurface::setGeometry(const QRect &rect) QWindowSurface::setGeometry(rect); } -bool QGraphicsSystemFbWindowSurface::scroll(const QRegion &area, int dx, int dy) +bool QFbWindowSurface::scroll(const QRegion &area, int dx, int dy) { return QWindowSurface::scroll(area, dx, dy); } -void QGraphicsSystemFbWindowSurface::beginPaint(const QRegion ®ion) +void QFbWindowSurface::beginPaint(const QRegion ®ion) { Q_UNUSED(region); } -void QGraphicsSystemFbWindowSurface::endPaint(const QRegion ®ion) +void QFbWindowSurface::endPaint(const QRegion ®ion) { Q_UNUSED(region); } -void QGraphicsSystemFbWindowSurface::setVisible(bool visible) +void QFbWindowSurface::setVisible(bool visible) { visibleFlag = visible; mScreen->invalidateRectCache(); mScreen->setDirty(geometry()); } -Qt::WindowFlags QGraphicsSystemFbWindowSurface::setWindowFlags(Qt::WindowFlags type) +Qt::WindowFlags QFbWindowSurface::setWindowFlags(Qt::WindowFlags type) { flags = type; mScreen->invalidateRectCache(); return flags; } -Qt::WindowFlags QGraphicsSystemFbWindowSurface::windowFlags() const +Qt::WindowFlags QFbWindowSurface::windowFlags() const { return flags; } diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index 7f9b005..fef769c 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -1,23 +1,23 @@ #ifndef QLIGHTHOUSEGRAPHICSSCREEN_H #define QLIGHTHOUSEGRAPHICSSCREEN_H -#include +#include #include #include #include #include -#include +#include class QMouseEvent; class QSize; class QPainter; -class QGraphicsSystemFbScreen; +class QFbPlatformScreen; class QGraphicsSystemSoftwareCursor : public QGraphicsSystemCursor { public: - QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen * scr); + QGraphicsSystemSoftwareCursor(QPlatformScreen * scr); // output methods QRect dirtyRect(); @@ -39,11 +39,11 @@ private: QRect getCurrentRect(); }; -class QGraphicsSystemFbWindowSurface : public QWindowSurface +class QFbWindowSurface : public QWindowSurface { public: - QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window); - ~QGraphicsSystemFbWindowSurface(); + QFbWindowSurface(QFbPlatformScreen *screen, QWidget *window); + ~QFbWindowSurface(); virtual QPaintDevice *paintDevice() { return &mImage; } virtual void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); @@ -65,7 +65,7 @@ public: WId winId() const { return windowId; } protected: - QGraphicsSystemFbScreen *mScreen; + QFbPlatformScreen *mScreen; QRect oldGeometry; QImage mImage; bool visibleFlag; @@ -74,12 +74,12 @@ protected: WId windowId; }; -class QGraphicsSystemFbScreen : public QGraphicsSystemScreen +class QFbPlatformScreen : public QPlatformScreen { Q_OBJECT public: - QGraphicsSystemFbScreen(); - ~QGraphicsSystemFbScreen(); + QFbPlatformScreen(); + ~QFbPlatformScreen(); virtual QRect geometry() const { return mGeometry; } virtual int depth() const { return mDepth; } @@ -93,8 +93,8 @@ public: virtual void setDirty(const QRect &rect); - virtual void removeWindowSurface(QGraphicsSystemFbWindowSurface * surface); - virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { + virtual void removeWindowSurface(QFbWindowSurface * surface); + virtual void addWindowSurface(QFbWindowSurface * surface) { windowStack.prepend(surface); invalidateRectCache(); } virtual void raise(QWindowSurface * surface); virtual void lower(QWindowSurface * surface); @@ -104,7 +104,7 @@ public: QPaintDevice * paintDevice() const { return mScreenImage; } protected: - QList windowStack; + QList windowStack; QRegion repaintRegion; QGraphicsSystemSoftwareCursor * cursor; QTimer redrawTimer; @@ -125,7 +125,7 @@ private: QList > cachedRects; void invalidateRectCache() { isUpToDate = false; } - friend class QGraphicsSystemFbWindowSurface; + friend class QFbWindowSurface; bool isUpToDate; }; diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp index f10748a..baaca3e 100644 --- a/src/plugins/platforms/vnc/main.cpp +++ b/src/plugins/platforms/vnc/main.cpp @@ -39,34 +39,34 @@ ** ****************************************************************************/ -#include +#include #include "qgraphicssystem_vnc.h" #include QT_BEGIN_NAMESPACE -class QVNCGraphicsSystemPlugin : public QGraphicsSystemPlugin +class QVNCPlatformIntegrationPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QGraphicsSystem *create(const QString&); + QPlatformIntegration *create(const QString&); }; -QStringList QVNCGraphicsSystemPlugin::keys() const +QStringList QVNCPlatformIntegrationPlugin::keys() const { QStringList list; list << "VNC"; return list; } -QGraphicsSystem* QVNCGraphicsSystemPlugin::create(const QString& system) +QPlatformIntegration* QVNCPlatformIntegrationPlugin::create(const QString& system) { if (system.toLower() == "vnc") - return new QVNCGraphicsSystem; + return new QVNCPlatformIntegration; return 0; } -Q_EXPORT_PLUGIN2(vnc, QVNCGraphicsSystemPlugin) +Q_EXPORT_PLUGIN2(vnc, QVNCPlatformIntegrationPlugin) QT_END_NAMESPACE diff --git a/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp b/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp index 7815f24..85f1b73 100644 --- a/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp +++ b/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp @@ -51,8 +51,8 @@ #include -QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() - : QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() +QVNCPlatformScreen::QVNCPlatformScreen() + : QFbPlatformScreen::QFbPlatformScreen() { int w = 800; int h = 600; @@ -69,21 +69,21 @@ QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() setPhysicalSize((geometry().size()*254)/720); - d_ptr = new QVNCGraphicsSystemScreenPrivate(this); + d_ptr = new QVNCPlatformScreenPrivate(this); cursor = new QVNCCursor(d_ptr->vncServer, this); d_ptr->vncServer->setCursor(static_cast(cursor)); } -QVNCDirtyMap *QVNCGraphicsSystemScreen::dirtyMap() +QVNCDirtyMap *QVNCPlatformScreen::dirtyMap() { return d_ptr->dirty; } -QRegion QVNCGraphicsSystemScreen::doRedraw() +QRegion QVNCPlatformScreen::doRedraw() { QRegion touched; - touched = QGraphicsSystemFbScreen::doRedraw(); + touched = QFbPlatformScreen::doRedraw(); QVector rects = touched.rects(); for (int i = 0; i < rects.size(); i++) @@ -92,24 +92,24 @@ QRegion QVNCGraphicsSystemScreen::doRedraw() } -QVNCGraphicsSystem::QVNCGraphicsSystem() +QVNCPlatformIntegration::QVNCPlatformIntegration() { - mPrimaryScreen = new QVNCGraphicsSystemScreen(); + mPrimaryScreen = new QVNCPlatformScreen(); mScreens.append(mPrimaryScreen); } -QPixmapData *QVNCGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +QPixmapData *QVNCPlatformIntegration::createPixmapData(QPixmapData::PixelType type) const { return new QRasterPixmapData(type); } -QWindowSurface *QVNCGraphicsSystem::createWindowSurface(QWidget *widget) const +QWindowSurface *QVNCPlatformIntegration::createWindowSurface(QWidget *widget) const { if (widget->windowType() == Qt::Desktop) return 0; // Don't create an explicit window surface for the destkop. - QGraphicsSystemFbWindowSurface * surface; - surface = new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); + QFbWindowSurface * surface; + surface = new QFbWindowSurface(mPrimaryScreen, widget); mPrimaryScreen->addWindowSurface(surface); return surface; } diff --git a/src/plugins/platforms/vnc/qgraphicssystem_vnc.h b/src/plugins/platforms/vnc/qgraphicssystem_vnc.h index b3349b7..731d3e9 100644 --- a/src/plugins/platforms/vnc/qgraphicssystem_vnc.h +++ b/src/plugins/platforms/vnc/qgraphicssystem_vnc.h @@ -42,51 +42,51 @@ #ifndef QGRAPHICSSYSTEM_VNC_H #define QGRAPHICSSYSTEM_VNC_H -#include #include "qvnccursor.h" #include "../fb_base/fb_base.h" +#include QT_BEGIN_NAMESPACE class QVNCServer; class QVNCDirtyMap; -class QVNCGraphicsSystemScreenPrivate; +class QVNCPlatformScreenPrivate; -class QVNCGraphicsSystemScreen : public QGraphicsSystemFbScreen +class QVNCPlatformScreen : public QFbPlatformScreen { public: - QVNCGraphicsSystemScreen(); + QVNCPlatformScreen(); int linestep() const { return image() ? image()->bytesPerLine() : 0; } uchar *base() const { return image() ? image()->bits() : 0; } QVNCDirtyMap *dirtyMap(); public: - QVNCGraphicsSystemScreenPrivate *d_ptr; + QVNCPlatformScreenPrivate *d_ptr; private: QVNCServer *server; QRegion doRedraw(); }; -class QVNCGraphicsSystemPrivate; +class QVNCPlatformIntegrationPrivate; -class QVNCGraphicsSystem : public QGraphicsSystem +class QVNCPlatformIntegration : public QPlatformIntegration { public: - QVNCGraphicsSystem(); + QVNCPlatformIntegration(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QWindowSurface *createWindowSurface(QWidget *widget) const; - QList screens() const { return mScreens; } + QList screens() const { return mScreens; } private: - QVNCGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; + QVNCPlatformScreen *mPrimaryScreen; + QList mScreens; }; diff --git a/src/plugins/platforms/vnc/qvnccursor.cpp b/src/plugins/platforms/vnc/qvnccursor.cpp index fb214d8..5f9fbb6 100644 --- a/src/plugins/platforms/vnc/qvnccursor.cpp +++ b/src/plugins/platforms/vnc/qvnccursor.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE -QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCGraphicsSystemScreen *scr ) +QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCPlatformScreen *scr ) :QGraphicsSystemSoftwareCursor(scr), useVncCursor(false), server(srvr) { } diff --git a/src/plugins/platforms/vnc/qvnccursor.h b/src/plugins/platforms/vnc/qvnccursor.h index 8ea0f45..0e4d7ca 100644 --- a/src/plugins/platforms/vnc/qvnccursor.h +++ b/src/plugins/platforms/vnc/qvnccursor.h @@ -48,12 +48,12 @@ QT_BEGIN_NAMESPACE -class QVNCGraphicsSystemScreen; +class QVNCPlatformScreen; class QVNCServer; class QVNCCursor : public QGraphicsSystemSoftwareCursor { public: - QVNCCursor(QVNCServer *, QVNCGraphicsSystemScreen *); + QVNCCursor(QVNCServer *, QVNCPlatformScreen *); // input methods void setCursorMode(bool vnc); diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp index ea576d4..ce08082 100644 --- a/src/plugins/platforms/vnc/qvncserver.cpp +++ b/src/plugins/platforms/vnc/qvncserver.cpp @@ -358,13 +358,13 @@ bool QRfbClientCutText::read(QTcpSocket *s) //=========================================================================== -QVNCServer::QVNCServer(QVNCGraphicsSystemScreen *screen) +QVNCServer::QVNCServer(QVNCPlatformScreen *screen) : qvnc_screen(screen), cursor(0) { init(5900); } -QVNCServer::QVNCServer(QVNCGraphicsSystemScreen *screen, int id) +QVNCServer::QVNCServer(QVNCPlatformScreen *screen, int id) : qvnc_screen(screen), cursor(0) { init(5900 + id); @@ -620,7 +620,7 @@ void QVNCServer::readClient() } #if 0//Q_BYTE_ORDER == Q_BIG_ENDIAN -bool QVNCGraphicsSystemScreen::swapBytes() const +bool QVNCScreen::swapBytes() const { if (depth() != 16) return false; @@ -1499,7 +1499,7 @@ static void blendCursor(QImage &image, const QRect &imageRect) } #endif // QT_NO_QWS_CURSOR -QVNCDirtyMap::QVNCDirtyMap(QVNCGraphicsSystemScreen *s) +QVNCDirtyMap::QVNCDirtyMap(QVNCPlatformScreen *s) : bytesPerPixel(0), numDirty(0), screen(s) { bytesPerPixel = (screen->depth() + 7) / 8; @@ -1885,7 +1885,7 @@ void QVNCServer::discardClient() -QVNCGraphicsSystemScreenPrivate::QVNCGraphicsSystemScreenPrivate(QVNCGraphicsSystemScreen *parent) +QVNCPlatformScreenPrivate::QVNCPlatformScreenPrivate(QVNCPlatformScreen *parent) : dpiX(72), dpiY(72), doOnScreenSurface(false), refreshRate(25), vncServer(0), q_ptr(parent) { @@ -1902,12 +1902,12 @@ QVNCGraphicsSystemScreenPrivate::QVNCGraphicsSystemScreenPrivate(QVNCGraphicsSys dirty = new QVNCDirtyMapOptimized(q_ptr); } -QVNCGraphicsSystemScreenPrivate::~QVNCGraphicsSystemScreenPrivate() +QVNCPlatformScreenPrivate::~QVNCPlatformScreenPrivate() { } -void QVNCGraphicsSystemScreenPrivate::setDirty(const QRect& rect, bool force) +void QVNCPlatformScreenPrivate::setDirty(const QRect& rect, bool force) { if (rect.isEmpty()) return; @@ -1916,7 +1916,7 @@ void QVNCGraphicsSystemScreenPrivate::setDirty(const QRect& rect, bool force) // q_ptr->screen()->setDirty(rect); if (!vncServer || !vncServer->isConnected()) { -// qDebug() << "QVNCGraphicsSystemScreenPrivate::setDirty() - Not connected"; +// qDebug() << "QVNCScreenPrivate::setDirty() - Not connected"; return; } const QRect r = rect; // .translated(-q_ptr->offset()); diff --git a/src/plugins/platforms/vnc/qvncserver.h b/src/plugins/platforms/vnc/qvncserver.h index 4fcdbae..6830ddd 100644 --- a/src/plugins/platforms/vnc/qvncserver.h +++ b/src/plugins/platforms/vnc/qvncserver.h @@ -72,7 +72,7 @@ class QVNCServer; class QVNCCursor : public QProxyScreenCursor { public: - QVNCCursor(QVNCGraphicsSystemScreen *s); + QVNCCursor(QVNCScreen *s); ~QVNCCursor(); void hide(); @@ -82,7 +82,7 @@ public: private: void setDirty(const QRect &r) const; - QVNCGraphicsSystemScreen *screen; + QVNCScreen *screen; }; class QVNCClientCursor : public QProxyScreenCursor @@ -106,7 +106,7 @@ private: class QVNCDirtyMap { public: - QVNCDirtyMap(QVNCGraphicsSystemScreen *screen); + QVNCDirtyMap(QVNCPlatformScreen *screen); virtual ~QVNCDirtyMap(); void reset(); @@ -122,7 +122,7 @@ public: protected: uchar *map; - QVNCGraphicsSystemScreen *screen; + QVNCPlatformScreen *screen; uchar *buffer; int bufferWidth; int bufferHeight; @@ -134,7 +134,7 @@ template class QVNCDirtyMapOptimized : public QVNCDirtyMap { public: - QVNCDirtyMapOptimized(QVNCGraphicsSystemScreen *screen) : QVNCDirtyMap(screen) {} + QVNCDirtyMapOptimized(QVNCPlatformScreen *screen) : QVNCDirtyMap(screen) {} ~QVNCDirtyMapOptimized() {} void setDirty(int x, int y, bool force = false); @@ -246,11 +246,11 @@ public: quint32 length; }; -class QVNCGraphicsSystemScreenPrivate : public QObject +class QVNCPlatformScreenPrivate : public QObject { public: - QVNCGraphicsSystemScreenPrivate(QVNCGraphicsSystemScreen *parent); - ~QVNCGraphicsSystemScreenPrivate(); + QVNCPlatformScreenPrivate(QVNCPlatformScreen *parent); + ~QVNCPlatformScreenPrivate(); void setDirty(const QRect &rect, bool force = false); void configure(); @@ -266,7 +266,7 @@ public: QSharedMemory shm; #endif - QVNCGraphicsSystemScreen *q_ptr; + QVNCPlatformScreen *q_ptr; }; class QRfbEncoder @@ -438,8 +438,8 @@ class QVNCServer : public QObject { Q_OBJECT public: - QVNCServer(QVNCGraphicsSystemScreen *screen); - QVNCServer(QVNCGraphicsSystemScreen *screen, int id); + QVNCServer(QVNCPlatformScreen *screen); + QVNCServer(QVNCPlatformScreen *screen, int id); ~QVNCServer(); void setDirty(); @@ -464,7 +464,7 @@ public: return pixelFormat.bitsPerPixel / 8; } - inline QVNCGraphicsSystemScreen* screen() const { return qvnc_screen; } + inline QVNCPlatformScreen* screen() const { return qvnc_screen; } inline QVNCDirtyMap* dirtyMap() const { return qvnc_screen->dirtyMap(); } inline QTcpSocket* clientSocket() const { return client; } QImage *screenImage() const; @@ -519,7 +519,7 @@ private: #endif bool dirtyCursor; int refreshRate; - QVNCGraphicsSystemScreen *qvnc_screen; + QVNCPlatformScreen *qvnc_screen; #ifndef QT_NO_QWS_CURSOR QVNCClientCursor *qvnc_cursor; #endif diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro index 0b73b5b..b1da572 100644 --- a/src/plugins/platforms/vnc/vnc.pro +++ b/src/plugins/platforms/vnc/vnc.pro @@ -1,7 +1,7 @@ TARGET = qvncgraphicssystem include(../../qpluginbase.pri) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms SOURCES = main.cpp qgraphicssystem_vnc.cpp HEADERS = qgraphicssystem_vnc.h @@ -14,6 +14,6 @@ SOURCES += qvnccursor.cpp include(../fb_base/fb_base.pri) -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target -- cgit v0.12 From 473d152acc9fe0d04167406c0926363c3eddd16c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 9 Apr 2010 10:25:06 +0200 Subject: Compile after the QPlatformWindow change ...but it doesn't *quite* work yet. --- .../testlite/qplatformintegration_testlite.cpp | 17 +++- .../testlite/qplatformintegration_testlite.h | 3 +- .../platforms/testlite/qwindowsurface_testlite.cpp | 109 ++++++++++++++------- .../platforms/testlite/qwindowsurface_testlite.h | 24 ++++- src/plugins/platforms/testlite/x11util.cpp | 18 ++-- src/plugins/platforms/testlite/x11util.h | 4 +- 6 files changed, 119 insertions(+), 56 deletions(-) diff --git a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp index 6811e2e..3e73821 100644 --- a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp +++ b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp @@ -57,20 +57,20 @@ public: MyCursor(QPlatformScreen *screen) : QGraphicsSystemCursor(screen) {} void changeCursor(QCursor * cursor, QWidget * widget) { - QTestLiteWindowSurface *ws = 0; + QTestLiteWindow *w = 0; if (widget) { QWidget *window = widget->window(); - ws = static_cast(window->windowSurface()); + w = static_cast(window->platformWindow()); } else { // No X11 cursor control when there is no widget under the cursor return; } //qDebug() << "changeCursor" << widget << ws; - if (!ws) + if (!w) return; - ws->setCursor(cursor); + w->setCursor(cursor); } }; @@ -101,7 +101,7 @@ QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type) return new QRasterPixmapData(type); } -QWindowSurface *QTestLiteIntegration::createWindowSurface(QWidget *widget) const +QWindowSurface *QTestLiteIntegration::createWindowSurfaceForWindow(QWidget *widget, WId) const { if (widget->windowType() == Qt::Desktop) return 0; // Don't create an explicit window surface for the destkop. @@ -110,6 +110,13 @@ QWindowSurface *QTestLiteIntegration::createWindowSurface(QWidget *widget) const } +QPlatformWindow *QTestLiteIntegration::createPlatformWindow(QWidget *widget, WId winId) const +{ + return new QTestLiteWindow(const_cast(this), mPrimaryScreen, widget); +} + + + QPixmap QTestLiteIntegration::grabWindow(WId window, int x, int y, int width, int height) const { QImage img = xd->grabWindow(window, x, y, width, height); diff --git a/src/plugins/platforms/testlite/qplatformintegration_testlite.h b/src/plugins/platforms/testlite/qplatformintegration_testlite.h index c540c48..bd27d89 100644 --- a/src/plugins/platforms/testlite/qplatformintegration_testlite.h +++ b/src/plugins/platforms/testlite/qplatformintegration_testlite.h @@ -74,7 +74,8 @@ public: QTestLiteIntegration(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const; QPixmap grabWindow(WId window, int x, int y, int width, int height) const; diff --git a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp index e2574f9..801491c 100644 --- a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp @@ -58,19 +58,16 @@ QTestLiteWindowSurface::QTestLiteWindowSurface xw(0) { - - xw = new MyWindow(platformIntegration->xd, 0,0,300,300); - xw->windowSurface = this; + xw = static_cast(window->platformWindow())->xw; +// xw = new MyWindow(platformIntegration->xd, 0,0,300,300); // qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window; - setWindowFlags(window->windowFlags()); //##### This should not be the plugin's responsibility } QTestLiteWindowSurface::~QTestLiteWindowSurface() { // qDebug() << "~QTestLiteWindowSurface" << xw->window; - delete xw; } QPaintDevice *QTestLiteWindowSurface::paintDevice() @@ -90,18 +87,18 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const } -void QTestLiteWindowSurface::setGeometry(const QRect &rect) -{ - QRect oldRect = geometry(); - if (rect == oldRect) - return; +// void QTestLiteWindowSurface::resize(const QSize &s) +// { +// if (s == size()) +// return; - QWindowSurface::setGeometry(rect); +// QWindowSurface::resize(size); - //if unchanged ### -// xw->setSize(rect.width(), rect.height()); - xw->setGeometry(rect.x(), rect.y(), rect.width(), rect.height()); -} +// //if unchanged ### +// // xw->setSize(rect.width(), rect.height()); + + +// } //### scroll logic copied from QRasterWindowSurface, we should make better API for this @@ -168,7 +165,8 @@ bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) void QTestLiteWindowSurface::beginPaint(const QRegion ®ion) { Q_UNUSED(region); - xw->resizeBuffer(geometry().size()); + qDebug() << "QTestLiteWindowSurface::beginPaint" << size(); + xw->resizeBuffer(size()); } void QTestLiteWindowSurface::endPaint(const QRegion ®ion) @@ -178,6 +176,29 @@ void QTestLiteWindowSurface::endPaint(const QRegion ®ion) } +/************************************************************************** +** QTestLiteWindow +**************************************************************************/ + +QTestLiteWindow::QTestLiteWindow(QTestLiteIntegration *platformIntegration, + QTestLiteScreen */*screen*/, QWidget *window) + :QPlatformWindow(window) +{ + xw = new MyWindow(platformIntegration->xd, 0,0,300,300); + setWindowFlags(window->windowFlags()); //##### This should not be the plugin's responsibility + + xw->windowTL = this; +} + + +QTestLiteWindow::~QTestLiteWindow() +{ + delete xw; +} + + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Mouse event stuff @@ -220,7 +241,7 @@ static Qt::KeyboardModifiers translateModifiers(int s) return ret; } -void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) +void QTestLiteWindow::handleMouseEvent(QEvent::Type type, void *ev) { static QPoint mousePoint; @@ -245,7 +266,7 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) bool hor = (((e->button == Button4 || e->button == Button5) && (modifiers & Qt::AltModifier)) || (e->button == 6 || e->button == 7)); - QWindowSystemInterface::handleWheelEvent(window(), e->time, + QWindowSystemInterface::handleWheelEvent(widget(), e->time, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), delta, hor ? Qt::Horizontal : Qt::Vertical); @@ -258,33 +279,33 @@ void QTestLiteWindowSurface::handleMouseEvent(QEvent::Type type, void *ev) buttons ^= button; // X event uses state *before*, Qt uses state *after* - QWindowSystemInterface::handleMouseEvent(window(), e->time, QPoint(e->x, e->y), + QWindowSystemInterface::handleMouseEvent(widget(), e->time, QPoint(e->x, e->y), QPoint(e->x_root, e->y_root), buttons); mousePoint = QPoint(e->x_root, e->y_root); } -void QTestLiteWindowSurface::handleGeometryChange(int x, int y, int w, int h) +void QTestLiteWindow::handleGeometryChange(int x, int y, int w, int h) { - QWindowSystemInterface::handleGeometryChange(window(), QRect(x,y,w,h)); + QWindowSystemInterface::handleGeometryChange(widget(), QRect(x,y,w,h)); } -void QTestLiteWindowSurface::handleCloseEvent() +void QTestLiteWindow::handleCloseEvent() { - QWindowSystemInterface::handleCloseEvent(window()); + QWindowSystemInterface::handleCloseEvent(widget()); } -void QTestLiteWindowSurface::handleEnterEvent() +void QTestLiteWindow::handleEnterEvent() { - QWindowSystemInterface::handleEnterEvent(window()); + QWindowSystemInterface::handleEnterEvent(widget()); } -void QTestLiteWindowSurface::handleLeaveEvent() +void QTestLiteWindow::handleLeaveEvent() { - QWindowSystemInterface::handleLeaveEvent(window()); + QWindowSystemInterface::handleLeaveEvent(widget()); } @@ -568,7 +589,7 @@ static Qt::KeyboardModifiers modifierFromKeyCode(int qtcode) } } -void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) +void QTestLiteWindow::handleKeyEvent(QEvent::Type type, void *ev) { XKeyEvent *e = static_cast(ev); @@ -592,12 +613,12 @@ void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) modifiers ^= modifierFromKeyCode(qtcode); if (qtcode) { - QWindowSystemInterface::handleKeyEvent(window(), e->time, type, qtcode, modifiers); + QWindowSystemInterface::handleKeyEvent(widget(), e->time, type, qtcode, modifiers); } else if (chars[0]) { int qtcode = chars.toUpper()[0]; //Not exactly right... if (modifiers & Qt::ControlModifier && qtcode < ' ') qtcode = chars[0] + '@'; - QWindowSystemInterface::handleKeyEvent(window(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars)); + QWindowSystemInterface::handleKeyEvent(widget(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars)); } else { qWarning() << "unknown X keycode" << hex << e->keycode << keySym; } @@ -605,7 +626,19 @@ void QTestLiteWindowSurface::handleKeyEvent(QEvent::Type type, void *ev) -Qt::WindowFlags QTestLiteWindowSurface::setWindowFlags(Qt::WindowFlags flags) +void QTestLiteWindow::setGeometry(const QRect &rect) +{ + QRect oldRect = geometry(); + if (rect == oldRect) + return; + + //if unchanged ### + xw->setGeometry(rect.x(), rect.y(), rect.width(), rect.height()); +} + + + +Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags) { Q_ASSERT(flags & Qt::Window); @@ -617,19 +650,19 @@ Qt::WindowFlags QTestLiteWindowSurface::setWindowFlags(Qt::WindowFlags flags) } -Qt::WindowFlags QTestLiteWindowSurface::windowFlags() const +Qt::WindowFlags QTestLiteWindow::windowFlags() const { return window_flags; } -void QTestLiteWindowSurface::setVisible(bool visible) +void QTestLiteWindow::setVisible(bool visible) { //qDebug() << "QTestLiteWindowSurface::setVisible" << visible << xw->window; xw->setVisible(visible); } -WId QTestLiteWindowSurface::winId() const +WId QTestLiteWindow::winId() const { if (xw) return (WId) xw->window; @@ -637,24 +670,24 @@ WId QTestLiteWindowSurface::winId() const return WId(0); } -void QTestLiteWindowSurface::raise() +void QTestLiteWindow::raise() { WId window = winId(); XRaiseWindow(mPlatformIntegration->xd->display, window); } -void QTestLiteWindowSurface::lower() +void QTestLiteWindow::lower() { WId window = winId(); XLowerWindow(mPlatformIntegration->xd->display, window); } -void QTestLiteWindowSurface::setWindowTitle(const QString &title) +void QTestLiteWindow::setWindowTitle(const QString &title) { xw->setWindowTitle(title); } -void QTestLiteWindowSurface::setCursor(QCursor *cursor) +void QTestLiteWindow::setCursor(QCursor *cursor) { xw->setCursor(cursor); } diff --git a/src/plugins/platforms/testlite/qwindowsurface_testlite.h b/src/plugins/platforms/testlite/qwindowsurface_testlite.h index ffd2d3a..d713cc2 100644 --- a/src/plugins/platforms/testlite/qwindowsurface_testlite.h +++ b/src/plugins/platforms/testlite/qwindowsurface_testlite.h @@ -43,6 +43,7 @@ #define QWINDOWSURFACE_TESTLITE_H #include +#include #include QT_BEGIN_NAMESPACE @@ -61,12 +62,28 @@ public: QPaintDevice *paintDevice(); void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); +// void resize(const QSize &size); bool scroll(const QRegion &area, int dx, int dy); void beginPaint(const QRegion ®ion); void endPaint(const QRegion ®ion); +private: + QTestLiteIntegration *mPlatformIntegration; + QTestLiteScreen *mScreen; + Qt::WindowFlags window_flags; + MyWindow *xw; +}; + + +class QTestLiteWindow : public QPlatformWindow +{ +public: + QTestLiteWindow(QTestLiteIntegration *platformIntegration, + QTestLiteScreen *screen, QWidget *window); + ~QTestLiteWindow(); + + void handleMouseEvent(QEvent::Type, void *); //forwarding X types is apparently impossible :( void handleKeyEvent(QEvent::Type, void *); void handleGeometryChange(int x, int y, int w, int h); @@ -74,6 +91,8 @@ public: void handleEnterEvent(); void handleLeaveEvent(); + void setGeometry(const QRect &rect); + Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); Qt::WindowFlags windowFlags() const; void setVisible(bool visible); @@ -89,8 +108,11 @@ private: QTestLiteScreen *mScreen; Qt::WindowFlags window_flags; MyWindow *xw; + + friend class QTestLiteWindowSurface; //### needs refactoring }; + QT_END_NAMESPACE #endif diff --git a/src/plugins/platforms/testlite/x11util.cpp b/src/plugins/platforms/testlite/x11util.cpp index 6d2966f..a869347 100644 --- a/src/plugins/platforms/testlite/x11util.cpp +++ b/src/plugins/platforms/testlite/x11util.cpp @@ -511,7 +511,7 @@ GC MyWindow::createGC() void MyWindow::closeEvent() { - windowSurface->handleCloseEvent(); + windowTL->handleCloseEvent(); } void MyWindow::paintEvent() @@ -633,7 +633,7 @@ void MyWindow::resizeEvent(XConfigureEvent *e) qDebug() << hex << window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height << "img:" << shm_img.size(); #endif - windowSurface->handleGeometryChange(xpos, ypos, width, height); + windowTL->handleGeometryChange(xpos, ypos, width, height); } #if 0 @@ -657,7 +657,7 @@ void MyWindow::enterEvent(XCrossingEvent *) #ifdef MYX11_DEBUG qDebug() << "MyWindow::enterEvent" << hex << window; #endif - windowSurface->handleEnterEvent(); + windowTL->handleEnterEvent(); } void MyWindow::leaveEvent(XCrossingEvent *) @@ -665,7 +665,7 @@ void MyWindow::leaveEvent(XCrossingEvent *) #ifdef MYX11_DEBUG qDebug() << "MyWindow::enterEvent" << hex << window; #endif - windowSurface->handleLeaveEvent(); + windowTL->handleLeaveEvent(); } void MyWindow::mousePressEvent(XButtonEvent *e) @@ -688,17 +688,17 @@ void MyWindow::mousePressEvent(XButtonEvent *e) prevX = e->x; prevY = e->y; - windowSurface->handleMouseEvent(type, e); + windowTL->handleMouseEvent(type, e); } void MyWindow::mouseReleaseEvent(XButtonEvent *e) { - windowSurface->handleMouseEvent(QEvent::MouseButtonRelease, e); + windowTL->handleMouseEvent(QEvent::MouseButtonRelease, e); } void MyWindow::mouseMoveEvent(XButtonEvent *e) { - windowSurface->handleMouseEvent(QEvent::MouseMove, e); + windowTL->handleMouseEvent(QEvent::MouseMove, e); } #ifdef KeyPress @@ -707,7 +707,7 @@ void MyWindow::mouseMoveEvent(XButtonEvent *e) void MyWindow::keyPressEvent(XKeyEvent *e) { - windowSurface->handleKeyEvent(QEvent::KeyPress, e); + windowTL->handleKeyEvent(QEvent::KeyPress, e); } #ifdef KeyRelease @@ -716,7 +716,7 @@ void MyWindow::keyPressEvent(XKeyEvent *e) void MyWindow::keyReleaseEvent(XKeyEvent *e) { - windowSurface->handleKeyEvent(QEvent::KeyRelease, e); + windowTL->handleKeyEvent(QEvent::KeyRelease, e); } diff --git a/src/plugins/platforms/testlite/x11util.h b/src/plugins/platforms/testlite/x11util.h index 79e7461..b28d1e8 100644 --- a/src/plugins/platforms/testlite/x11util.h +++ b/src/plugins/platforms/testlite/x11util.h @@ -85,7 +85,7 @@ public: //### MyX11Cursors * cursors; }; -class QTestLiteWindowSurface; //### abstract callback interface, anyone? +class QTestLiteWindow; //### abstract callback interface, anyone? struct MyShmImageInfo; @@ -133,7 +133,7 @@ public: //### MyDisplay *xd; GC gc; - QTestLiteWindowSurface *windowSurface; + QTestLiteWindow *windowTL; int currentCursor; bool painted; -- cgit v0.12 From 662eab575f3678364fbd3f317624fdd840e03c3c Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 9 Apr 2010 10:25:59 +0200 Subject: port linuxfb to platform api name change --- src/plugins/platforms/linuxfb/linuxfb.pro | 4 +- src/plugins/platforms/linuxfb/main.cpp | 14 +++--- .../platforms/linuxfb/qgraphicssystem_linuxfb.cpp | 52 +++++++++++----------- .../platforms/linuxfb/qgraphicssystem_linuxfb.h | 22 ++++----- 4 files changed, 45 insertions(+), 47 deletions(-) diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro index 031b843..2633a10 100644 --- a/src/plugins/platforms/linuxfb/linuxfb.pro +++ b/src/plugins/platforms/linuxfb/linuxfb.pro @@ -1,12 +1,12 @@ TARGET = qlinuxfbgraphicssystem include(../../qpluginbase.pri) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms SOURCES = main.cpp qgraphicssystem_linuxfb.cpp HEADERS = qgraphicssystem_linuxfb.h include(../fb_base/fb_base.pri) -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/linuxfb/main.cpp b/src/plugins/platforms/linuxfb/main.cpp index 4d03fe5..4f7684b 100644 --- a/src/plugins/platforms/linuxfb/main.cpp +++ b/src/plugins/platforms/linuxfb/main.cpp @@ -39,33 +39,33 @@ ** ****************************************************************************/ -#include +#include #include "qgraphicssystem_linuxfb.h" QT_BEGIN_NAMESPACE -class QLinuxFbGraphicsSystemPlugin : public QGraphicsSystemPlugin +class QLinuxFbIntegrationPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QGraphicsSystem *create(const QString&); + QPlatformIntegration *create(const QString&); }; -QStringList QLinuxFbGraphicsSystemPlugin::keys() const +QStringList QLinuxFbIntegrationPlugin::keys() const { QStringList list; list << "LinuxFb"; return list; } -QGraphicsSystem* QLinuxFbGraphicsSystemPlugin::create(const QString& system) +QPlatformIntegration* QLinuxFbIntegrationPlugin::create(const QString& system) { if (system.toLower() == "linuxfb") - return new QLinuxFbGraphicsSystem; + return new QLinuxFbIntegration; return 0; } -Q_EXPORT_PLUGIN2(linuxfb, QLinuxFbGraphicsSystemPlugin) +Q_EXPORT_PLUGIN2(linuxfb, QLinuxFbIntegrationPlugin) QT_END_NAMESPACE diff --git a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp index 44960bb..6310062 100644 --- a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp +++ b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp @@ -69,11 +69,11 @@ QT_BEGIN_NAMESPACE -class QLinuxFbGraphicsSystemPrivate +class QLinuxFbPrivate { public: - QLinuxFbGraphicsSystemPrivate(); - ~QLinuxFbGraphicsSystemPrivate(); + QLinuxFbPrivate(); + ~QLinuxFbPrivate(); void openTty(); void closeTty(); @@ -94,7 +94,7 @@ public: QString displaySpec; }; -QLinuxFbGraphicsSystemPrivate::QLinuxFbGraphicsSystemPrivate() +QLinuxFbPrivate::QLinuxFbPrivate() : fd(-1), blank(true), doGraphicsMode(true), #ifdef QT_QWS_DEPTH_GENERIC doGenericColors(false), @@ -103,12 +103,12 @@ QLinuxFbGraphicsSystemPrivate::QLinuxFbGraphicsSystemPrivate() { } -QLinuxFbGraphicsSystemPrivate::~QLinuxFbGraphicsSystemPrivate() +QLinuxFbPrivate::~QLinuxFbPrivate() { closeTty(); } -void QLinuxFbGraphicsSystemPrivate::openTty() +void QLinuxFbPrivate::openTty() { const char *const devs[] = {"/dev/tty0", "/dev/tty", "/dev/console", 0}; @@ -139,7 +139,7 @@ void QLinuxFbGraphicsSystemPrivate::openTty() QT_WRITE(ttyfd, termctl, sizeof(termctl)); } -void QLinuxFbGraphicsSystemPrivate::closeTty() +void QLinuxFbPrivate::closeTty() { if (ttyfd == -1) return; @@ -155,9 +155,9 @@ void QLinuxFbGraphicsSystemPrivate::closeTty() ttyfd = -1; } -QLinuxFbGraphicsSystem::QLinuxFbGraphicsSystem() +QLinuxFbIntegration::QLinuxFbIntegration() { - d_ptr = new QLinuxFbGraphicsSystemPrivate(); + d_ptr = new QLinuxFbPrivate(); // XXX QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY")); @@ -168,20 +168,18 @@ QLinuxFbGraphicsSystem::QLinuxFbGraphicsSystem() // Create a QImage directly on the screen's framebuffer. // This is the blit target for copying windows to the screen. - mPrimaryScreen = new QLinuxFbGraphicsSystemScreen(data, w, h, lstep, - screenFormat); + mPrimaryScreen = new QLinuxFbScreen(data, w, h, lstep, screenFormat); mPrimaryScreen->setPhysicalSize(QSize(physWidth, physHeight)); - mScreens.append(mPrimaryScreen); } -QLinuxFbGraphicsSystem::~QLinuxFbGraphicsSystem() +QLinuxFbIntegration::~QLinuxFbIntegration() { delete mPrimaryScreen; delete d_ptr; } -bool QLinuxFbGraphicsSystem::connect(const QString &displaySpec) +bool QLinuxFbIntegration::connect(const QString &displaySpec) { const QStringList args = displaySpec.split(QLatin1Char(':')); @@ -411,7 +409,7 @@ bool QLinuxFbGraphicsSystem::connect(const QString &displaySpec) return true; } -bool QLinuxFbGraphicsSystem::initDevice() +bool QLinuxFbIntegration::initDevice() { d_ptr->openTty(); @@ -538,7 +536,7 @@ bool QLinuxFbGraphicsSystem::initDevice() return true; } -void QLinuxFbGraphicsSystem::setPixelFormat(struct fb_var_screeninfo info) +void QLinuxFbIntegration::setPixelFormat(struct fb_var_screeninfo info) { const fb_bitfield rgba[4] = { info.red, info.green, info.blue, info.transp }; @@ -626,7 +624,7 @@ void QLinuxFbGraphicsSystem::setPixelFormat(struct fb_var_screeninfo info) screenFormat = format; } -void QLinuxFbGraphicsSystem::createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo) +void QLinuxFbIntegration::createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo) { if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; @@ -756,7 +754,7 @@ void QLinuxFbGraphicsSystem::createPalette(fb_cmap &cmap, fb_var_screeninfo &vin } } -void QLinuxFbGraphicsSystem::blank(bool on) +void QLinuxFbIntegration::blank(bool on) { if (d_ptr->blank == on) return; @@ -781,22 +779,22 @@ void QLinuxFbGraphicsSystem::blank(bool on) d_ptr->blank = on; } -QPixmapData *QLinuxFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +QPixmapData *QLinuxFbIntegration::createPixmapData(QPixmapData::PixelType type) const { return new QRasterPixmapData(type); } -QWindowSurface *QLinuxFbGraphicsSystem::createWindowSurface(QWidget *widget) const +QWindowSurface *QLinuxFbIntegration::createWindowSurface(QWidget *widget) const { if (widget->windowType() == Qt::Desktop) return 0; // Don't create an explicit window surface for the destkop. - QGraphicsSystemFbWindowSurface * surface = - new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); + QFbWindowSurface * surface = + new QFbWindowSurface(mPrimaryScreen, widget); mPrimaryScreen->addWindowSurface(surface); return surface; } -QLinuxFbGraphicsSystemScreen::QLinuxFbGraphicsSystemScreen(uchar * d, int w, +QLinuxFbScreen::QLinuxFbScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat) : compositePainter(0) { data = d; @@ -811,7 +809,7 @@ QLinuxFbGraphicsSystemScreen::QLinuxFbGraphicsSystemScreen(uchar * d, int w, cursor = new QGraphicsSystemSoftwareCursor(this); } -void QLinuxFbGraphicsSystemScreen::setGeometry(QRect rect) +void QLinuxFbScreen::setGeometry(QRect rect) { mGeometry = rect; delete mFbScreenImage; @@ -825,7 +823,7 @@ void QLinuxFbGraphicsSystemScreen::setGeometry(QRect rect) mFormat); } -void QLinuxFbGraphicsSystemScreen::setFormat(QImage::Format format) +void QLinuxFbScreen::setFormat(QImage::Format format) { mFormat = format; delete mFbScreenImage; @@ -839,10 +837,10 @@ void QLinuxFbGraphicsSystemScreen::setFormat(QImage::Format format) mFormat); } -QRegion QLinuxFbGraphicsSystemScreen::doRedraw() +QRegion QLinuxFbScreen::doRedraw() { QRegion touched; - touched = QGraphicsSystemFbScreen::doRedraw(); + touched = QFbPlatformScreen::doRedraw(); if (!compositePainter) { compositePainter = new QPainter(mFbScreenImage); diff --git a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h index cc8ce7e..bb4c920 100644 --- a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h +++ b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h @@ -42,15 +42,15 @@ #ifndef QGRAPHICSSYSTEM_LINUXFB_H #define QGRAPHICSSYSTEM_LINUXFB_H -#include +#include #include "../fb_base/fb_base.h" QT_BEGIN_NAMESPACE -class QLinuxFbGraphicsSystemScreen : public QGraphicsSystemFbScreen +class QLinuxFbScreen : public QFbPlatformScreen { public: - QLinuxFbGraphicsSystemScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat); + QLinuxFbScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat); void setGeometry(QRect rect); void setFormat(QImage::Format format); @@ -65,26 +65,26 @@ private: QPainter *compositePainter; }; -class QLinuxFbGraphicsSystemPrivate; +class QLinuxFbPrivate; struct fb_cmap; struct fb_var_screeninfo; struct fb_fix_screeninfo; -class QLinuxFbGraphicsSystem : public QGraphicsSystem +class QLinuxFbIntegration : public QPlatformIntegration { public: - QLinuxFbGraphicsSystem(); - ~QLinuxFbGraphicsSystem(); + QLinuxFbIntegration(); + ~QLinuxFbIntegration(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QWindowSurface *createWindowSurface(QWidget *widget) const; - QList screens() const { return mScreens; } + QList screens() const { return mScreens; } private: - QLinuxFbGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; - QLinuxFbGraphicsSystemPrivate *d_ptr; + QLinuxFbScreen *mPrimaryScreen; + QList mScreens; + QLinuxFbPrivate *d_ptr; enum PixelType { NormalPixel, BGRPixel }; -- cgit v0.12 From 9020859ae8cf450a8f32608d54adfde089128355 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 9 Apr 2010 12:53:32 +0200 Subject: This seems to fix the resize issues --- src/gui/kernel/qapplication_lite.cpp | 1 + src/gui/painting/qbackingstore.cpp | 19 ++++++++++++++----- .../platforms/testlite/qwindowsurface_testlite.cpp | 1 - 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index c8d65ff..87fa933 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -767,6 +767,7 @@ void QApplicationPrivate::processGeometryChange(QWidget *tlw, const QRect &newRe if (isResize) { QResizeEvent e(tlw->data->crect.size(), cr.size()); QApplication::sendSpontaneousEvent(tlw, &e); + tlw->update(); } if (isMove) { diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 30c042e..cc16fd0 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -419,9 +419,12 @@ void QWidgetBackingStore::endPaint(const QRegion &cleaned, QWindowSurface *windo QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const { const bool widgetDirty = widget && widget != tlw; -#if !defined(Q_WS_LITE) const QRect tlwRect(topLevelRect()); +#if defined(Q_WS_LITE) + const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size()); +#else const QRect surfaceGeometry(windowSurface->geometry()); +#endif if (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size()) { if (widgetDirty) { const QRect dirtyTlwRect = QRect(QPoint(), tlwRect.size()); @@ -431,7 +434,6 @@ QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const } return QRect(QPoint(), tlwRect.size()); } -#endif // Calculate the region that needs repaint. QRegion r(dirty); @@ -1156,11 +1158,14 @@ void QWidgetBackingStore::sync() const bool updatesDisabled = !tlw->updatesEnabled(); bool repaintAllWidgets = false; -#if !defined(Q_WS_LITE) + const bool inTopLevelResize = tlwExtra->inTopLevelResize; const QRect tlwRect(topLevelRect()); +#ifdef Q_WS_LITE + const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size()); +#else const QRect surfaceGeometry(windowSurface->geometry()); - +#endif if (inTopLevelResize || surfaceGeometry != tlwRect) { if ((inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) { if (hasStaticContents()) { @@ -1180,9 +1185,13 @@ void QWidgetBackingStore::sync() repaintAllWidgets = true; } } +#ifdef Q_WS_LITE + windowSurface->resize(tlwRect.size()); +#else windowSurface->setGeometry(tlwRect); - } #endif + } + if (updatesDisabled) return; diff --git a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp index 801491c..81fa247 100644 --- a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp @@ -165,7 +165,6 @@ bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) void QTestLiteWindowSurface::beginPaint(const QRegion ®ion) { Q_UNUSED(region); - qDebug() << "QTestLiteWindowSurface::beginPaint" << size(); xw->resizeBuffer(size()); } -- cgit v0.12 From 6dd82100e43749e3bd43b127587aa16a0bc4bbac Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 9 Apr 2010 17:25:22 +0200 Subject: Refactoring TestLite The x11util classes stopped being generic a long time ago. Now that we have a clean separation between surface and window in the API, it makes sense to have the platform-specific logic in the derived classes, instead of having an extra level of indirection. --- .../testlite/qplatformintegration_testlite.cpp | 9 +- src/plugins/platforms/testlite/qtestlitewindow.cpp | 1558 ++++++++++++++++++++ src/plugins/platforms/testlite/qtestlitewindow.h | 157 ++ .../platforms/testlite/qwindowsurface_testlite.cpp | 671 ++------- .../platforms/testlite/qwindowsurface_testlite.h | 54 +- src/plugins/platforms/testlite/testlite.pro | 8 +- src/plugins/platforms/testlite/x11util.cpp | 1215 --------------- src/plugins/platforms/testlite/x11util.h | 204 --- 8 files changed, 1860 insertions(+), 2016 deletions(-) create mode 100644 src/plugins/platforms/testlite/qtestlitewindow.cpp create mode 100644 src/plugins/platforms/testlite/qtestlitewindow.h delete mode 100644 src/plugins/platforms/testlite/x11util.cpp delete mode 100644 src/plugins/platforms/testlite/x11util.h diff --git a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp index 3e73821..f9b3135 100644 --- a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp +++ b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ + + #include "qplatformintegration_testlite.h" #include "qwindowsurface_testlite.h" #include @@ -47,7 +49,7 @@ #include -#include "x11util.h" +#include "qtestlitewindow.h" QT_BEGIN_NAMESPACE @@ -105,12 +107,11 @@ QWindowSurface *QTestLiteIntegration::createWindowSurfaceForWindow(QWidget *widg { if (widget->windowType() == Qt::Desktop) return 0; // Don't create an explicit window surface for the destkop. - return new QTestLiteWindowSurface - (const_cast(this), mPrimaryScreen, widget); + return new QTestLiteWindowSurface(mPrimaryScreen, widget); } -QPlatformWindow *QTestLiteIntegration::createPlatformWindow(QWidget *widget, WId winId) const +QPlatformWindow *QTestLiteIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const { return new QTestLiteWindow(const_cast(this), mPrimaryScreen, widget); } diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp new file mode 100644 index 0000000..db3904f --- /dev/null +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -0,0 +1,1558 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsurface_testlite.h" +#include "qplatformintegration_testlite.h" +#include + +#include "qtestlitewindow.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + + +#include + +#include + + + +//### remove stuff we don't want from qt_x11_p.h +#undef ATOM +#undef X11 + +QT_BEGIN_NAMESPACE + +static int (*original_x_errhandler)(Display *dpy, XErrorEvent *); +static bool seen_badwindow; + + +static Atom wmProtocolsAtom; +static Atom wmDeleteWindowAtom; + + + +class MyX11CursorNode +{ +public: + MyX11CursorNode(int id, Cursor c) { idValue = id; cursorValue = c; refCount = 1; } + QDateTime expiration() { return t; } + void setExpiration(QDateTime val) { t = val; } + MyX11CursorNode * ante() { return before; } + void setAnte(MyX11CursorNode *node) { before = node; } + MyX11CursorNode * post() { return after; } + void setPost(MyX11CursorNode *node) { after = node; } + Cursor cursor() { return cursorValue; } + int id() { return idValue; } + unsigned int refCount; + +private: + MyX11CursorNode *before; + MyX11CursorNode *after; + QDateTime t; + Cursor cursorValue; + int idValue; + + Display * display; +}; + + + + + +class MyX11Cursors : public QObject +{ + Q_OBJECT +public: + MyX11Cursors(Display * d); + ~MyX11Cursors() { timer.stop(); } + void incrementUseCount(int id); + void decrementUseCount(int id); + void createNode(int id, Cursor c); + bool exists(int id) { return lookupMap.contains(id); } + Cursor cursor(int id); +public slots: + void timeout(); + +private: + void removeNode(MyX11CursorNode *node); + void insertNode(MyX11CursorNode *node); + + // linked list of cursors currently not assigned to any window + MyX11CursorNode *firstExpired; + MyX11CursorNode *lastExpired; + + QHash lookupMap; + QTimer timer; + + Display *display; + + int removalDelay; +}; + + + + + +QTestLiteWindow::QTestLiteWindow(QTestLiteIntegration *platformIntegration, + QTestLiteScreen */*screen*/, QWidget *window) + :QPlatformWindow(window) +{ + xd = platformIntegration->xd; + xd->windowList.append(this); + { + int x = 0; + int y = 0; + int w = 300; + int h = 300; //### + + x_window = XCreateSimpleWindow(xd->display, xd->rootWindow(), + x, y, w, h, 0 /*border_width*/, + xd->blackPixel(), xd->whitePixel()); + + } + + width = -1; + height = -1; + xpos = -1; + ypos = -1; + + XSetWindowBackgroundPixmap(xd->display, x_window, XNone); + + XSelectInput(xd->display, x_window, ExposureMask | KeyPressMask | KeyReleaseMask | + EnterWindowMask | LeaveWindowMask | FocusChangeMask | + PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | + StructureNotifyMask); + + gc = createGC(); + + XChangeProperty (xd->display, x_window, + wmProtocolsAtom, + XA_ATOM, 32, PropModeAppend, + (unsigned char *) &wmDeleteWindowAtom, 1); + + + setWindowTitle(QLatin1String("Qt Lighthouse")); + + currentCursor = -1; + windowSurface = 0; + + setWindowFlags(window->windowFlags()); //##### This should not be the plugin's responsibility + + //xw->windowTL = this; +} + + +QTestLiteWindow::~QTestLiteWindow() +{ +#ifdef MYX11_DEBUG + qDebug() << "~QTestLiteWindow" << hex << x_window; +#endif + XFreeGC(xd->display, gc); + XDestroyWindow(xd->display, x_window); + + xd->windowList.removeAll(this); +} + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Mouse event stuff + + + + +static Qt::MouseButtons translateMouseButtons(int s) +{ + Qt::MouseButtons ret = 0; + if (s & Button1Mask) + ret |= Qt::LeftButton; + if (s & Button2Mask) + ret |= Qt::MidButton; + if (s & Button3Mask) + ret |= Qt::RightButton; + return ret; +} + + +static Qt::KeyboardModifiers translateModifiers(int s) +{ + const uchar qt_alt_mask = Mod1Mask; + const uchar qt_meta_mask = Mod4Mask; + + + Qt::KeyboardModifiers ret = 0; + if (s & ShiftMask) + ret |= Qt::ShiftModifier; + if (s & ControlMask) + ret |= Qt::ControlModifier; + if (s & qt_alt_mask) + ret |= Qt::AltModifier; + if (s & qt_meta_mask) + ret |= Qt::MetaModifier; +#if 0 + if (s & qt_mode_switch_mask) + ret |= Qt::GroupSwitchModifier; +#endif + return ret; +} + +void QTestLiteWindow::handleMouseEvent(QEvent::Type type, XButtonEvent *e) +{ + static QPoint mousePoint; + + Qt::MouseButton button = Qt::NoButton; + Qt::MouseButtons buttons = translateMouseButtons(e->state); + Qt::KeyboardModifiers modifiers = translateModifiers(e->state); + if (type != QEvent::MouseMove) { + switch (e->button) { + case Button1: button = Qt::LeftButton; break; + case Button2: button = Qt::MidButton; break; + case Button3: button = Qt::RightButton; break; + case Button4: + case Button5: + case 6: + case 7: { + //mouse wheel + if (type == QEvent::MouseButtonPress) { + //logic borrowed from qapplication_x11.cpp + int delta = 120 * ((e->button == Button4 || e->button == 6) ? 1 : -1); + bool hor = (((e->button == Button4 || e->button == Button5) + && (modifiers & Qt::AltModifier)) + || (e->button == 6 || e->button == 7)); + QWindowSystemInterface::handleWheelEvent(widget(), e->time, + QPoint(e->x, e->y), + QPoint(e->x_root, e->y_root), + delta, hor ? Qt::Horizontal : Qt::Vertical); + } + return; + } + default: break; + } + } + + buttons ^= button; // X event uses state *before*, Qt uses state *after* + + QWindowSystemInterface::handleMouseEvent(widget(), e->time, QPoint(e->x, e->y), + QPoint(e->x_root, e->y_root), + buttons); + + mousePoint = QPoint(e->x_root, e->y_root); +} + +void QTestLiteWindow::handleCloseEvent() +{ + QWindowSystemInterface::handleCloseEvent(widget()); +} + + +void QTestLiteWindow::handleEnterEvent() +{ + QWindowSystemInterface::handleEnterEvent(widget()); +} + +void QTestLiteWindow::handleLeaveEvent() +{ + QWindowSystemInterface::handleLeaveEvent(widget()); +} + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Key event stuff -- not pretty either +// +// What we want to do is to port Robert's keytable code properly + +// keyboard mapping table +static const unsigned int keyTbl[] = { + + // misc keys + + XK_Escape, Qt::Key_Escape, + XK_Tab, Qt::Key_Tab, + XK_ISO_Left_Tab, Qt::Key_Backtab, + XK_BackSpace, Qt::Key_Backspace, + XK_Return, Qt::Key_Return, + XK_Insert, Qt::Key_Insert, + XK_Delete, Qt::Key_Delete, + XK_Clear, Qt::Key_Delete, + XK_Pause, Qt::Key_Pause, + XK_Print, Qt::Key_Print, + 0x1005FF60, Qt::Key_SysReq, // hardcoded Sun SysReq + 0x1007ff00, Qt::Key_SysReq, // hardcoded X386 SysReq + + // cursor movement + + XK_Home, Qt::Key_Home, + XK_End, Qt::Key_End, + XK_Left, Qt::Key_Left, + XK_Up, Qt::Key_Up, + XK_Right, Qt::Key_Right, + XK_Down, Qt::Key_Down, + XK_Prior, Qt::Key_PageUp, + XK_Next, Qt::Key_PageDown, + + // modifiers + + XK_Shift_L, Qt::Key_Shift, + XK_Shift_R, Qt::Key_Shift, + XK_Shift_Lock, Qt::Key_Shift, + XK_Control_L, Qt::Key_Control, + XK_Control_R, Qt::Key_Control, + XK_Meta_L, Qt::Key_Meta, + XK_Meta_R, Qt::Key_Meta, + XK_Alt_L, Qt::Key_Alt, + XK_Alt_R, Qt::Key_Alt, + XK_Caps_Lock, Qt::Key_CapsLock, + XK_Num_Lock, Qt::Key_NumLock, + XK_Scroll_Lock, Qt::Key_ScrollLock, + XK_Super_L, Qt::Key_Super_L, + XK_Super_R, Qt::Key_Super_R, + XK_Menu, Qt::Key_Menu, + XK_Hyper_L, Qt::Key_Hyper_L, + XK_Hyper_R, Qt::Key_Hyper_R, + XK_Help, Qt::Key_Help, + 0x1000FF74, Qt::Key_Backtab, // hardcoded HP backtab + 0x1005FF10, Qt::Key_F11, // hardcoded Sun F36 (labeled F11) + 0x1005FF11, Qt::Key_F12, // hardcoded Sun F37 (labeled F12) + + // numeric and function keypad keys + + XK_KP_Space, Qt::Key_Space, + XK_KP_Tab, Qt::Key_Tab, + XK_KP_Enter, Qt::Key_Enter, + //XK_KP_F1, Qt::Key_F1, + //XK_KP_F2, Qt::Key_F2, + //XK_KP_F3, Qt::Key_F3, + //XK_KP_F4, Qt::Key_F4, + XK_KP_Home, Qt::Key_Home, + XK_KP_Left, Qt::Key_Left, + XK_KP_Up, Qt::Key_Up, + XK_KP_Right, Qt::Key_Right, + XK_KP_Down, Qt::Key_Down, + XK_KP_Prior, Qt::Key_PageUp, + XK_KP_Next, Qt::Key_PageDown, + XK_KP_End, Qt::Key_End, + XK_KP_Begin, Qt::Key_Clear, + XK_KP_Insert, Qt::Key_Insert, + XK_KP_Delete, Qt::Key_Delete, + XK_KP_Equal, Qt::Key_Equal, + XK_KP_Multiply, Qt::Key_Asterisk, + XK_KP_Add, Qt::Key_Plus, + XK_KP_Separator, Qt::Key_Comma, + XK_KP_Subtract, Qt::Key_Minus, + XK_KP_Decimal, Qt::Key_Period, + XK_KP_Divide, Qt::Key_Slash, + + // International input method support keys + + // International & multi-key character composition + XK_ISO_Level3_Shift, Qt::Key_AltGr, + XK_Multi_key, Qt::Key_Multi_key, + XK_Codeinput, Qt::Key_Codeinput, + XK_SingleCandidate, Qt::Key_SingleCandidate, + XK_MultipleCandidate, Qt::Key_MultipleCandidate, + XK_PreviousCandidate, Qt::Key_PreviousCandidate, + + // Misc Functions + XK_Mode_switch, Qt::Key_Mode_switch, + XK_script_switch, Qt::Key_Mode_switch, + + // Japanese keyboard support + XK_Kanji, Qt::Key_Kanji, + XK_Muhenkan, Qt::Key_Muhenkan, + //XK_Henkan_Mode, Qt::Key_Henkan_Mode, + XK_Henkan_Mode, Qt::Key_Henkan, + XK_Henkan, Qt::Key_Henkan, + XK_Romaji, Qt::Key_Romaji, + XK_Hiragana, Qt::Key_Hiragana, + XK_Katakana, Qt::Key_Katakana, + XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana, + XK_Zenkaku, Qt::Key_Zenkaku, + XK_Hankaku, Qt::Key_Hankaku, + XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku, + XK_Touroku, Qt::Key_Touroku, + XK_Massyo, Qt::Key_Massyo, + XK_Kana_Lock, Qt::Key_Kana_Lock, + XK_Kana_Shift, Qt::Key_Kana_Shift, + XK_Eisu_Shift, Qt::Key_Eisu_Shift, + XK_Eisu_toggle, Qt::Key_Eisu_toggle, + //XK_Kanji_Bangou, Qt::Key_Kanji_Bangou, + //XK_Zen_Koho, Qt::Key_Zen_Koho, + //XK_Mae_Koho, Qt::Key_Mae_Koho, + XK_Kanji_Bangou, Qt::Key_Codeinput, + XK_Zen_Koho, Qt::Key_MultipleCandidate, + XK_Mae_Koho, Qt::Key_PreviousCandidate, + +#ifdef XK_KOREAN + // Korean keyboard support + XK_Hangul, Qt::Key_Hangul, + XK_Hangul_Start, Qt::Key_Hangul_Start, + XK_Hangul_End, Qt::Key_Hangul_End, + XK_Hangul_Hanja, Qt::Key_Hangul_Hanja, + XK_Hangul_Jamo, Qt::Key_Hangul_Jamo, + XK_Hangul_Romaja, Qt::Key_Hangul_Romaja, + //XK_Hangul_Codeinput, Qt::Key_Hangul_Codeinput, + XK_Hangul_Codeinput, Qt::Key_Codeinput, + XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja, + XK_Hangul_Banja, Qt::Key_Hangul_Banja, + XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja, + XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja, + //XK_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate, + //XK_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate, + //XK_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate, + XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate, + XK_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate, + XK_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate, + XK_Hangul_Special, Qt::Key_Hangul_Special, + //XK_Hangul_switch, Qt::Key_Hangul_switch, + XK_Hangul_switch, Qt::Key_Mode_switch, +#endif // XK_KOREAN + + // dead keys + XK_dead_grave, Qt::Key_Dead_Grave, + XK_dead_acute, Qt::Key_Dead_Acute, + XK_dead_circumflex, Qt::Key_Dead_Circumflex, + XK_dead_tilde, Qt::Key_Dead_Tilde, + XK_dead_macron, Qt::Key_Dead_Macron, + XK_dead_breve, Qt::Key_Dead_Breve, + XK_dead_abovedot, Qt::Key_Dead_Abovedot, + XK_dead_diaeresis, Qt::Key_Dead_Diaeresis, + XK_dead_abovering, Qt::Key_Dead_Abovering, + XK_dead_doubleacute, Qt::Key_Dead_Doubleacute, + XK_dead_caron, Qt::Key_Dead_Caron, + XK_dead_cedilla, Qt::Key_Dead_Cedilla, + XK_dead_ogonek, Qt::Key_Dead_Ogonek, + XK_dead_iota, Qt::Key_Dead_Iota, + XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound, + XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound, + XK_dead_belowdot, Qt::Key_Dead_Belowdot, + XK_dead_hook, Qt::Key_Dead_Hook, + XK_dead_horn, Qt::Key_Dead_Horn, + +#if 0 + // Special multimedia keys + // currently only tested with MS internet keyboard + + // browsing keys + XF86XK_Back, Qt::Key_Back, + XF86XK_Forward, Qt::Key_Forward, + XF86XK_Stop, Qt::Key_Stop, + XF86XK_Refresh, Qt::Key_Refresh, + XF86XK_Favorites, Qt::Key_Favorites, + XF86XK_AudioMedia, Qt::Key_LaunchMedia, + XF86XK_OpenURL, Qt::Key_OpenUrl, + XF86XK_HomePage, Qt::Key_HomePage, + XF86XK_Search, Qt::Key_Search, + + // media keys + XF86XK_AudioLowerVolume, Qt::Key_VolumeDown, + XF86XK_AudioMute, Qt::Key_VolumeMute, + XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp, + XF86XK_AudioPlay, Qt::Key_MediaPlay, + XF86XK_AudioStop, Qt::Key_MediaStop, + XF86XK_AudioPrev, Qt::Key_MediaPrevious, + XF86XK_AudioNext, Qt::Key_MediaNext, + XF86XK_AudioRecord, Qt::Key_MediaRecord, + + // launch keys + XF86XK_Mail, Qt::Key_LaunchMail, + XF86XK_MyComputer, Qt::Key_Launch0, + XF86XK_Calculator, Qt::Key_Launch1, + XF86XK_Standby, Qt::Key_Standby, + + XF86XK_Launch0, Qt::Key_Launch2, + XF86XK_Launch1, Qt::Key_Launch3, + XF86XK_Launch2, Qt::Key_Launch4, + XF86XK_Launch3, Qt::Key_Launch5, + XF86XK_Launch4, Qt::Key_Launch6, + XF86XK_Launch5, Qt::Key_Launch7, + XF86XK_Launch6, Qt::Key_Launch8, + XF86XK_Launch7, Qt::Key_Launch9, + XF86XK_Launch8, Qt::Key_LaunchA, + XF86XK_Launch9, Qt::Key_LaunchB, + XF86XK_LaunchA, Qt::Key_LaunchC, + XF86XK_LaunchB, Qt::Key_LaunchD, + XF86XK_LaunchC, Qt::Key_LaunchE, + XF86XK_LaunchD, Qt::Key_LaunchF, +#endif + +#if 0 + // Qtopia keys + QTOPIAXK_Select, Qt::Key_Select, + QTOPIAXK_Yes, Qt::Key_Yes, + QTOPIAXK_No, Qt::Key_No, + QTOPIAXK_Cancel, Qt::Key_Cancel, + QTOPIAXK_Printer, Qt::Key_Printer, + QTOPIAXK_Execute, Qt::Key_Execute, + QTOPIAXK_Sleep, Qt::Key_Sleep, + QTOPIAXK_Play, Qt::Key_Play, + QTOPIAXK_Zoom, Qt::Key_Zoom, + QTOPIAXK_Context1, Qt::Key_Context1, + QTOPIAXK_Context2, Qt::Key_Context2, + QTOPIAXK_Context3, Qt::Key_Context3, + QTOPIAXK_Context4, Qt::Key_Context4, + QTOPIAXK_Call, Qt::Key_Call, + QTOPIAXK_Hangup, Qt::Key_Hangup, + QTOPIAXK_Flip, Qt::Key_Flip, +#endif + 0, 0 +}; + + +static int lookupCode(unsigned int xkeycode) +{ + if (xkeycode >= XK_F1 && xkeycode <= XK_F35) + return Qt::Key_F1 + (int(xkeycode) - XK_F1); + + const unsigned int *p = keyTbl; + while (*p) { + if (*p == xkeycode) + return *++p; + p += 2; + } + + return 0; +} + + +static Qt::KeyboardModifiers modifierFromKeyCode(int qtcode) +{ + switch (qtcode) { + case Qt::Key_Control: + return Qt::ControlModifier; + case Qt::Key_Alt: + return Qt::AltModifier; + case Qt::Key_Shift: + return Qt::ShiftModifier; + case Qt::Key_Meta: + return Qt::MetaModifier; + default: + return Qt::NoModifier; + } +} + +void QTestLiteWindow::handleKeyEvent(QEvent::Type type, void *ev) +{ + XKeyEvent *e = static_cast(ev); + + KeySym keySym; + QByteArray chars; + chars.resize(513); + + int count = XLookupString(e, chars.data(), chars.size(), &keySym, 0); + Q_UNUSED(count); +// qDebug() << "QTLWS::handleKeyEvent" << count << hex << "XKeysym:" << keySym; +// if (count) +// qDebug() << hex << int(chars[0]) << "String:" << chars; + + Qt::KeyboardModifiers modifiers = translateModifiers(e->state); + + int qtcode = lookupCode(keySym); +// qDebug() << "lookup: " << hex << keySym << qtcode << "mod" << modifiers; + + //X11 specifies state *before*, Qt expects state *after* the event + + modifiers ^= modifierFromKeyCode(qtcode); + + if (qtcode) { + QWindowSystemInterface::handleKeyEvent(widget(), e->time, type, qtcode, modifiers); + } else if (chars[0]) { + int qtcode = chars.toUpper()[0]; //Not exactly right... + if (modifiers & Qt::ControlModifier && qtcode < ' ') + qtcode = chars[0] + '@'; + QWindowSystemInterface::handleKeyEvent(widget(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars)); + } else { + qWarning() << "unknown X keycode" << hex << e->keycode << keySym; + } +} + +void QTestLiteWindow::setGeometry(const QRect &rect) +{ + QRect oldRect = geometry(); + if (rect == oldRect) + return; + + //if unchanged ### + XMoveResizeWindow(xd->display, x_window, rect.x(), rect.y(), rect.width(), rect.height()); +} + + +Qt::WindowFlags QTestLiteWindow::windowFlags() const +{ + return window_flags; +} + +WId QTestLiteWindow::winId() const +{ + return x_window; +} + +void QTestLiteWindow::raise() +{ + XRaiseWindow(mPlatformIntegration->xd->display, x_window); +} + +void QTestLiteWindow::lower() +{ + XLowerWindow(mPlatformIntegration->xd->display, x_window); +} + +void QTestLiteWindow::setWindowTitle(const QString &title) +{ + QByteArray ba = title.toLatin1(); //We're not making a general solution here... + XTextProperty windowName; + windowName.value = (unsigned char *)ba.constData(); + windowName.encoding = XA_STRING; + windowName.format = 8; + windowName.nitems = ba.length(); + + XSetWMName(xd->display, x_window, &windowName); +} + + + +GC QTestLiteWindow::createGC() +{ + GC gc; + + gc = XCreateGC(xd->display, x_window, 0, 0); + if (gc < 0) { + qWarning("QTestLiteWindow::createGC() could not create GC"); + } + return gc; +} + + +void QTestLiteWindow::paintEvent() +{ +#ifdef MYX11_DEBUG + qDebug() << "QTestLiteWindow::paintEvent" << shm_img.size() << painted; +#endif + + windowSurface->flush(windowSurface->window(), QRect(xpos,ypos,width, height), QPoint()); +} + + +void QTestLiteWindow::resizeEvent(XConfigureEvent *e) +{ + + if ((e->width != width || e->height != height) && e->x == 0 && e->y == 0) { + //qDebug() << "resize with bogus pos" << e->x << e->y << e->width << e->height << "window"<< hex << window; + } else { + //qDebug() << "geometry change" << e->x << e->y << e->width << e->height << "window"<< hex << window; + xpos = e->x; + ypos = e->y; + } + width = e->width; + height = e->height; + +#ifdef MYX11_DEBUG + qDebug() << hex << window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height << "img:" << shm_img.size(); +#endif + + QWindowSystemInterface::handleGeometryChange(widget(), QRect(xpos, ypos, width, height)); +} + + +void QTestLiteWindow::mousePressEvent(XButtonEvent *e) +{ + static long prevTime = 0; + static Window prevWindow; + static int prevX = -999; + static int prevY = -999; + + QEvent::Type type = QEvent::MouseButtonPress; + + if (e->window == prevWindow && long(e->time) - prevTime < QApplication::doubleClickInterval() + && qAbs(e->x - prevX) < 5 && qAbs(e->y - prevY) < 5) { + type = QEvent::MouseButtonDblClick; + prevTime = e->time - QApplication::doubleClickInterval(); //no double click next time + } else { + prevTime = e->time; + } + prevWindow = e->window; + prevX = e->x; + prevY = e->y; + + handleMouseEvent(type, e); +} + + + +// WindowFlag stuff, lots of copied code from qwidget_x11.cpp... + +//We're hacking here... + + +// MWM support +struct QtMWMHints { + ulong flags, functions, decorations; + long input_mode; + ulong status; +}; + +enum { + MWM_HINTS_FUNCTIONS = (1L << 0), + + MWM_FUNC_ALL = (1L << 0), + MWM_FUNC_RESIZE = (1L << 1), + MWM_FUNC_MOVE = (1L << 2), + MWM_FUNC_MINIMIZE = (1L << 3), + MWM_FUNC_MAXIMIZE = (1L << 4), + MWM_FUNC_CLOSE = (1L << 5), + + MWM_HINTS_DECORATIONS = (1L << 1), + + MWM_DECOR_ALL = (1L << 0), + MWM_DECOR_BORDER = (1L << 1), + MWM_DECOR_RESIZEH = (1L << 2), + MWM_DECOR_TITLE = (1L << 3), + MWM_DECOR_MENU = (1L << 4), + MWM_DECOR_MINIMIZE = (1L << 5), + MWM_DECOR_MAXIMIZE = (1L << 6), + + MWM_HINTS_INPUT_MODE = (1L << 2), + + MWM_INPUT_MODELESS = 0L, + MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L, + MWM_INPUT_FULL_APPLICATION_MODAL = 3L +}; + +static Atom mwm_hint_atom = XNone; + +#if 0 +static QtMWMHints GetMWMHints(Display *display, Window window) +{ + QtMWMHints mwmhints; + + Atom type; + int format; + ulong nitems, bytesLeft; + uchar *data = 0; + if ((XGetWindowProperty(display, window, mwm_hint_atom, 0, 5, false, + mwm_hint_atom, &type, &format, &nitems, &bytesLeft, + &data) == Success) + && (type == mwm_hint_atom + && format == 32 + && nitems >= 5)) { + mwmhints = *(reinterpret_cast(data)); + } else { + mwmhints.flags = 0L; + mwmhints.functions = MWM_FUNC_ALL; + mwmhints.decorations = MWM_DECOR_ALL; + mwmhints.input_mode = 0L; + mwmhints.status = 0L; + } + + if (data) + XFree(data); + + return mwmhints; +} +#endif + +static void SetMWMHints(Display *display, Window window, const QtMWMHints &mwmhints) +{ + if (mwmhints.flags != 0l) { + XChangeProperty(display, window, mwm_hint_atom, mwm_hint_atom, 32, + PropModeReplace, (unsigned char *) &mwmhints, 5); + } else { + XDeleteProperty(display, window, mwm_hint_atom); + } +} + +// 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)); +} + + + +Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags) +{ + Q_ASSERT(flags & Qt::Window); + window_flags = flags; + + if (mwm_hint_atom == XNone) { + mwm_hint_atom = XInternAtom(xd->display, "_MOTIF_WM_HINTS\0", False); + } + +#ifdef MYX11_DEBUG + qDebug() << "QTestLiteWindow::setWindowFlags" << hex << window << "flags" << flags; +#endif + Qt::WindowType type = static_cast(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); + + + bool tooltip = (type == Qt::ToolTip); + + XSetWindowAttributes wsa; + + QtMWMHints mwmhints; + mwmhints.flags = 0L; + mwmhints.functions = 0L; + mwmhints.decorations = 0; + mwmhints.input_mode = 0L; + mwmhints.status = 0L; + + + ulong wsa_mask = 0; + if (type != Qt::SplashScreen) { // && customize) { + 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 (tool) { + wsa.save_under = True; + wsa_mask |= CWSaveUnder; + } + + if (flags & Qt::X11BypassWindowManagerHint) { + wsa.override_redirect = True; + wsa_mask |= CWOverrideRedirect; + } +#if 0 + if (wsa_mask && initializeWindow) { + Q_ASSERT(id); + XChangeWindowAttributes(dpy, id, wsa_mask, &wsa); + } +#endif + 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; + } + + SetMWMHints(xd->display, x_window, mwmhints); + +//##### only if initializeWindow??? + + if (popup || tooltip) { // popup widget +#ifdef MYX11_DEBUG + qDebug() << "Doing XChangeWindowAttributes for popup" << wsa.override_redirect; +#endif + // set EWMH window types + // setNetWmWindowTypes(); + + wsa.override_redirect = True; + wsa.save_under = True; + XChangeWindowAttributes(xd->display, x_window, CWOverrideRedirect | CWSaveUnder, + &wsa); + } else { +#ifdef MYX11_DEBUG + qDebug() << "Doing XChangeWindowAttributes for non-popup"; +#endif + } + + return flags; +} + +void QTestLiteWindow::setVisible(bool visible) +{ +#ifdef MYX11_DEBUG + qDebug() << "QTestLiteWindow::setVisible" << visible << hex << window; +#endif + if (visible) + XMapWindow(xd->display, x_window); + else + XUnmapWindow(xd->display, x_window); +} + + +void QTestLiteWindow::setCursor(QCursor * cursor) +{ + int id = cursor->handle(); + if (id == currentCursor) + return; + Cursor c; + if (!xd->cursors->exists(id)) { + if (cursor->shape() == Qt::BitmapCursor) + c = createCursorBitmap(cursor); + else + c = createCursorShape(cursor->shape()); + if (!c) { + return; + } + xd->cursors->createNode(id, c); + } else { + xd->cursors->incrementUseCount(id); + c = xd->cursors->cursor(id); + } + + if (currentCursor != -1) + xd->cursors->decrementUseCount(currentCursor); + currentCursor = id; + + XDefineCursor(xd->display, x_window, c); + XFlush(xd->display); +} + +Cursor QTestLiteWindow::createCursorBitmap(QCursor * cursor) +{ + XColor bg, fg; + bg.red = 255 << 8; + bg.green = 255 << 8; + bg.blue = 255 << 8; + fg.red = 0; + fg.green = 0; + fg.blue = 0; + QPoint spot = cursor->hotSpot(); + Window rootwin = x_window; + + QImage mapImage = cursor->bitmap()->toImage().convertToFormat(QImage::Format_MonoLSB); + QImage maskImage = cursor->mask()->toImage().convertToFormat(QImage::Format_MonoLSB); + + int width = cursor->bitmap()->width(); + int height = cursor->bitmap()->height(); + int bytesPerLine = mapImage.bytesPerLine(); + int destLineSize = width / 8; + if (width % 8) + destLineSize++; + + const uchar * map = mapImage.bits(); + const uchar * mask = maskImage.bits(); + + char * mapBits = new char[height * destLineSize]; + char * maskBits = new char[height * destLineSize]; + for (int i = 0; i < height; i++) { + memcpy(mapBits + (destLineSize * i),map + (bytesPerLine * i), destLineSize); + memcpy(maskBits + (destLineSize * i),mask + (bytesPerLine * i), destLineSize); + } + + Pixmap cp = XCreateBitmapFromData(xd->display, rootwin, mapBits, width, height); + Pixmap mp = XCreateBitmapFromData(xd->display, rootwin, maskBits, width, height); + Cursor c = XCreatePixmapCursor(xd->display, cp, mp, &fg, &bg, spot.x(), spot.y()); + XFreePixmap(xd->display, cp); + XFreePixmap(xd->display, mp); + delete[] mapBits; + delete[] maskBits; + + return c; +} + +Cursor QTestLiteWindow::createCursorShape(int cshape) +{ + Cursor cursor = 0; + + if (cshape < 0 || cshape > Qt::LastCursor) + return 0; + + switch (cshape) { + case Qt::ArrowCursor: + cursor = XCreateFontCursor(xd->display, XC_left_ptr); + break; + case Qt::UpArrowCursor: + cursor = XCreateFontCursor(xd->display, XC_center_ptr); + break; + case Qt::CrossCursor: + cursor = XCreateFontCursor(xd->display, XC_crosshair); + break; + case Qt::WaitCursor: + cursor = XCreateFontCursor(xd->display, XC_watch); + break; + case Qt::IBeamCursor: + cursor = XCreateFontCursor(xd->display, XC_xterm); + break; + case Qt::SizeAllCursor: + cursor = XCreateFontCursor(xd->display, XC_fleur); + break; + case Qt::PointingHandCursor: + cursor = XCreateFontCursor(xd->display, XC_hand2); + break; + case Qt::SizeBDiagCursor: + cursor = XCreateFontCursor(xd->display, XC_top_right_corner); + break; + case Qt::SizeFDiagCursor: + cursor = XCreateFontCursor(xd->display, XC_bottom_right_corner); + break; + case Qt::SizeVerCursor: + case Qt::SplitVCursor: + cursor = XCreateFontCursor(xd->display, XC_sb_v_double_arrow); + break; + case Qt::SizeHorCursor: + case Qt::SplitHCursor: + cursor = XCreateFontCursor(xd->display, XC_sb_h_double_arrow); + break; + case Qt::WhatsThisCursor: + cursor = XCreateFontCursor(xd->display, XC_question_arrow); + break; + case Qt::ForbiddenCursor: + cursor = XCreateFontCursor(xd->display, XC_circle); + break; + case Qt::BusyCursor: + cursor = XCreateFontCursor(xd->display, XC_watch); + break; + + default: //default cursor for all the rest + break; + } + return cursor; +} + + +MyX11Cursors::MyX11Cursors(Display * d) : firstExpired(0), lastExpired(0), display(d), removalDelay(3) +{ + connect(&timer, SIGNAL(timeout()), this, SLOT(timeout())); +} + +void MyX11Cursors::insertNode(MyX11CursorNode * node) +{ + QDateTime now = QDateTime::currentDateTime(); + QDateTime timeout = now.addSecs(removalDelay); + node->setExpiration(timeout); + node->setPost(0); + if (lastExpired) { + lastExpired->setPost(node); + node->setAnte(lastExpired); + } + lastExpired = node; + if (!firstExpired) { + firstExpired = node; + node->setAnte(0); + int interval = removalDelay * 1000; + timer.setInterval(interval); + timer.start(); + } +} + +void MyX11Cursors::removeNode(MyX11CursorNode * node) +{ + MyX11CursorNode *pre = node->ante(); + MyX11CursorNode *post = node->post(); + if (pre) + pre->setPost(post); + if (post) + post->setAnte(pre); + if (node == lastExpired) + lastExpired = pre; + if (node == firstExpired) { + firstExpired = post; + if (!firstExpired) { + timer.stop(); + return; + } + int interval = QDateTime::currentDateTime().secsTo(firstExpired->expiration()) * 1000; + timer.stop(); + timer.setInterval(interval); + timer.start(); + } +} + +void MyX11Cursors::incrementUseCount(int id) +{ + MyX11CursorNode * node = lookupMap.value(id); + Q_ASSERT(node); + if (!node->refCount) + removeNode(node); + node->refCount++; +} + +void MyX11Cursors::decrementUseCount(int id) +{ + MyX11CursorNode * node = lookupMap.value(id); + Q_ASSERT(node); + node->refCount--; + if (!node->refCount) + insertNode(node); +} + +void MyX11Cursors::createNode(int id, Cursor c) +{ + MyX11CursorNode * node = new MyX11CursorNode(id, c); + lookupMap.insert(id, node); +} + +void MyX11Cursors::timeout() +{ + MyX11CursorNode * node; + node = firstExpired; + QDateTime now = QDateTime::currentDateTime(); + while (node && now.secsTo(node->expiration()) < 1) { + Cursor c = node->cursor(); + int id = node->id(); + lookupMap.take(id); + MyX11CursorNode * tmp = node; + node = node->post(); + delete tmp; + XFreeCursor(display, c); + } + firstExpired = node; + if (node == 0) { + timer.stop(); + lastExpired = 0; + } + else { + int interval = QDateTime::currentDateTime().secsTo(firstExpired->expiration()) * 1000; + timer.setInterval(interval); + timer.start(); + } +} + +Cursor MyX11Cursors::cursor(int id) +{ + MyX11CursorNode * node = lookupMap.value(id); + Q_ASSERT(node); + return node->cursor(); +} + + + +/******************************************************************** + +MyDisplay class - perhaps better placed in qplatformintegration_testlite? + +*********************************************************************/ + +//### copied from qapplication_x11.cpp + +static int qt_x_errhandler(Display *dpy, XErrorEvent *err) +{ + +qDebug() << "qt_x_errhandler" << err->error_code; + + switch (err->error_code) { + case BadAtom: +#if 0 + if (err->request_code == 20 /* X_GetProperty */ + && (err->resourceid == XA_RESOURCE_MANAGER + || err->resourceid == XA_RGB_DEFAULT_MAP + || err->resourceid == ATOM(_NET_SUPPORTED) + || err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK) + || err->resourceid == ATOM(KDE_FULL_SESSION) + || err->resourceid == ATOM(KWIN_RUNNING) + || err->resourceid == ATOM(XdndProxy) + || err->resourceid == ATOM(XdndAware)) + + + ) { + // Perhaps we're running under SECURITY reduction? :/ + return 0; + } +#endif + qDebug() << "BadAtom"; + break; + + case BadWindow: + if (err->request_code == 2 /* X_ChangeWindowAttributes */ + || err->request_code == 38 /* X_QueryPointer */) { + for (int i = 0; i < ScreenCount(dpy); ++i) { + if (err->resourceid == RootWindow(dpy, i)) { + // Perhaps we're running under SECURITY reduction? :/ + return 0; + } + } + } + seen_badwindow = true; + if (err->request_code == 25 /* X_SendEvent */) { + for (int i = 0; i < ScreenCount(dpy); ++i) { + if (err->resourceid == RootWindow(dpy, i)) { + // Perhaps we're running under SECURITY reduction? :/ + return 0; + } + } +#if 0 + if (X11->xdndHandleBadwindow()) { + qDebug("xdndHandleBadwindow returned true"); + return 0; + } +#endif + } +#if 0 + if (X11->ignore_badwindow) + return 0; +#endif + break; + + case BadMatch: + if (err->request_code == 42 /* X_SetInputFocus */) + return 0; + break; + + default: +#if 0 //!defined(QT_NO_XINPUT) + if (err->request_code == X11->xinput_major + && err->error_code == (X11->xinput_errorbase + XI_BadDevice) + && err->minor_code == 3 /* X_OpenDevice */) { + return 0; + } +#endif + break; + } + + char errstr[256]; + XGetErrorText( dpy, err->error_code, errstr, 256 ); + char buffer[256]; + char request_str[256]; + qsnprintf(buffer, 256, "%d", err->request_code); + XGetErrorDatabaseText(dpy, "XRequest", buffer, "", request_str, 256); + if (err->request_code < 128) { + // X error for a normal protocol request + qWarning( "X Error: %s %d\n" + " Major opcode: %d (%s)\n" + " Resource id: 0x%lx", + errstr, err->error_code, + err->request_code, + request_str, + err->resourceid ); + } else { + // X error for an extension request + const char *extensionName = 0; +#if 0 + if (err->request_code == X11->xrender_major) + extensionName = "RENDER"; + else if (err->request_code == X11->xrandr_major) + extensionName = "RANDR"; + else if (err->request_code == X11->xinput_major) + extensionName = "XInputExtension"; + else if (err->request_code == X11->mitshm_major) + extensionName = "MIT-SHM"; +#endif + char minor_str[256]; + if (extensionName) { + qsnprintf(buffer, 256, "%s.%d", extensionName, err->minor_code); + XGetErrorDatabaseText(dpy, "XRequest", buffer, "", minor_str, 256); + } else { + extensionName = "Uknown extension"; + qsnprintf(minor_str, 256, "Unknown request"); + } + qWarning( "X Error: %s %d\n" + " Extension: %d (%s)\n" + " Minor opcode: %d (%s)\n" + " Resource id: 0x%lx", + errstr, err->error_code, + err->request_code, + extensionName, + err->minor_code, + minor_str, + err->resourceid ); + } + + // ### we really should distinguish between severe, non-severe and + // ### application specific errors + + return 0; +} + + +#ifdef KeyPress +#undef KeyPress +#endif +#ifdef KeyRelease +#undef KeyRelease +#endif + +bool MyDisplay::handleEvent(XEvent *xe) +{ + //qDebug() << "handleEvent" << xe->xany.type << xe->xany.window; + int quit = false; + QTestLiteWindow *xw = 0; + foreach (QTestLiteWindow *w, windowList) { + if (w->winId() == xe->xany.window) { + xw = w; + break; + } + } + if (!xw) { +#ifdef MYX11_DEBUG + qWarning() << "Unknown window" << hex << xe->xany.window << "received event" << xe->type; +#endif + return quit; + } + + switch (xe->type) { + + case ClientMessage: + if (xe->xclient.format == 32 && xe->xclient.message_type == wmProtocolsAtom) { + Atom a = xe->xclient.data.l[0]; + if (a == wmDeleteWindowAtom) + xw->handleCloseEvent(); +#ifdef MYX11_DEBUG + qDebug() << "ClientMessage WM_PROTOCOLS" << a; +#endif + } +#ifdef MYX11_DEBUG + else + qDebug() << "ClientMessage" << xe->xclient.format << xe->xclient.message_type; +#endif + break; + + case Expose: + if (xw) + if (xe->xexpose.count == 0) + xw->paintEvent(); + break; + case ConfigureNotify: + if (xw) + xw->resizeEvent(&xe->xconfigure); + break; + + case ButtonPress: + xw->mousePressEvent(&xe->xbutton); + break; + + case ButtonRelease: + xw->handleMouseEvent(QEvent::MouseButtonRelease, &xe->xbutton); + break; + + case MotionNotify: + xw->handleMouseEvent(QEvent::MouseMove, &xe->xbutton); + break; + + case XKeyPress: + xw->handleKeyEvent(QEvent::KeyPress, &xe->xkey); + break; + + case XKeyRelease: + xw->handleKeyEvent(QEvent::KeyRelease, &xe->xkey); + break; + + case EnterNotify: + xw->handleEnterEvent(); + break; + + case LeaveNotify: + xw->handleLeaveEvent(); + break; + + default: +#ifdef MYX11_DEBUG + qDebug() << hex << xe->xany.window << "Other X event" << xe->type; +#endif + break; + } + return quit; +}; + + + +MyDisplay::MyDisplay() +{ + char *display_name = getenv("DISPLAY"); + display = XOpenDisplay(display_name); + if (!display) { + fprintf(stderr, "Cannot connect to X server: %s\n", + display_name); + exit(1); + } + +#ifndef DONT_USE_MIT_SHM + Status MIT_SHM_extension_supported = XShmQueryExtension (display); + Q_ASSERT(MIT_SHM_extension_supported == True); +#endif + original_x_errhandler = XSetErrorHandler(qt_x_errhandler); + + if (qgetenv("DO_X_SYNCHRONIZE").toInt()) + XSynchronize(display, true); + + screen = DefaultScreen(display); + width = DisplayWidth(display, screen); + height = DisplayHeight(display, screen); + physicalWidth = DisplayWidthMM(display, screen); + physicalHeight = DisplayHeightMM(display, screen); + + int xSocketNumber = XConnectionNumber(display); +#ifdef MYX11_DEBUG + qDebug() << "X socket:"<< xSocketNumber; +#endif + QSocketNotifier *sock = new QSocketNotifier(xSocketNumber, QSocketNotifier::Read, this); + connect(sock, SIGNAL(activated(int)), this, SLOT(eventDispatcher())); + + wmProtocolsAtom = XInternAtom (display, "WM_PROTOCOLS", False); + wmDeleteWindowAtom = XInternAtom (display, "WM_DELETE_WINDOW", False); + + cursors = new MyX11Cursors(display); +} + + +MyDisplay::~MyDisplay() +{ + XCloseDisplay(display); +} + + +void MyDisplay::eventDispatcher() +{ +// qDebug() << "eventDispatcher"; + + + ulong marker = XNextRequest(display); +// int i = 0; + while (XPending(display)) { + XEvent event; + XNextEvent(display, &event); + /* done = */ + handleEvent(&event); + + if (event.xany.serial >= marker) { +#ifdef MYX11_DEBUG + qDebug() << "potential livelock averted"; +#endif +#if 0 + if (XEventsQueued(display, QueuedAfterFlush)) { + qDebug() << " with events queued"; + QTimer::singleShot(0, this, SLOT(eventDispatcher())); + } +#endif + break; + } + } +} + + +QImage MyDisplay::grabWindow(Window window, int x, int y, int w, int h) +{ + if (w == 0 || h ==0) + return QImage(); + + //WinId 0 means the desktop widget + if (!window) + window = rootWindow(); + + XWindowAttributes window_attr; + if (!XGetWindowAttributes(display, window, &window_attr)) + return QImage(); + + if (w < 0) + w = window_attr.width - x; + if (h < 0) + h = window_attr.height - y; + + // Ideally, we should also limit ourselves to the screen area, but the Qt docs say + // that it's "unsafe" to go outside the screen, so we can ignore that problem. + + //We're definitely not optimizing for speed... + XImage *xi = XGetImage(display, window, x, y, w, h, AllPlanes, ZPixmap); + + if (!xi) + return QImage(); + + //taking a copy to make sure we have ownership -- not fast + QImage result = QImage( (uchar*) xi->data, xi->width, xi->height, xi->bytes_per_line, QImage::Format_RGB32 ).copy(); + + XDestroyImage(xi); + + return result; +} + + + + + + + +QT_END_NAMESPACE +#include "qtestlitewindow.moc" diff --git a/src/plugins/platforms/testlite/qtestlitewindow.h b/src/plugins/platforms/testlite/qtestlitewindow.h new file mode 100644 index 0000000..6fb7ed2 --- /dev/null +++ b/src/plugins/platforms/testlite/qtestlitewindow.h @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTESTLITEWINDOW_H +#define QTESTLITEWINDOW_H + +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include + + + +class QTestLiteIntegration; +class QTestLiteScreen; +class QTestLiteWindowSurface; +class MyX11Cursors; +class QTestLiteWindow; + +class MyDisplay : public QObject +{ + Q_OBJECT; +public: + MyDisplay(); + ~MyDisplay(); + + Window rootWindow() { return RootWindow(display, screen); } + unsigned long blackPixel() { return BlackPixel(display, screen); } + unsigned long whitePixel() { return WhitePixel(display, screen); } + + bool handleEvent(XEvent *xe); + QImage grabWindow(Window window, int x, int y, int w, int h); + +public slots: + void eventDispatcher(); + +public: //### + Display * display; + int screen; + int width, height; + int physicalWidth; + int physicalHeight; + + QList windowList; + + MyX11Cursors * cursors; +}; + +struct MyShmImageInfo; + +class QWindowSurface; + +class QTestLiteWindow : public QPlatformWindow +{ +public: + QTestLiteWindow(QTestLiteIntegration *platformIntegration, + QTestLiteScreen *screen, QWidget *window); + ~QTestLiteWindow(); + + + void mousePressEvent(XButtonEvent*); + void handleMouseEvent(QEvent::Type, XButtonEvent *ev); + + void handleKeyEvent(QEvent::Type, void *); + void handleCloseEvent(); + void handleEnterEvent(); + void handleLeaveEvent(); + + void resizeEvent(XConfigureEvent *configure_event); + void paintEvent(); + + + void setGeometry(const QRect &rect); + + Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); + Qt::WindowFlags windowFlags() const; + void setVisible(bool visible); + WId winId() const; + void raise(); + void lower(); + void setWindowTitle(const QString &title); + + void setCursor(QCursor * cursor); + +private: + int xpos, ypos; + int width, height; + Window x_window; + GC gc; + + GC createGC(); + Cursor createCursorShape(int cshape); + Cursor createCursorBitmap(QCursor * cursor); + + int currentCursor; + + QWindowSurface *windowSurface; + MyDisplay *xd; + + QTestLiteIntegration *mPlatformIntegration; + QTestLiteScreen *mScreen; + Qt::WindowFlags window_flags; + + friend class QTestLiteWindowSurface; // x_window, gc and windowSurface +}; + + + + + +#endif diff --git a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp index 81fa247..b5a0f74 100644 --- a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp @@ -45,36 +45,108 @@ #include #include -#include "x11util.h" +#include "qtestlitewindow.h" + +# include +# include +# include QT_BEGIN_NAMESPACE -QTestLiteWindowSurface::QTestLiteWindowSurface - (QTestLiteIntegration *platformIntegration, - QTestLiteScreen *screen, QWidget *window) - : QWindowSurface(window), - mPlatformIntegration(platformIntegration), - mScreen(screen), - xw(0) + +struct MyShmImageInfo { + MyShmImageInfo(Display *xdisplay) : image(0), display(xdisplay) {} + ~MyShmImageInfo() { destroy(); } + + void destroy(); + + XShmSegmentInfo shminfo; + XImage *image; + Display *display; +}; + +//void QTestLiteWindowSurface::flush() + + +#ifndef DONT_USE_MIT_SHM +void MyShmImageInfo::destroy() +{ + XShmDetach (display, &shminfo); + XDestroyImage (image); + shmdt (shminfo.shmaddr); + shmctl (shminfo.shmid, IPC_RMID, 0); +} +#endif + +void QTestLiteWindowSurface::resizeShmImage(int width, int height) { + MyDisplay *xd = xw->xd; - xw = static_cast(window->platformWindow())->xw; -// xw = new MyWindow(platformIntegration->xd, 0,0,300,300); +#ifdef DONT_USE_MIT_SHM + shm_img = QImage(width, height, QImage::Format_RGB32); +#else + if (image_info) + image_info->destroy(); + else + image_info = new MyShmImageInfo(xd->display); -// qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window; + Visual *visual = DefaultVisual(xd->display, xd->screen); + + + XImage *image = XShmCreateImage (xd->display, visual, 24, ZPixmap, 0, + &image_info->shminfo, width, height); + + + image_info->shminfo.shmid = shmget (IPC_PRIVATE, + image->bytes_per_line * image->height, IPC_CREAT|0777); + + image_info->shminfo.shmaddr = image->data = (char*)shmat (image_info->shminfo.shmid, 0, 0); + image_info->shminfo.readOnly = False; + image_info->image = image; + + Status shm_attach_status = XShmAttach(xd->display, &image_info->shminfo); + + Q_ASSERT(shm_attach_status == True); + + shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, QImage::Format_RGB32 ); +#endif + painted = false; +} + + +void QTestLiteWindowSurface::resizeBuffer(QSize s) +{ + if (shm_img.size() != s) + resizeShmImage(s.width(), s.height()); +} + +QSize QTestLiteWindowSurface::bufferSize() const +{ + return shm_img.size(); +} + +QTestLiteWindowSurface::QTestLiteWindowSurface (QTestLiteScreen */*screen*/, QWidget *window) + : QWindowSurface(window), + painted(false), image_info(0) +{ + xw = static_cast(window->platformWindow()); + xw->windowSurface = this; +// qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window; } QTestLiteWindowSurface::~QTestLiteWindowSurface() { -// qDebug() << "~QTestLiteWindowSurface" << xw->window; + qDebug() << "~QTestLiteWindowSurface"; + delete image_info; } QPaintDevice *QTestLiteWindowSurface::paintDevice() { - return xw->image(); + return &shm_img; } + void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(widget); @@ -83,22 +155,48 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const // qDebug() << "QTestLiteWindowSurface::flush:" << (long)this; - xw->paintEvent(); -} - + if (!painted) + return; -// void QTestLiteWindowSurface::resize(const QSize &s) -// { -// if (s == size()) -// return; + MyDisplay *xd = xw->xd; + GC gc = xw->gc; + Window window = xw->x_window; +#ifdef DONT_USE_MIT_SHM + // just convert the image every time... + if (!shm_img.isNull()) { + Visual *visual = DefaultVisual(xd->display, xd->screen); -// QWindowSurface::resize(size); + QImage image = shm_img; + //img.convertToFormat( + XImage *xi = XCreateImage(xd->display, visual, 24, ZPixmap, + 0, (char *) image.scanLine(0), image.width(), image.height(), + 32, image.bytesPerLine()); -// //if unchanged ### -// // xw->setSize(rect.width(), rect.height()); + int x = 0; + int y = 0; + /*int r =*/ XPutImage(xd->display, window, gc, xi, 0, 0, x, y, image.width(), image.height()); -// } + xi->data = 0; // QImage owns these bits + XDestroyImage(xi); + } +#else + // Use MIT_SHM + if (image_info->image) { + //qDebug() << "Here we go" << image_info->image->width << image_info->image->height; + int x = 0; + int y = 0; + + // We could set send_event to true, and then use the ShmCompletion to synchronize, + // but let's do like Qt/11 and just use XSync + XShmPutImage (xd->display, window, gc, image_info->image, 0, 0, + x, y, image_info->image->width, image_info->image->height, + /*send_event*/ False); + + XSync(xd->display, False); + } +#endif +} //### scroll logic copied from QRasterWindowSurface, we should make better API for this @@ -151,12 +249,12 @@ void copied_qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &o bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) { - if (!xw->image() || xw->image()->isNull()) + if (shm_img.isNull()) return false; const QVector rects = area.rects(); for (int i = 0; i < rects.size(); ++i) - copied_qt_scrollRectInImage(*xw->image(), rects.at(i), QPoint(dx, dy)); + copied_qt_scrollRectInImage(shm_img, rects.at(i), QPoint(dx, dy)); return true; } @@ -165,529 +263,12 @@ bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) void QTestLiteWindowSurface::beginPaint(const QRegion ®ion) { Q_UNUSED(region); - xw->resizeBuffer(size()); + resizeBuffer(size()); } void QTestLiteWindowSurface::endPaint(const QRegion ®ion) { Q_UNUSED(region); - xw->painted = true; //there is content in the buffer -} - - -/************************************************************************** -** QTestLiteWindow -**************************************************************************/ - -QTestLiteWindow::QTestLiteWindow(QTestLiteIntegration *platformIntegration, - QTestLiteScreen */*screen*/, QWidget *window) - :QPlatformWindow(window) -{ - xw = new MyWindow(platformIntegration->xd, 0,0,300,300); - setWindowFlags(window->windowFlags()); //##### This should not be the plugin's responsibility - - xw->windowTL = this; -} - - -QTestLiteWindow::~QTestLiteWindow() -{ - delete xw; -} - - - - - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Mouse event stuff - - - - -static Qt::MouseButtons translateMouseButtons(int s) -{ - Qt::MouseButtons ret = 0; - if (s & Button1Mask) - ret |= Qt::LeftButton; - if (s & Button2Mask) - ret |= Qt::MidButton; - if (s & Button3Mask) - ret |= Qt::RightButton; - return ret; -} - - -static Qt::KeyboardModifiers translateModifiers(int s) -{ - const uchar qt_alt_mask = Mod1Mask; - const uchar qt_meta_mask = Mod4Mask; - - - Qt::KeyboardModifiers ret = 0; - if (s & ShiftMask) - ret |= Qt::ShiftModifier; - if (s & ControlMask) - ret |= Qt::ControlModifier; - if (s & qt_alt_mask) - ret |= Qt::AltModifier; - if (s & qt_meta_mask) - ret |= Qt::MetaModifier; -#if 0 - if (s & qt_mode_switch_mask) - ret |= Qt::GroupSwitchModifier; -#endif - return ret; -} - -void QTestLiteWindow::handleMouseEvent(QEvent::Type type, void *ev) -{ - static QPoint mousePoint; - - XButtonEvent *e = static_cast(ev); - - Qt::MouseButton button = Qt::NoButton; - Qt::MouseButtons buttons = translateMouseButtons(e->state); - Qt::KeyboardModifiers modifiers = translateModifiers(e->state); - if (type != QEvent::MouseMove) { - switch (e->button) { - case Button1: button = Qt::LeftButton; break; - case Button2: button = Qt::MidButton; break; - case Button3: button = Qt::RightButton; break; - case Button4: - case Button5: - case 6: - case 7: { - //mouse wheel - if (type == QEvent::MouseButtonPress) { - //logic borrowed from qapplication_x11.cpp - int delta = 120 * ((e->button == Button4 || e->button == 6) ? 1 : -1); - bool hor = (((e->button == Button4 || e->button == Button5) - && (modifiers & Qt::AltModifier)) - || (e->button == 6 || e->button == 7)); - QWindowSystemInterface::handleWheelEvent(widget(), e->time, - QPoint(e->x, e->y), - QPoint(e->x_root, e->y_root), - delta, hor ? Qt::Horizontal : Qt::Vertical); - } - return; - } - default: break; - } - } - - buttons ^= button; // X event uses state *before*, Qt uses state *after* - - QWindowSystemInterface::handleMouseEvent(widget(), e->time, QPoint(e->x, e->y), - QPoint(e->x_root, e->y_root), - buttons); - - mousePoint = QPoint(e->x_root, e->y_root); -} - -void QTestLiteWindow::handleGeometryChange(int x, int y, int w, int h) -{ - QWindowSystemInterface::handleGeometryChange(widget(), QRect(x,y,w,h)); -} - - -void QTestLiteWindow::handleCloseEvent() -{ - QWindowSystemInterface::handleCloseEvent(widget()); -} - - -void QTestLiteWindow::handleEnterEvent() -{ - QWindowSystemInterface::handleEnterEvent(widget()); -} - -void QTestLiteWindow::handleLeaveEvent() -{ - QWindowSystemInterface::handleLeaveEvent(widget()); -} - - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Key event stuff -- not pretty either -// -// What we want to do is to port Robert's keytable code properly - - - - - - - -// keyboard mapping table -static const unsigned int keyTbl[] = { - - // misc keys - - XK_Escape, Qt::Key_Escape, - XK_Tab, Qt::Key_Tab, - XK_ISO_Left_Tab, Qt::Key_Backtab, - XK_BackSpace, Qt::Key_Backspace, - XK_Return, Qt::Key_Return, - XK_Insert, Qt::Key_Insert, - XK_Delete, Qt::Key_Delete, - XK_Clear, Qt::Key_Delete, - XK_Pause, Qt::Key_Pause, - XK_Print, Qt::Key_Print, - 0x1005FF60, Qt::Key_SysReq, // hardcoded Sun SysReq - 0x1007ff00, Qt::Key_SysReq, // hardcoded X386 SysReq - - // cursor movement - - XK_Home, Qt::Key_Home, - XK_End, Qt::Key_End, - XK_Left, Qt::Key_Left, - XK_Up, Qt::Key_Up, - XK_Right, Qt::Key_Right, - XK_Down, Qt::Key_Down, - XK_Prior, Qt::Key_PageUp, - XK_Next, Qt::Key_PageDown, - - // modifiers - - XK_Shift_L, Qt::Key_Shift, - XK_Shift_R, Qt::Key_Shift, - XK_Shift_Lock, Qt::Key_Shift, - XK_Control_L, Qt::Key_Control, - XK_Control_R, Qt::Key_Control, - XK_Meta_L, Qt::Key_Meta, - XK_Meta_R, Qt::Key_Meta, - XK_Alt_L, Qt::Key_Alt, - XK_Alt_R, Qt::Key_Alt, - XK_Caps_Lock, Qt::Key_CapsLock, - XK_Num_Lock, Qt::Key_NumLock, - XK_Scroll_Lock, Qt::Key_ScrollLock, - XK_Super_L, Qt::Key_Super_L, - XK_Super_R, Qt::Key_Super_R, - XK_Menu, Qt::Key_Menu, - XK_Hyper_L, Qt::Key_Hyper_L, - XK_Hyper_R, Qt::Key_Hyper_R, - XK_Help, Qt::Key_Help, - 0x1000FF74, Qt::Key_Backtab, // hardcoded HP backtab - 0x1005FF10, Qt::Key_F11, // hardcoded Sun F36 (labeled F11) - 0x1005FF11, Qt::Key_F12, // hardcoded Sun F37 (labeled F12) - - // numeric and function keypad keys - - XK_KP_Space, Qt::Key_Space, - XK_KP_Tab, Qt::Key_Tab, - XK_KP_Enter, Qt::Key_Enter, - //XK_KP_F1, Qt::Key_F1, - //XK_KP_F2, Qt::Key_F2, - //XK_KP_F3, Qt::Key_F3, - //XK_KP_F4, Qt::Key_F4, - XK_KP_Home, Qt::Key_Home, - XK_KP_Left, Qt::Key_Left, - XK_KP_Up, Qt::Key_Up, - XK_KP_Right, Qt::Key_Right, - XK_KP_Down, Qt::Key_Down, - XK_KP_Prior, Qt::Key_PageUp, - XK_KP_Next, Qt::Key_PageDown, - XK_KP_End, Qt::Key_End, - XK_KP_Begin, Qt::Key_Clear, - XK_KP_Insert, Qt::Key_Insert, - XK_KP_Delete, Qt::Key_Delete, - XK_KP_Equal, Qt::Key_Equal, - XK_KP_Multiply, Qt::Key_Asterisk, - XK_KP_Add, Qt::Key_Plus, - XK_KP_Separator, Qt::Key_Comma, - XK_KP_Subtract, Qt::Key_Minus, - XK_KP_Decimal, Qt::Key_Period, - XK_KP_Divide, Qt::Key_Slash, - - // International input method support keys - - // International & multi-key character composition - XK_ISO_Level3_Shift, Qt::Key_AltGr, - XK_Multi_key, Qt::Key_Multi_key, - XK_Codeinput, Qt::Key_Codeinput, - XK_SingleCandidate, Qt::Key_SingleCandidate, - XK_MultipleCandidate, Qt::Key_MultipleCandidate, - XK_PreviousCandidate, Qt::Key_PreviousCandidate, - - // Misc Functions - XK_Mode_switch, Qt::Key_Mode_switch, - XK_script_switch, Qt::Key_Mode_switch, - - // Japanese keyboard support - XK_Kanji, Qt::Key_Kanji, - XK_Muhenkan, Qt::Key_Muhenkan, - //XK_Henkan_Mode, Qt::Key_Henkan_Mode, - XK_Henkan_Mode, Qt::Key_Henkan, - XK_Henkan, Qt::Key_Henkan, - XK_Romaji, Qt::Key_Romaji, - XK_Hiragana, Qt::Key_Hiragana, - XK_Katakana, Qt::Key_Katakana, - XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana, - XK_Zenkaku, Qt::Key_Zenkaku, - XK_Hankaku, Qt::Key_Hankaku, - XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku, - XK_Touroku, Qt::Key_Touroku, - XK_Massyo, Qt::Key_Massyo, - XK_Kana_Lock, Qt::Key_Kana_Lock, - XK_Kana_Shift, Qt::Key_Kana_Shift, - XK_Eisu_Shift, Qt::Key_Eisu_Shift, - XK_Eisu_toggle, Qt::Key_Eisu_toggle, - //XK_Kanji_Bangou, Qt::Key_Kanji_Bangou, - //XK_Zen_Koho, Qt::Key_Zen_Koho, - //XK_Mae_Koho, Qt::Key_Mae_Koho, - XK_Kanji_Bangou, Qt::Key_Codeinput, - XK_Zen_Koho, Qt::Key_MultipleCandidate, - XK_Mae_Koho, Qt::Key_PreviousCandidate, - -#ifdef XK_KOREAN - // Korean keyboard support - XK_Hangul, Qt::Key_Hangul, - XK_Hangul_Start, Qt::Key_Hangul_Start, - XK_Hangul_End, Qt::Key_Hangul_End, - XK_Hangul_Hanja, Qt::Key_Hangul_Hanja, - XK_Hangul_Jamo, Qt::Key_Hangul_Jamo, - XK_Hangul_Romaja, Qt::Key_Hangul_Romaja, - //XK_Hangul_Codeinput, Qt::Key_Hangul_Codeinput, - XK_Hangul_Codeinput, Qt::Key_Codeinput, - XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja, - XK_Hangul_Banja, Qt::Key_Hangul_Banja, - XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja, - XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja, - //XK_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate, - //XK_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate, - //XK_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate, - XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate, - XK_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate, - XK_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate, - XK_Hangul_Special, Qt::Key_Hangul_Special, - //XK_Hangul_switch, Qt::Key_Hangul_switch, - XK_Hangul_switch, Qt::Key_Mode_switch, -#endif // XK_KOREAN - - // dead keys - XK_dead_grave, Qt::Key_Dead_Grave, - XK_dead_acute, Qt::Key_Dead_Acute, - XK_dead_circumflex, Qt::Key_Dead_Circumflex, - XK_dead_tilde, Qt::Key_Dead_Tilde, - XK_dead_macron, Qt::Key_Dead_Macron, - XK_dead_breve, Qt::Key_Dead_Breve, - XK_dead_abovedot, Qt::Key_Dead_Abovedot, - XK_dead_diaeresis, Qt::Key_Dead_Diaeresis, - XK_dead_abovering, Qt::Key_Dead_Abovering, - XK_dead_doubleacute, Qt::Key_Dead_Doubleacute, - XK_dead_caron, Qt::Key_Dead_Caron, - XK_dead_cedilla, Qt::Key_Dead_Cedilla, - XK_dead_ogonek, Qt::Key_Dead_Ogonek, - XK_dead_iota, Qt::Key_Dead_Iota, - XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound, - XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound, - XK_dead_belowdot, Qt::Key_Dead_Belowdot, - XK_dead_hook, Qt::Key_Dead_Hook, - XK_dead_horn, Qt::Key_Dead_Horn, - -#if 0 - // Special multimedia keys - // currently only tested with MS internet keyboard - - // browsing keys - XF86XK_Back, Qt::Key_Back, - XF86XK_Forward, Qt::Key_Forward, - XF86XK_Stop, Qt::Key_Stop, - XF86XK_Refresh, Qt::Key_Refresh, - XF86XK_Favorites, Qt::Key_Favorites, - XF86XK_AudioMedia, Qt::Key_LaunchMedia, - XF86XK_OpenURL, Qt::Key_OpenUrl, - XF86XK_HomePage, Qt::Key_HomePage, - XF86XK_Search, Qt::Key_Search, - - // media keys - XF86XK_AudioLowerVolume, Qt::Key_VolumeDown, - XF86XK_AudioMute, Qt::Key_VolumeMute, - XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp, - XF86XK_AudioPlay, Qt::Key_MediaPlay, - XF86XK_AudioStop, Qt::Key_MediaStop, - XF86XK_AudioPrev, Qt::Key_MediaPrevious, - XF86XK_AudioNext, Qt::Key_MediaNext, - XF86XK_AudioRecord, Qt::Key_MediaRecord, - - // launch keys - XF86XK_Mail, Qt::Key_LaunchMail, - XF86XK_MyComputer, Qt::Key_Launch0, - XF86XK_Calculator, Qt::Key_Launch1, - XF86XK_Standby, Qt::Key_Standby, - - XF86XK_Launch0, Qt::Key_Launch2, - XF86XK_Launch1, Qt::Key_Launch3, - XF86XK_Launch2, Qt::Key_Launch4, - XF86XK_Launch3, Qt::Key_Launch5, - XF86XK_Launch4, Qt::Key_Launch6, - XF86XK_Launch5, Qt::Key_Launch7, - XF86XK_Launch6, Qt::Key_Launch8, - XF86XK_Launch7, Qt::Key_Launch9, - XF86XK_Launch8, Qt::Key_LaunchA, - XF86XK_Launch9, Qt::Key_LaunchB, - XF86XK_LaunchA, Qt::Key_LaunchC, - XF86XK_LaunchB, Qt::Key_LaunchD, - XF86XK_LaunchC, Qt::Key_LaunchE, - XF86XK_LaunchD, Qt::Key_LaunchF, -#endif - -#if 0 - // Qtopia keys - QTOPIAXK_Select, Qt::Key_Select, - QTOPIAXK_Yes, Qt::Key_Yes, - QTOPIAXK_No, Qt::Key_No, - QTOPIAXK_Cancel, Qt::Key_Cancel, - QTOPIAXK_Printer, Qt::Key_Printer, - QTOPIAXK_Execute, Qt::Key_Execute, - QTOPIAXK_Sleep, Qt::Key_Sleep, - QTOPIAXK_Play, Qt::Key_Play, - QTOPIAXK_Zoom, Qt::Key_Zoom, - QTOPIAXK_Context1, Qt::Key_Context1, - QTOPIAXK_Context2, Qt::Key_Context2, - QTOPIAXK_Context3, Qt::Key_Context3, - QTOPIAXK_Context4, Qt::Key_Context4, - QTOPIAXK_Call, Qt::Key_Call, - QTOPIAXK_Hangup, Qt::Key_Hangup, - QTOPIAXK_Flip, Qt::Key_Flip, -#endif - 0, 0 -}; - - -static int lookupCode(unsigned int xkeycode) -{ - if (xkeycode >= XK_F1 && xkeycode <= XK_F35) - return Qt::Key_F1 + (int(xkeycode) - XK_F1); - - const unsigned int *p = keyTbl; - while (*p) { - if (*p == xkeycode) - return *++p; - p += 2; - } - - return 0; -} - - -static Qt::KeyboardModifiers modifierFromKeyCode(int qtcode) -{ - switch (qtcode) { - case Qt::Key_Control: - return Qt::ControlModifier; - case Qt::Key_Alt: - return Qt::AltModifier; - case Qt::Key_Shift: - return Qt::ShiftModifier; - case Qt::Key_Meta: - return Qt::MetaModifier; - default: - return Qt::NoModifier; - } -} - -void QTestLiteWindow::handleKeyEvent(QEvent::Type type, void *ev) -{ - XKeyEvent *e = static_cast(ev); - - KeySym keySym; - QByteArray chars; - chars.resize(513); - - int count = XLookupString(e, chars.data(), chars.size(), &keySym, 0); - -// qDebug() << "QTLWS::handleKeyEvent" << count << hex << "XKeysym:" << keySym; -// if (count) -// qDebug() << hex << int(chars[0]) << "String:" << chars; - - Qt::KeyboardModifiers modifiers = translateModifiers(e->state); - - int qtcode = lookupCode(keySym); -// qDebug() << "lookup: " << hex << keySym << qtcode << "mod" << modifiers; - - //X11 specifies state *before*, Qt expects state *after* the event - - modifiers ^= modifierFromKeyCode(qtcode); - - if (qtcode) { - QWindowSystemInterface::handleKeyEvent(widget(), e->time, type, qtcode, modifiers); - } else if (chars[0]) { - int qtcode = chars.toUpper()[0]; //Not exactly right... - if (modifiers & Qt::ControlModifier && qtcode < ' ') - qtcode = chars[0] + '@'; - QWindowSystemInterface::handleKeyEvent(widget(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars)); - } else { - qWarning() << "unknown X keycode" << hex << e->keycode << keySym; - } -} - - - -void QTestLiteWindow::setGeometry(const QRect &rect) -{ - QRect oldRect = geometry(); - if (rect == oldRect) - return; - - //if unchanged ### - xw->setGeometry(rect.x(), rect.y(), rect.width(), rect.height()); -} - - - -Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags) -{ - Q_ASSERT(flags & Qt::Window); - - window_flags = flags; - - xw->setWindowFlags(flags); - - return window_flags; - -} - -Qt::WindowFlags QTestLiteWindow::windowFlags() const -{ - return window_flags; -} - -void QTestLiteWindow::setVisible(bool visible) -{ - //qDebug() << "QTestLiteWindowSurface::setVisible" << visible << xw->window; - xw->setVisible(visible); -} - - -WId QTestLiteWindow::winId() const -{ - if (xw) - return (WId) xw->window; - else - return WId(0); -} - -void QTestLiteWindow::raise() -{ - WId window = winId(); - XRaiseWindow(mPlatformIntegration->xd->display, window); -} - -void QTestLiteWindow::lower() -{ - WId window = winId(); - XLowerWindow(mPlatformIntegration->xd->display, window); -} - -void QTestLiteWindow::setWindowTitle(const QString &title) -{ - xw->setWindowTitle(title); -} - -void QTestLiteWindow::setCursor(QCursor *cursor) -{ - xw->setCursor(cursor); + painted = true; //there is content in the buffer } QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qwindowsurface_testlite.h b/src/plugins/platforms/testlite/qwindowsurface_testlite.h index d713cc2..915e7fe 100644 --- a/src/plugins/platforms/testlite/qwindowsurface_testlite.h +++ b/src/plugins/platforms/testlite/qwindowsurface_testlite.h @@ -43,24 +43,23 @@ #define QWINDOWSURFACE_TESTLITE_H #include -#include -#include + QT_BEGIN_NAMESPACE -class MyWindow; +class QTestLiteWindow; class QTestLiteIntegration; class QTestLiteScreen; +class MyShmImageInfo; class QTestLiteWindowSurface : public QWindowSurface { public: - QTestLiteWindowSurface - (QTestLiteIntegration *platformIntegration, - QTestLiteScreen *screen, QWidget *window); + QTestLiteWindowSurface (QTestLiteScreen *screen, QWidget *window); ~QTestLiteWindowSurface(); QPaintDevice *paintDevice(); +// void flush(); void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); // void resize(const QSize &size); bool scroll(const QRegion &area, int dx, int dy); @@ -69,47 +68,18 @@ public: void endPaint(const QRegion ®ion); private: - QTestLiteIntegration *mPlatformIntegration; - QTestLiteScreen *mScreen; - Qt::WindowFlags window_flags; - MyWindow *xw; -}; - + bool painted; + void resizeBuffer(QSize); + QSize bufferSize() const; -class QTestLiteWindow : public QPlatformWindow -{ -public: - QTestLiteWindow(QTestLiteIntegration *platformIntegration, - QTestLiteScreen *screen, QWidget *window); - ~QTestLiteWindow(); + void resizeShmImage(int width, int height); - void handleMouseEvent(QEvent::Type, void *); //forwarding X types is apparently impossible :( - void handleKeyEvent(QEvent::Type, void *); - void handleGeometryChange(int x, int y, int w, int h); - void handleCloseEvent(); - void handleEnterEvent(); - void handleLeaveEvent(); + QImage shm_img; + MyShmImageInfo *image_info; - void setGeometry(const QRect &rect); - - Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); - Qt::WindowFlags windowFlags() const; - void setVisible(bool visible); - WId winId() const; - void raise(); - void lower(); - void setWindowTitle(const QString &title); - - void setCursor(QCursor * cursor); - -private: - QTestLiteIntegration *mPlatformIntegration; - QTestLiteScreen *mScreen; - Qt::WindowFlags window_flags; - MyWindow *xw; + QTestLiteWindow *xw; - friend class QTestLiteWindowSurface; //### needs refactoring }; diff --git a/src/plugins/platforms/testlite/testlite.pro b/src/plugins/platforms/testlite/testlite.pro index 442dd68..02122f1 100644 --- a/src/plugins/platforms/testlite/testlite.pro +++ b/src/plugins/platforms/testlite/testlite.pro @@ -3,12 +3,8 @@ include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms -SOURCES = main.cpp qplatformintegration_testlite.cpp qwindowsurface_testlite.cpp -HEADERS = qplatformintegration_testlite.h qwindowsurface_testlite.h - - -HEADERS += x11util.h -SOURCES += x11util.cpp +SOURCES = main.cpp qplatformintegration_testlite.cpp qwindowsurface_testlite.cpp qtestlitewindow.cpp +HEADERS = qplatformintegration_testlite.h qwindowsurface_testlite.h qtestlitewindow.h LIBS += -lX11 -lXext diff --git a/src/plugins/platforms/testlite/x11util.cpp b/src/plugins/platforms/testlite/x11util.cpp deleted file mode 100644 index a869347..0000000 --- a/src/plugins/platforms/testlite/x11util.cpp +++ /dev/null @@ -1,1215 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include -#include -#include - -#include "x11util.h" -#include "qwindowsurface_testlite.h" - -#include -#include - - -#include - -#include - -# include -# include -# include - - -#include -#include -#include -#include - -//### remove stuff we don't want from qt_x11_p.h -#undef ATOM -#undef X11 - -//#define MYX11_DEBUG - -//#define DONT_USE_MIT_SHM - -static int (*original_x_errhandler)(Display *dpy, XErrorEvent *); -static bool seen_badwindow; - - -static Atom wmProtocolsAtom; -static Atom wmDeleteWindowAtom; - -//### copied from qapplication_x11.cpp - -static int qt_x_errhandler(Display *dpy, XErrorEvent *err) -{ - -qDebug() << "qt_x_errhandler" << err->error_code; - - switch (err->error_code) { - case BadAtom: -#if 0 - if (err->request_code == 20 /* X_GetProperty */ - && (err->resourceid == XA_RESOURCE_MANAGER - || err->resourceid == XA_RGB_DEFAULT_MAP - || err->resourceid == ATOM(_NET_SUPPORTED) - || err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK) - || err->resourceid == ATOM(KDE_FULL_SESSION) - || err->resourceid == ATOM(KWIN_RUNNING) - || err->resourceid == ATOM(XdndProxy) - || err->resourceid == ATOM(XdndAware)) - - - ) { - // Perhaps we're running under SECURITY reduction? :/ - return 0; - } -#endif - qDebug() << "BadAtom"; - break; - - case BadWindow: - if (err->request_code == 2 /* X_ChangeWindowAttributes */ - || err->request_code == 38 /* X_QueryPointer */) { - for (int i = 0; i < ScreenCount(dpy); ++i) { - if (err->resourceid == RootWindow(dpy, i)) { - // Perhaps we're running under SECURITY reduction? :/ - return 0; - } - } - } - seen_badwindow = true; - if (err->request_code == 25 /* X_SendEvent */) { - for (int i = 0; i < ScreenCount(dpy); ++i) { - if (err->resourceid == RootWindow(dpy, i)) { - // Perhaps we're running under SECURITY reduction? :/ - return 0; - } - } -#if 0 - if (X11->xdndHandleBadwindow()) { - qDebug("xdndHandleBadwindow returned true"); - return 0; - } -#endif - } -#if 0 - if (X11->ignore_badwindow) - return 0; -#endif - break; - - case BadMatch: - if (err->request_code == 42 /* X_SetInputFocus */) - return 0; - break; - - default: -#if 0 //!defined(QT_NO_XINPUT) - if (err->request_code == X11->xinput_major - && err->error_code == (X11->xinput_errorbase + XI_BadDevice) - && err->minor_code == 3 /* X_OpenDevice */) { - return 0; - } -#endif - break; - } - - char errstr[256]; - XGetErrorText( dpy, err->error_code, errstr, 256 ); - char buffer[256]; - char request_str[256]; - qsnprintf(buffer, 256, "%d", err->request_code); - XGetErrorDatabaseText(dpy, "XRequest", buffer, "", request_str, 256); - if (err->request_code < 128) { - // X error for a normal protocol request - qWarning( "X Error: %s %d\n" - " Major opcode: %d (%s)\n" - " Resource id: 0x%lx", - errstr, err->error_code, - err->request_code, - request_str, - err->resourceid ); - } else { - // X error for an extension request - const char *extensionName = 0; -#if 0 - if (err->request_code == X11->xrender_major) - extensionName = "RENDER"; - else if (err->request_code == X11->xrandr_major) - extensionName = "RANDR"; - else if (err->request_code == X11->xinput_major) - extensionName = "XInputExtension"; - else if (err->request_code == X11->mitshm_major) - extensionName = "MIT-SHM"; -#endif - char minor_str[256]; - if (extensionName) { - qsnprintf(buffer, 256, "%s.%d", extensionName, err->minor_code); - XGetErrorDatabaseText(dpy, "XRequest", buffer, "", minor_str, 256); - } else { - extensionName = "Uknown extension"; - qsnprintf(minor_str, 256, "Unknown request"); - } - qWarning( "X Error: %s %d\n" - " Extension: %d (%s)\n" - " Minor opcode: %d (%s)\n" - " Resource id: 0x%lx", - errstr, err->error_code, - err->request_code, - extensionName, - err->minor_code, - minor_str, - err->resourceid ); - } - - // ### we really should distinguish between severe, non-severe and - // ### application specific errors - - return 0; -} - - - - - - - - - -bool MyDisplay::handleEvent(XEvent *xe) -{ - //qDebug() << "handleEvent" << xe->xany.type << xe->xany.window; - int quit = false; - MyWindow *xw = 0; - foreach (MyWindow *w, windowList) { - if (w->window == xe->xany.window) { - xw = w; - break; - } - } - if (!xw) { -#ifdef MYX11_DEBUG - qWarning() << "Unknown window" << hex << xe->xany.window << "received event" << xe->type; -#endif - return quit; - } - - switch (xe->type) { - - case ClientMessage: - if (xe->xclient.format == 32 && xe->xclient.message_type == wmProtocolsAtom) { - Atom a = xe->xclient.data.l[0]; - if (a == wmDeleteWindowAtom) - xw->closeEvent(); -#ifdef MYX11_DEBUG - qDebug() << "ClientMessage WM_PROTOCOLS" << a; -#endif - } -#ifdef MYX11_DEBUG - else - qDebug() << "ClientMessage" << xe->xclient.format << xe->xclient.message_type; -#endif - break; - - case Expose: - if (xw) - if (xe->xexpose.count == 0) - xw->paintEvent(); - break; - case ConfigureNotify: - if (xw) - xw->resizeEvent(&xe->xconfigure); - break; - - case ButtonPress: - xw->mousePressEvent(&xe->xbutton); - break; - - case ButtonRelease: - xw->mouseReleaseEvent(&xe->xbutton); - break; - - case MotionNotify: - xw->mouseMoveEvent(&xe->xbutton); - break; - - case XKeyPress: - xw->keyPressEvent(&xe->xkey); - break; - - case XKeyRelease: - xw->keyReleaseEvent(&xe->xkey); - break; - - case EnterNotify: - xw->enterEvent(&xe->xcrossing); - break; - - case LeaveNotify: - xw->leaveEvent(&xe->xcrossing); - break; - - default: -#ifdef MYX11_DEBUG - qDebug() << hex << xe->xany.window << "Other X event" << xe->type; -#endif - break; - } - return quit; -}; - - - -MyDisplay::MyDisplay() -{ - char *display_name = getenv("DISPLAY"); - display = XOpenDisplay(display_name); - if (!display) { - fprintf(stderr, "Cannot connect to X server: %s\n", - display_name); - exit(1); - } - -#ifndef DONT_USE_MIT_SHM - Status MIT_SHM_extension_supported = XShmQueryExtension (display); - Q_ASSERT(MIT_SHM_extension_supported == True); -#endif - original_x_errhandler = XSetErrorHandler(qt_x_errhandler); - - if (qgetenv("DO_X_SYNCHRONIZE").toInt()) - XSynchronize(display, true); - - screen = DefaultScreen(display); - width = DisplayWidth(display, screen); - height = DisplayHeight(display, screen); - physicalWidth = DisplayWidthMM(display, screen); - physicalHeight = DisplayHeightMM(display, screen); - - int xSocketNumber = XConnectionNumber(display); -#ifdef MYX11_DEBUG - qDebug() << "X socket:"<< xSocketNumber; -#endif - QSocketNotifier *sock = new QSocketNotifier(xSocketNumber, QSocketNotifier::Read, this); - connect(sock, SIGNAL(activated(int)), this, SLOT(eventDispatcher())); - - wmProtocolsAtom = XInternAtom (display, "WM_PROTOCOLS", False); - wmDeleteWindowAtom = XInternAtom (display, "WM_DELETE_WINDOW", False); - - cursors = new MyX11Cursors(display); -} - - -MyDisplay::~MyDisplay() -{ - XCloseDisplay(display); -} - - -void MyDisplay::eventDispatcher() -{ -// qDebug() << "eventDispatcher"; - - - ulong marker = XNextRequest(display); -// int i = 0; - while (XPending(display)) { - XEvent event; - XNextEvent(display, &event); - /* done = */ - handleEvent(&event); - - if (event.xany.serial >= marker) { -#ifdef MYX11_DEBUG - qDebug() << "potential livelock averted"; -#endif -#if 0 - if (XEventsQueued(display, QueuedAfterFlush)) { - qDebug() << " with events queued"; - QTimer::singleShot(0, this, SLOT(eventDispatcher())); - } -#endif - break; - } - } -} - - -QImage MyDisplay::grabWindow(Window window, int x, int y, int w, int h) -{ - if (w == 0 || h ==0) - return QImage(); - - //WinId 0 means the desktop widget - if (!window) - window = rootWindow(); - - XWindowAttributes window_attr; - if (!XGetWindowAttributes(display, window, &window_attr)) - return QImage(); - - if (w < 0) - w = window_attr.width - x; - if (h < 0) - h = window_attr.height - y; - - // Ideally, we should also limit ourselves to the screen area, but the Qt docs say - // that it's "unsafe" to go outside the screen, so we can ignore that problem. - - //We're definitely not optimizing for speed... - XImage *xi = XGetImage(display, window, x, y, w, h, AllPlanes, ZPixmap); - - if (!xi) - return QImage(); - - //taking a copy to make sure we have ownership -- not fast - QImage result = QImage( (uchar*) xi->data, xi->width, xi->height, xi->bytes_per_line, QImage::Format_RGB32 ).copy(); - - XDestroyImage(xi); - - return result; -} - - - - -struct MyShmImageInfo { - MyShmImageInfo(Display *xdisplay) : image(0), display(xdisplay) {} - ~MyShmImageInfo() { destroy(); } - - void destroy(); - - XShmSegmentInfo shminfo; - XImage *image; - Display *display; -}; - -MyWindow::MyWindow(MyDisplay *display, int x, int y, int w, int h) -{ - xd = display; - - xd->windowList.append(this); - - window = XCreateSimpleWindow(xd->display, xd->rootWindow(), - x, y, w, h, 0 /*border_width*/, - xd->blackPixel(), xd->whitePixel()); - - -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::MyWindow" << hex << window; -#endif - - - width = -1; - height = -1; - xpos = -1; - ypos = -1; - - XSetWindowBackgroundPixmap(xd->display, window, XNone); - - XSelectInput(xd->display, window, ExposureMask | KeyPressMask | KeyReleaseMask | - EnterWindowMask | LeaveWindowMask | FocusChangeMask | - PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | - StructureNotifyMask); - - gc = createGC(); - - XChangeProperty (xd->display, window, - wmProtocolsAtom, - XA_ATOM, 32, PropModeAppend, - (unsigned char *) &wmDeleteWindowAtom, 1); - - - setWindowTitle(QLatin1String("Qt Lighthouse")); - - currentCursor = -1; - - image_info = 0; - painted = false; -} - - -void MyWindow::setWindowTitle(const QString &title) - -{ - QByteArray ba = title.toLatin1(); //We're not making a general solution here... - XTextProperty windowName; - windowName.value = (unsigned char *)ba.constData(); - windowName.encoding = XA_STRING; - windowName.format = 8; - windowName.nitems = ba.length(); - - XSetWMName(xd->display, window, &windowName); -} - -MyWindow::~MyWindow() -{ -#ifdef MYX11_DEBUG - qDebug() << "~MyWindow" << hex << window; -#endif - XFreeGC(xd->display, gc); - XDestroyWindow(xd->display, window); - - xd->windowList.removeAll(this); - - delete image_info; -} - -GC MyWindow::createGC() -{ - GC gc; - - gc = XCreateGC(xd->display, window, 0, 0); - if (gc < 0) { - qWarning("MyWindow::createGC() could not create GC"); - } - return gc; -} - -void MyWindow::closeEvent() -{ - windowTL->handleCloseEvent(); -} - -void MyWindow::paintEvent() -{ -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::paintEvent" << shm_img.size() << painted; -#endif - if (!painted) - return; - -#ifdef DONT_USE_MIT_SHM - // just convert the image every time... - if (!shm_img.isNull()) { - Visual *visual = DefaultVisual(xd->display, xd->screen); - - QImage image = shm_img; - //img.convertToFormat( - XImage *xi = XCreateImage(xd->display, visual, 24, ZPixmap, - 0, (char *) image.scanLine(0), image.width(), image.height(), - 32, image.bytesPerLine()); - - int x = 0; - int y = 0; - - /*int r =*/ XPutImage(xd->display, window, gc, xi, 0, 0, x, y, image.width(), image.height()); - - xi->data = 0; // QImage owns these bits - XDestroyImage(xi); - } -#else - // Use MIT_SHM - if (image_info->image) { - //qDebug() << "Here we go" << image_info->image->width << image_info->image->height; - int x = 0; - int y = 0; - - // We could set send_event to true, and then use the ShmCompletion to synchronize, - // but let's do like Qt/11 and just use XSync - XShmPutImage (xd->display, window, gc, image_info->image, 0, 0, - x, y, image_info->image->width, image_info->image->height, - /*send_event*/ False); - - XSync(xd->display, False); - } -#endif -} - -#ifndef DONT_USE_MIT_SHM -void MyShmImageInfo::destroy() -{ - XShmDetach (display, &shminfo); - XDestroyImage (image); - shmdt (shminfo.shmaddr); - shmctl (shminfo.shmid, IPC_RMID, 0); -} -#endif - -void MyWindow::resizeShmImage(int width, int height) -{ -#ifdef DONT_USE_MIT_SHM - shm_img = QImage(width, height, QImage::Format_RGB32); -#else - if (image_info) - image_info->destroy(); - else - image_info = new MyShmImageInfo(xd->display); - - Visual *visual = DefaultVisual(xd->display, xd->screen); - - - XImage *image = XShmCreateImage (xd->display, visual, 24, ZPixmap, 0, - &image_info->shminfo, width, height); - - - image_info->shminfo.shmid = shmget (IPC_PRIVATE, - image->bytes_per_line * image->height, IPC_CREAT|0777); - - image_info->shminfo.shmaddr = image->data = (char*)shmat (image_info->shminfo.shmid, 0, 0); - image_info->shminfo.readOnly = False; - - image_info->image = image; - - Status shm_attach_status = XShmAttach(xd->display, &image_info->shminfo); - - Q_ASSERT(shm_attach_status == True); - - shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, QImage::Format_RGB32 ); -#endif - painted = false; -} - - -void MyWindow::resizeBuffer(QSize s) -{ - if (shm_img.size() != s) - resizeShmImage(s.width(), s.height()); -} - -QSize MyWindow::bufferSize() const -{ - return shm_img.size(); -} - - -void MyWindow::resizeEvent(XConfigureEvent *e) -{ - - if ((e->width != width || e->height != height) && e->x == 0 && e->y == 0) { - //qDebug() << "resize with bogus pos" << e->x << e->y << e->width << e->height << "window"<< hex << window; - } else { - //qDebug() << "geometry change" << e->x << e->y << e->width << e->height << "window"<< hex << window; - xpos = e->x; - ypos = e->y; - } - width = e->width; - height = e->height; - -#ifdef MYX11_DEBUG - qDebug() << hex << window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height << "img:" << shm_img.size(); -#endif - - windowTL->handleGeometryChange(xpos, ypos, width, height); -} - -#if 0 -void MyWindow::setSize(int w, int h) -{ - XResizeWindow(xd->display, window, w, h); -} -#endif - -void MyWindow::setGeometry(int x, int y, int w, int h) -{ -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::setGeometry" << hex << window << dec << x << y << w << h << "img:" << shm_img.size(); -#endif - XMoveResizeWindow(xd->display, window, x, y, w, h); -} - - -void MyWindow::enterEvent(XCrossingEvent *) -{ -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::enterEvent" << hex << window; -#endif - windowTL->handleEnterEvent(); -} - -void MyWindow::leaveEvent(XCrossingEvent *) -{ -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::enterEvent" << hex << window; -#endif - windowTL->handleLeaveEvent(); -} - -void MyWindow::mousePressEvent(XButtonEvent *e) -{ - static long prevTime = 0; - static Window prevWindow; - static int prevX = -999; - static int prevY = -999; - - QEvent::Type type = QEvent::MouseButtonPress; - - if (e->window == prevWindow && long(e->time) - prevTime < QApplication::doubleClickInterval() - && qAbs(e->x - prevX) < 5 && qAbs(e->y - prevY) < 5) { - type = QEvent::MouseButtonDblClick; - prevTime = e->time - QApplication::doubleClickInterval(); //no double click next time - } else { - prevTime = e->time; - } - prevWindow = e->window; - prevX = e->x; - prevY = e->y; - - windowTL->handleMouseEvent(type, e); -} - -void MyWindow::mouseReleaseEvent(XButtonEvent *e) -{ - windowTL->handleMouseEvent(QEvent::MouseButtonRelease, e); -} - -void MyWindow::mouseMoveEvent(XButtonEvent *e) -{ - windowTL->handleMouseEvent(QEvent::MouseMove, e); -} - -#ifdef KeyPress -#undef KeyPress -#endif - -void MyWindow::keyPressEvent(XKeyEvent *e) -{ - windowTL->handleKeyEvent(QEvent::KeyPress, e); -} - -#ifdef KeyRelease -#undef KeyRelease -#endif - -void MyWindow::keyReleaseEvent(XKeyEvent *e) -{ - windowTL->handleKeyEvent(QEvent::KeyRelease, e); -} - - -// WindowFlag stuff, lots of copied code from qwidget_x11.cpp... - -//We're hacking here... - - -// MWM support -struct QtMWMHints { - ulong flags, functions, decorations; - long input_mode; - ulong status; -}; - -enum { - MWM_HINTS_FUNCTIONS = (1L << 0), - - MWM_FUNC_ALL = (1L << 0), - MWM_FUNC_RESIZE = (1L << 1), - MWM_FUNC_MOVE = (1L << 2), - MWM_FUNC_MINIMIZE = (1L << 3), - MWM_FUNC_MAXIMIZE = (1L << 4), - MWM_FUNC_CLOSE = (1L << 5), - - MWM_HINTS_DECORATIONS = (1L << 1), - - MWM_DECOR_ALL = (1L << 0), - MWM_DECOR_BORDER = (1L << 1), - MWM_DECOR_RESIZEH = (1L << 2), - MWM_DECOR_TITLE = (1L << 3), - MWM_DECOR_MENU = (1L << 4), - MWM_DECOR_MINIMIZE = (1L << 5), - MWM_DECOR_MAXIMIZE = (1L << 6), - - MWM_HINTS_INPUT_MODE = (1L << 2), - - MWM_INPUT_MODELESS = 0L, - MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L, - MWM_INPUT_FULL_APPLICATION_MODAL = 3L -}; - -static Atom mwm_hint_atom = XNone; - -static QtMWMHints GetMWMHints(Display *display, Window window) -{ - QtMWMHints mwmhints; - - Atom type; - int format; - ulong nitems, bytesLeft; - uchar *data = 0; - if ((XGetWindowProperty(display, window, mwm_hint_atom, 0, 5, false, - mwm_hint_atom, &type, &format, &nitems, &bytesLeft, - &data) == Success) - && (type == mwm_hint_atom - && format == 32 - && nitems >= 5)) { - mwmhints = *(reinterpret_cast(data)); - } else { - mwmhints.flags = 0L; - mwmhints.functions = MWM_FUNC_ALL; - mwmhints.decorations = MWM_DECOR_ALL; - mwmhints.input_mode = 0L; - mwmhints.status = 0L; - } - - if (data) - XFree(data); - - return mwmhints; -} - -static void SetMWMHints(Display *display, Window window, const QtMWMHints &mwmhints) -{ - if (mwmhints.flags != 0l) { - XChangeProperty(display, window, mwm_hint_atom, mwm_hint_atom, 32, - PropModeReplace, (unsigned char *) &mwmhints, 5); - } else { - XDeleteProperty(display, window, mwm_hint_atom); - } -} - -// 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)); -} - - - -Qt::WindowFlags MyWindow::setWindowFlags(Qt::WindowFlags flags) -{ - - if (mwm_hint_atom == XNone) { - mwm_hint_atom = XInternAtom(xd->display, "_MOTIF_WM_HINTS\0", False); - } - -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::setWindowFlags" << hex << window << "flags" << flags; -#endif - Qt::WindowType type = static_cast(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); - - bool tooltip = (type == Qt::ToolTip); - - XSetWindowAttributes wsa; - - QtMWMHints mwmhints; - mwmhints.flags = 0L; - mwmhints.functions = 0L; - mwmhints.decorations = 0; - mwmhints.input_mode = 0L; - mwmhints.status = 0L; - - - ulong wsa_mask = 0; - if (type != Qt::SplashScreen) { // && customize) { - 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 (tool) { - wsa.save_under = True; - wsa_mask |= CWSaveUnder; - } - - if (flags & Qt::X11BypassWindowManagerHint) { - wsa.override_redirect = True; - wsa_mask |= CWOverrideRedirect; - } -#if 0 - if (wsa_mask && initializeWindow) { - Q_ASSERT(id); - XChangeWindowAttributes(dpy, id, wsa_mask, &wsa); - } -#endif - 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; - } - - SetMWMHints(xd->display, window, mwmhints); - -//##### only if initializeWindow??? - - if (popup || tooltip) { // popup widget -#ifdef MYX11_DEBUG - qDebug() << "Doing XChangeWindowAttributes for popup" << wsa.override_redirect; -#endif - // set EWMH window types - // setNetWmWindowTypes(); - - wsa.override_redirect = True; - wsa.save_under = True; - XChangeWindowAttributes(xd->display, window, CWOverrideRedirect | CWSaveUnder, - &wsa); - } else { -#ifdef MYX11_DEBUG - qDebug() << "Doing XChangeWindowAttributes for non-popup"; -#endif - } - - return flags; -} - -void MyWindow::setVisible(bool visible) -{ -#ifdef MYX11_DEBUG - qDebug() << "MyWindow::setVisible" << visible << hex << window; -#endif - if (visible) - XMapWindow(xd->display, window); - else - XUnmapWindow(xd->display, window); -} - -MyX11Cursors::MyX11Cursors(Display * d) : firstExpired(0), lastExpired(0), display(d), removalDelay(3) -{ - connect(&timer, SIGNAL(timeout()), this, SLOT(timeout())); -} - -void MyX11Cursors::insertNode(MyX11CursorNode * node) -{ - QDateTime now = QDateTime::currentDateTime(); - QDateTime timeout = now.addSecs(removalDelay); - node->setExpiration(timeout); - node->setPost(0); - if (lastExpired) { - lastExpired->setPost(node); - node->setAnte(lastExpired); - } - lastExpired = node; - if (!firstExpired) { - firstExpired = node; - node->setAnte(0); - int interval = removalDelay * 1000; - timer.setInterval(interval); - timer.start(); - } -} - -void MyX11Cursors::removeNode(MyX11CursorNode * node) -{ - MyX11CursorNode *pre = node->ante(); - MyX11CursorNode *post = node->post(); - if (pre) - pre->setPost(post); - if (post) - post->setAnte(pre); - if (node == lastExpired) - lastExpired = pre; - if (node == firstExpired) { - firstExpired = post; - if (!firstExpired) { - timer.stop(); - return; - } - int interval = QDateTime::currentDateTime().secsTo(firstExpired->expiration()) * 1000; - timer.stop(); - timer.setInterval(interval); - timer.start(); - } -} - -void MyX11Cursors::incrementUseCount(int id) -{ - MyX11CursorNode * node = lookupMap.value(id); - Q_ASSERT(node); - if (!node->refCount) - removeNode(node); - node->refCount++; -} - -void MyX11Cursors::decrementUseCount(int id) -{ - MyX11CursorNode * node = lookupMap.value(id); - Q_ASSERT(node); - node->refCount--; - if (!node->refCount) - insertNode(node); -} - -void MyX11Cursors::createNode(int id, Cursor c) -{ - MyX11CursorNode * node = new MyX11CursorNode(id, c); - lookupMap.insert(id, node); -} - -void MyX11Cursors::timeout() -{ - MyX11CursorNode * node; - node = firstExpired; - QDateTime now = QDateTime::currentDateTime(); - while (node && now.secsTo(node->expiration()) < 1) { - Cursor c = node->cursor(); - int id = node->id(); - lookupMap.take(id); - MyX11CursorNode * tmp = node; - node = node->post(); - delete tmp; - XFreeCursor(display, c); - } - firstExpired = node; - if (node == 0) { - timer.stop(); - lastExpired = 0; - } - else { - int interval = QDateTime::currentDateTime().secsTo(firstExpired->expiration()) * 1000; - timer.setInterval(interval); - timer.start(); - } -} - -Cursor MyX11Cursors::cursor(int id) -{ - MyX11CursorNode * node = lookupMap.value(id); - Q_ASSERT(node); - return node->cursor(); -} - -void MyWindow::setCursor(QCursor * cursor) -{ - int id = cursor->handle(); - if (id == currentCursor) - return; - Cursor c; - if (!xd->cursors->exists(id)) { - if (cursor->shape() == Qt::BitmapCursor) - c = createCursorBitmap(cursor); - else - c = createCursorShape(cursor->shape()); - if (!c) { - return; - } - xd->cursors->createNode(id, c); - } else { - xd->cursors->incrementUseCount(id); - c = xd->cursors->cursor(id); - } - - if (currentCursor != -1) - xd->cursors->decrementUseCount(currentCursor); - currentCursor = id; - - XDefineCursor(xd->display, window, c); - XFlush(xd->display); -} - -Cursor MyWindow::createCursorBitmap(QCursor * cursor) -{ - XColor bg, fg; - bg.red = 255 << 8; - bg.green = 255 << 8; - bg.blue = 255 << 8; - fg.red = 0; - fg.green = 0; - fg.blue = 0; - QPoint spot = cursor->hotSpot(); - Window rootwin = window; - - QImage mapImage = cursor->bitmap()->toImage().convertToFormat(QImage::Format_MonoLSB); - QImage maskImage = cursor->mask()->toImage().convertToFormat(QImage::Format_MonoLSB); - - int width = cursor->bitmap()->width(); - int height = cursor->bitmap()->height(); - int bytesPerLine = mapImage.bytesPerLine(); - int destLineSize = width / 8; - if (width % 8) - destLineSize++; - - const uchar * map = mapImage.bits(); - const uchar * mask = maskImage.bits(); - - char * mapBits = new char[height * destLineSize]; - char * maskBits = new char[height * destLineSize]; - for (int i = 0; i < height; i++) { - memcpy(mapBits + (destLineSize * i),map + (bytesPerLine * i), destLineSize); - memcpy(maskBits + (destLineSize * i),mask + (bytesPerLine * i), destLineSize); - } - - Pixmap cp = XCreateBitmapFromData(xd->display, rootwin, mapBits, width, height); - Pixmap mp = XCreateBitmapFromData(xd->display, rootwin, maskBits, width, height); - Cursor c = XCreatePixmapCursor(xd->display, cp, mp, &fg, &bg, spot.x(), spot.y()); - XFreePixmap(xd->display, cp); - XFreePixmap(xd->display, mp); - delete[] mapBits; - delete[] maskBits; - - return c; -} - -Cursor MyWindow::createCursorShape(int cshape) -{ - Cursor cursor = 0; - - if (cshape < 0 || cshape > Qt::LastCursor) - return 0; - - switch (cshape) { - case Qt::ArrowCursor: - cursor = XCreateFontCursor(xd->display, XC_left_ptr); - break; - case Qt::UpArrowCursor: - cursor = XCreateFontCursor(xd->display, XC_center_ptr); - break; - case Qt::CrossCursor: - cursor = XCreateFontCursor(xd->display, XC_crosshair); - break; - case Qt::WaitCursor: - cursor = XCreateFontCursor(xd->display, XC_watch); - break; - case Qt::IBeamCursor: - cursor = XCreateFontCursor(xd->display, XC_xterm); - break; - case Qt::SizeAllCursor: - cursor = XCreateFontCursor(xd->display, XC_fleur); - break; - case Qt::PointingHandCursor: - cursor = XCreateFontCursor(xd->display, XC_hand2); - break; - case Qt::SizeBDiagCursor: - cursor = XCreateFontCursor(xd->display, XC_top_right_corner); - break; - case Qt::SizeFDiagCursor: - cursor = XCreateFontCursor(xd->display, XC_bottom_right_corner); - break; - case Qt::SizeVerCursor: - case Qt::SplitVCursor: - cursor = XCreateFontCursor(xd->display, XC_sb_v_double_arrow); - break; - case Qt::SizeHorCursor: - case Qt::SplitHCursor: - cursor = XCreateFontCursor(xd->display, XC_sb_h_double_arrow); - break; - case Qt::WhatsThisCursor: - cursor = XCreateFontCursor(xd->display, XC_question_arrow); - break; - case Qt::ForbiddenCursor: - cursor = XCreateFontCursor(xd->display, XC_circle); - break; - case Qt::BusyCursor: - cursor = XCreateFontCursor(xd->display, XC_watch); - break; - - default: //default cursor for all the rest - break; - } - return cursor; -} - - -#if 0 - - - switch (cshape) { // map Q cursor to X cursor - case Qt::BlankCursor: - XColor bg, fg; - bg.red = 255 << 8; - bg.green = 255 << 8; - bg.blue = 255 << 8; - fg.red = 0; - fg.green = 0; - fg.blue = 0; - pm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16); - pmm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16); - hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8); - return; - break; - default: - qWarning("QCursor::update: Invalid cursor shape %d", cshape); - return; - } -#endif diff --git a/src/plugins/platforms/testlite/x11util.h b/src/plugins/platforms/testlite/x11util.h deleted file mode 100644 index b28d1e8..0000000 --- a/src/plugins/platforms/testlite/x11util.h +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MYX11UTIL_H -#define MYX11UTIL_H - -#include -#include -#include -#include - -#include - -#include -#include - - -class MyWindow; -class MyX11Cursors; - -class MyDisplay : public QObject -{ - Q_OBJECT; -public: - MyDisplay(); - ~MyDisplay(); - - Window rootWindow() { return RootWindow(display, screen); } - unsigned long blackPixel() { return BlackPixel(display, screen); } - unsigned long whitePixel() { return WhitePixel(display, screen); } - - bool handleEvent(XEvent *xe); - QImage grabWindow(Window window, int x, int y, int w, int h); - -public slots: - void eventDispatcher(); - -public: //### - Display * display; - int screen; - int width, height; - int physicalWidth; - int physicalHeight; - - QList windowList; - - MyX11Cursors * cursors; -}; - -class QTestLiteWindow; //### abstract callback interface, anyone? - -struct MyShmImageInfo; - -class MyWindow : public QObject -{ - Q_OBJECT; -public: - MyWindow(MyDisplay *xd, int x, int y, int w, int h); - ~MyWindow(); - - - void mousePressEvent(XButtonEvent*); - void mouseReleaseEvent(XButtonEvent*); - void mouseMoveEvent(XButtonEvent*); - - void keyPressEvent(XKeyEvent*); - void keyReleaseEvent(XKeyEvent*); - - void enterEvent(XCrossingEvent*); - void leaveEvent(XCrossingEvent*); - - void closeEvent(); - void paintEvent(); - void resizeEvent(XConfigureEvent *configure_event); -// void setSize(int w, int h); - void setGeometry(int x, int y, int w, int h); - - GC createGC(); - - Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); - void setVisible(bool visible); - void setCursor(QCursor * cursor); - Cursor createCursorShape(int cshape); - Cursor createCursorBitmap(QCursor * cursor); - - void setWindowTitle(const QString &title); - - QImage *image() { return &shm_img; } - -public: //### - - int xpos, ypos; - int width, height; - Window window; - MyDisplay *xd; - GC gc; - - QTestLiteWindow *windowTL; - - int currentCursor; - bool painted; - void resizeBuffer(QSize); - QSize bufferSize() const; - -private: - void resizeShmImage(int width, int height); - - QImage shm_img; - MyShmImageInfo *image_info; -}; - -class MyX11CursorNode -{ -public: - MyX11CursorNode(int id, Cursor c) { idValue = id; cursorValue = c; refCount = 1; } - QDateTime expiration() { return t; } - void setExpiration(QDateTime val) { t = val; } - MyX11CursorNode * ante() { return before; } - void setAnte(MyX11CursorNode *node) { before = node; } - MyX11CursorNode * post() { return after; } - void setPost(MyX11CursorNode *node) { after = node; } - Cursor cursor() { return cursorValue; } - int id() { return idValue; } - unsigned int refCount; - -private: - MyX11CursorNode *before; - MyX11CursorNode *after; - QDateTime t; - Cursor cursorValue; - int idValue; - - Display * display; -}; - -class MyX11Cursors : public QObject -{ - Q_OBJECT -public: - MyX11Cursors(Display * d); - ~MyX11Cursors() { timer.stop(); } - void incrementUseCount(int id); - void decrementUseCount(int id); - void createNode(int id, Cursor c); - bool exists(int id) { return lookupMap.contains(id); } - Cursor cursor(int id); -public slots: - void timeout(); - -private: - void removeNode(MyX11CursorNode *node); - void insertNode(MyX11CursorNode *node); - - // linked list of cursors currently not assigned to any window - MyX11CursorNode *firstExpired; - MyX11CursorNode *lastExpired; - - QHash lookupMap; - QTimer timer; - - Display *display; - - int removalDelay; -}; - -#endif // MYX11UTIL_H -- cgit v0.12 From b260d7b806c239505324d6a4762d3755e74a1b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 12 Apr 2010 12:33:25 +0200 Subject: Fix forward declaration in qplatformwindow_lite.h --- src/gui/kernel/qplatformwindow_lite.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qplatformwindow_lite.h b/src/gui/kernel/qplatformwindow_lite.h index 8771cfe..583ac28 100644 --- a/src/gui/kernel/qplatformwindow_lite.h +++ b/src/gui/kernel/qplatformwindow_lite.h @@ -47,13 +47,13 @@ #include #include -class QPlatformWindowPrivate; -class QWidget; QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +class QPlatformWindowPrivate; +class QWidget; class Q_GUI_EXPORT QPlatformWindow { Q_DECLARE_PRIVATE(QPlatformWindow); -- cgit v0.12 From 0851bd20f126a7dafec776771795e08de5ac9fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 12 Apr 2010 12:46:34 +0200 Subject: Cleaned up Blitter Paint engine and fixed a couple of bugs --- src/gui/painting/qpaintengine_blitter.cpp | 111 ++++++++++----------- src/gui/painting/qpaintengine_blitter_p.h | 1 - .../platforms/directfb/qblitter_directfb.cpp | 5 +- 3 files changed, 56 insertions(+), 61 deletions(-) diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 0b74a4d..54a146f 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -30,14 +30,20 @@ static inline void updateStateBits(uint *state, uint mask, bool on) *state = on ? (*state | mask) : (*state & ~mask); } +static inline bool checkStateAgainstMask(uint state, uint mask) +{ + return !state || (state & mask && !(state & ~mask)); +} + class CapabilitiesToStateMask { public: CapabilitiesToStateMask(QBlittable::Capabilities capabilities) : m_capabilities(capabilities), - fillRectMask(0), fillRectState(0), - drawRectMask(0), drawRectState(0), - drawPixmapMask(0), drawPixmapState(0) + fillRectMask(0), + drawRectMask(0), + drawPixmapMask(0), + capabillitiesState(0) { if (capabilities & QBlittable::SolidRectCapability) { setFillRectMask(); @@ -48,23 +54,26 @@ public: if (capabilities & QBlittable::SourceOverPixmapCapability) { setSourceOverPixmapMask(); } + if (capabilities & QBlittable::SourceOverScaledPixmapCapability) { + setSourceOverScaledPixmapMask(); + } } inline bool canBlitterFillRect() const { - return !fillRectState || (fillRectState & fillRectMask); + return checkStateAgainstMask(capabillitiesState,fillRectMask); } inline bool canBlitterDrawRectMask() const { - return drawRectState & drawRectMask; + return checkStateAgainstMask(capabillitiesState,drawRectMask); } bool canBlitterDrawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) const { if (pm.pixmapData()->classId() != QPixmapData::BlitterClass) return false; - if ((!drawPixmapState) || drawPixmapState & drawPixmapMask) { + if (checkStateAgainstMask(capabillitiesState,drawPixmapMask)) { if (m_capabilities & (QBlittable::SourceOverPixmapCapability | QBlittable::SourceOverScaledPixmapCapability)) { if (r.size() != sr.size()) { @@ -80,21 +89,8 @@ public: return false; } - inline void updateFillRectBits(uint mask, bool on) { - updateStateBits(&fillRectState,mask,on); - } - - inline void updateDrawRectBits(uint mask, bool on) { - updateStateBits(&drawRectState,mask,on); - } - - inline void updateDrawPixmapBits(uint mask, bool on) { - updateStateBits(&drawPixmapState,mask,on); - } - inline void updateAllWithBits(uint mask, bool on) { - updateStateBits(&fillRectState,mask,on); - updateStateBits(&drawRectState,mask,on); - updateStateBits(&drawPixmapState,mask,on); + inline void updateState(uint mask, bool on) { + updateStateBits(&capabillitiesState,mask,on); } public: @@ -138,17 +134,21 @@ public: setSourcePixmapMask(); } + void setSourceOverScaledPixmapMask() { + setSourceOverPixmapMask(); + updateStateBits(&drawRectMask, STATE_XFORM_SCALE, true); + } + QBlittable::Capabilities m_capabilities; uint fillRectMask; - uint fillRectState; uint drawRectMask; - uint drawRectState; uint drawPixmapMask; - uint drawPixmapState; + uint capabillitiesState; }; class QBlitterPaintEnginePrivate : public QPaintEngineExPrivate { + Q_DECLARE_PUBLIC(QBlitterPaintEngine); public: QBlitterPaintEnginePrivate(QBlittablePixmapData *p) : QPaintEngineExPrivate(), @@ -176,12 +176,13 @@ public: } void fillRect(const QRectF &rect, const QColor &color) { + Q_Q(QBlitterPaintEngine); pmData->unmarkRasterOverlay(rect); QRectF targetRect = rect; if (hasXForm) { - targetRect = state->matrix.mapRect(rect); + targetRect = q->state()->matrix.mapRect(rect); } - const QClipData *clipData = raster->d_func()->clip();; + const QClipData *clipData = q->clip(); if (clipData) { if (clipData->hasRectClip) { unlock(); @@ -214,23 +215,23 @@ public: QRectF intersectedRect = clip.intersected(target); if (intersectedRect.isEmpty()) return; - QRectF source = sr; if(intersectedRect.size() != target.size()) { qreal deltaTop = target.top() - intersectedRect.top(); qreal deltaLeft = target.left() - intersectedRect.left(); qreal deltaBottom = target.bottom() - intersectedRect.bottom(); qreal deltaRight = target.right() - intersectedRect.right(); - source.adjust(-deltaLeft,-deltaTop,deltaRight,deltaBottom); + source.adjust(-deltaLeft,-deltaTop,-deltaRight,-deltaBottom); } pmData->unmarkRasterOverlay(intersectedRect); pmData->blittable()->drawPixmap(intersectedRect, pm, source); } void updateClip() { - const QClipData *clip = raster->d_func()->clip(); - bool complex = clip != 0 && !(clip->hasRectClip || clip->hasRegionClip); - capabillities->updateAllWithBits(STATE_CLIP_COMPLEX, complex); + Q_Q(QBlitterPaintEngine); + const QClipData *clip = q->clip(); + bool complex = clip && !(clip->hasRectClip || clip->hasRegionClip); + capabillities->updateState(STATE_CLIP_COMPLEX, complex); } void systemStateChanged() { @@ -238,7 +239,6 @@ public: } QRasterPaintEngine *raster; - QRasterPaintEngineState *state; QBlittablePixmapData *pmData; bool isBlitterLocked; @@ -267,8 +267,6 @@ bool QBlitterPaintEngine::begin(QPaintDevice *pdev) { Q_D(QBlitterPaintEngine); - d->raster->setSystemRect(systemRect()); - d->raster->setSystemClip(systemClip()); setActive(true); bool ok = d->raster->begin(pdev); #ifdef QT_BLITTER_RASTEROVERLAY @@ -282,8 +280,6 @@ bool QBlitterPaintEngine::end() { Q_D(QBlitterPaintEngine); - d->raster->setPaintDevice(0); - d->raster->setActive(false); setActive(false); #ifdef QT_BLITTER_RASTEROVERLAY d->pmData->mergeOverlay(); @@ -321,7 +317,9 @@ void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) { if(rect.size().isEmpty()) return; + Q_D(QBlitterPaintEngine); + if (qbrush_style(brush) == Qt::SolidPattern && qbrush_color(brush).alpha() == 0xff && d->capabillities->canBlitterFillRect()) @@ -336,11 +334,11 @@ void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) qreal y = transformedRect.y(); QPixmap pm = brush.texture(); d->unlock(); - int srcX = (int)(rect.x() - d->raster->state()->brushOrigin.x()) % pm.width(); + int srcX = int(rect.x() - state()->brushOrigin.x()) % pm.width(); if (srcX < 0) srcX = pm.width() + srcX; const int startX = srcX; - int srcY = (int)(rect.y() - d->raster->state()->brushOrigin.y())% pm.height(); + int srcY = int(rect.y() - state()->brushOrigin.y()) % pm.height(); if (srcY < 0) srcY = pm.height() + srcY; while (!rectIsFilled) { @@ -350,7 +348,7 @@ void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) blitWidth = transformedRect.right() -x; if (y + blitHeight > transformedRect.bottom()) blitHeight = transformedRect.bottom() - y; - const QClipData *clipData = d->raster->d_func()->clip(); + const QClipData *clipData = clip(); if (clipData->hasRectClip) { QRect targetRect = QRect(x,y,blitWidth,blitHeight).intersected(clipData->clipRect); if (targetRect.isValid()) { @@ -434,7 +432,7 @@ void QBlitterPaintEngine::penChanged() Q_D(QBlitterPaintEngine); d->lock(); d->raster->penChanged(); - d->capabillities->updateDrawRectBits(STATE_PEN_ENABLED,qpen_style(d->state->pen) != Qt::NoPen); + d->capabillities->updateState(STATE_PEN_ENABLED,qpen_style(state()->pen) != Qt::NoPen); } void QBlitterPaintEngine::brushChanged() @@ -442,11 +440,11 @@ void QBlitterPaintEngine::brushChanged() Q_D(QBlitterPaintEngine); d->raster->brushChanged(); - bool solid = qbrush_style(d->state->brush) == Qt::SolidPattern; + bool solid = qbrush_style(state()->brush) == Qt::SolidPattern; - d->capabillities->updateDrawRectBits(STATE_BRUSH_PATTERN, !solid); - d->capabillities->updateDrawRectBits(STATE_BRUSH_ALPHA, - qbrush_color(d->state->brush).alpha() < 255); + d->capabillities->updateState(STATE_BRUSH_PATTERN, !solid); + d->capabillities->updateState(STATE_BRUSH_ALPHA, + qbrush_color(state()->brush).alpha() < 255); } void QBlitterPaintEngine::brushOriginChanged() @@ -460,8 +458,8 @@ void QBlitterPaintEngine::opacityChanged() Q_D(QBlitterPaintEngine); d->raster->opacityChanged(); - bool translucent = d->state->opacity < 1; - d->capabillities->updateAllWithBits(STATE_ALPHA,translucent); + bool translucent = state()->opacity < 1; + d->capabillities->updateState(STATE_ALPHA,translucent); } void QBlitterPaintEngine::compositionModeChanged() @@ -469,10 +467,10 @@ void QBlitterPaintEngine::compositionModeChanged() Q_D(QBlitterPaintEngine); d->raster->compositionModeChanged(); - bool nonTrivial = d->state->composition_mode != QPainter::CompositionMode_SourceOver - && d->state->composition_mode != QPainter::CompositionMode_Source; + bool nonTrivial = state()->composition_mode != QPainter::CompositionMode_SourceOver + && state()->composition_mode != QPainter::CompositionMode_Source; - d->capabillities->updateAllWithBits(STATE_BLENDING_COMPLEX,nonTrivial); + d->capabillities->updateState(STATE_BLENDING_COMPLEX,nonTrivial); } void QBlitterPaintEngine::renderHintsChanged() @@ -480,9 +478,8 @@ void QBlitterPaintEngine::renderHintsChanged() Q_D(QBlitterPaintEngine); d->raster->renderHintsChanged(); - bool aa = d->state->renderHints & QPainter::Antialiasing; - d->capabillities->updateFillRectBits(STATE_ANTIALIASING, aa); - d->capabillities->updateDrawRectBits(STATE_ANTIALIASING, aa); + bool aa = state()->renderHints & QPainter::Antialiasing; + d->capabillities->updateState(STATE_ANTIALIASING, aa); } @@ -491,9 +488,10 @@ void QBlitterPaintEngine::transformChanged() Q_D(QBlitterPaintEngine); d->raster->transformChanged(); - QTransform::TransformationType type = d->state->matrix.type(); + QTransform::TransformationType type = state()->matrix.type(); - d->capabillities->updateAllWithBits(STATE_XFORM_COMPLEX, type > QTransform::TxScale); + d->capabillities->updateState(STATE_XFORM_COMPLEX, type > QTransform::TxScale); + d->capabillities->updateState(STATE_XFORM_SCALE, type > QTransform::TxTranslate); d->hasXForm = type >= QTransform::TxTranslate; @@ -504,7 +502,7 @@ void QBlitterPaintEngine::drawRects(const QRect *rects, int rectCount) Q_D(QBlitterPaintEngine); if (d->capabillities->canBlitterDrawRectMask()) { for (int i=0; ifillRect(rects[i], qbrush_color(d->state->brush)); + d->fillRect(rects[i], qbrush_color(state()->brush)); } } else { d->pmData->markRasterOverlay(rects,rectCount); @@ -517,7 +515,7 @@ void QBlitterPaintEngine::drawRects(const QRectF *rects, int rectCount) Q_D(QBlitterPaintEngine); if (d->capabillities->canBlitterDrawRectMask()) { for (int i=0; ifillRect(rects[i], qbrush_color(d->state->brush)); + d->fillRect(rects[i], qbrush_color(state()->brush)); } } else { d->pmData->markRasterOverlay(rects,rectCount); @@ -600,7 +598,6 @@ void QBlitterPaintEngine::setState(QPainterState *s) d->lock(); QPaintEngineEx::setState(s); d->raster->setState(s); - d->state = (QRasterPaintEngineState *) s; clipEnabledChanged(); penChanged(); diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index d436993..3a2fce5 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -64,7 +64,6 @@ public: private: QRasterPaintEngine *raster() const; - }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/directfb/qblitter_directfb.cpp b/src/plugins/platforms/directfb/qblitter_directfb.cpp index 08dee0a..6525022 100644 --- a/src/plugins/platforms/directfb/qblitter_directfb.cpp +++ b/src/plugins/platforms/directfb/qblitter_directfb.cpp @@ -28,6 +28,7 @@ QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, IDirectFBSurface *surface) dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); m_surface->Clear(m_surface,0,0,0,0); } + } QDirectFbBlitter::~QDirectFbBlitter() @@ -60,13 +61,11 @@ void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, con IDirectFBSurface *s = dfbBlitter->m_surface; quint32 blittingFlags = pixmap.hasAlpha()? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; - - s->SetBlittingFlags(s, DFBSurfaceBlittingFlags(blittingFlags)); m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags)); m_surface->SetPorterDuff(m_surface,DSPD_SRC_OVER); m_surface->SetDstBlendFunction(m_surface,DSBF_INVSRCALPHA); - const DFBRectangle sRect = { srcRect.x(), srcRect.y(), rect.width(), rect.height() }; + const DFBRectangle sRect = { srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height() }; DFBResult result; if (rect.width() == srcRect.width() && rect.height() == srcRect.height()) -- cgit v0.12 From 3cf347414ce2203178893fb1fa1d005633d37526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 12 Apr 2010 13:47:52 +0200 Subject: Small optimalisation in DirectfbBlitter --- src/gui/painting/qpaintengine_blitter.cpp | 2 +- src/plugins/platforms/directfb/qblitter_directfb.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 54a146f..4144696 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -533,7 +533,7 @@ void QBlitterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const Q if (d->hasXForm) { targetRect = state()->matrix.mapRect(r); } - const QClipData *clipData = d->raster->d_func()->clip(); + const QClipData *clipData = clip(); if (clipData) { if (clipData->hasRectClip) { d->clipAndDrawPixmap(clipData->clipRect,targetRect,pm,sr); diff --git a/src/plugins/platforms/directfb/qblitter_directfb.cpp b/src/plugins/platforms/directfb/qblitter_directfb.cpp index 6525022..20f8741 100644 --- a/src/plugins/platforms/directfb/qblitter_directfb.cpp +++ b/src/plugins/platforms/directfb/qblitter_directfb.cpp @@ -60,9 +60,15 @@ void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, con IDirectFBSurface *s = dfbBlitter->m_surface; - quint32 blittingFlags = pixmap.hasAlpha()? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; + DFBSurfaceBlittingFlags blittingFlags = DSBLIT_NOFX; + DFBSurfacePorterDuffRule porterDuff = DSPD_SRC; + if (pixmap.hasAlpha()) { + blittingFlags = DSBLIT_BLEND_ALPHACHANNEL; + porterDuff = DSPD_SRC_OVER; + } + m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags)); - m_surface->SetPorterDuff(m_surface,DSPD_SRC_OVER); + m_surface->SetPorterDuff(m_surface,porterDuff); m_surface->SetDstBlendFunction(m_surface,DSBF_INVSRCALPHA); const DFBRectangle sRect = { srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height() }; -- cgit v0.12 From 1d768c1deb98a8e32cdbd7790186e1d6a81acc29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 12 Apr 2010 14:20:39 +0200 Subject: Ifdef out QPlatformWindow implementation when not compiling lighthouse --- src/gui/kernel/qwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 7eaf03c..07639ba 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11842,6 +11842,7 @@ QWindowSurface *QWidget::windowSurface() const return bs ? bs->windowSurface : 0; } +#if defined(Q_WS_LITE) /*! \preliminary @@ -11879,6 +11880,7 @@ QPlatformWindow *QWidget::platformWindow() const return 0; } +#endif //defined(Q_WS_LITE) void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const { -- cgit v0.12 From 80c3790501df2ce3a8edf022e469317bc6f66246 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 12 Apr 2010 15:21:35 +0200 Subject: Make the VNC plugin compile and largely work --- src/gui/kernel/qplatformscreen_lite.h | 4 +- src/gui/kernel/qwidget_lite.cpp | 18 +++- src/plugins/platforms/fb_base/fb_base.cpp | 98 ++++++++++++++++------ src/plugins/platforms/fb_base/fb_base.h | 58 ++++++++++--- src/plugins/platforms/testlite/qtestlitewindow.cpp | 1 + src/plugins/platforms/vnc/main.cpp | 8 +- src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp | 22 ++++- src/plugins/platforms/vnc/qgraphicssystem_vnc.h | 11 +-- src/plugins/platforms/vnc/vnc.pro | 4 +- 9 files changed, 168 insertions(+), 56 deletions(-) diff --git a/src/gui/kernel/qplatformscreen_lite.h b/src/gui/kernel/qplatformscreen_lite.h index da0e26b..cae5f42 100644 --- a/src/gui/kernel/qplatformscreen_lite.h +++ b/src/gui/kernel/qplatformscreen_lite.h @@ -44,6 +44,7 @@ #include #include +#include QT_BEGIN_HEADER @@ -51,8 +52,9 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) -class Q_GUI_EXPORT QPlatformScreen +class Q_GUI_EXPORT QPlatformScreen : public QObject { + Q_OBJECT public: virtual ~QPlatformScreen() { } diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index cf93c5e..465dbee 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -90,10 +90,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO void QWidget::destroy(bool destroyWindow, bool destroySubWindows) { - Q_UNUSED(destroyWindow); + Q_D(QWidget); Q_UNUSED(destroySubWindows); - // XXX - if ((windowType() == Qt::Popup)) qApp->d_func()->closePopup(this); @@ -101,6 +99,20 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) //### we don't have proper focus event handling yet if (this == QApplicationPrivate::active_window) QApplication::setActiveWindow(0); + + if (windowType() != Qt::Desktop) { + if (destroyWindow && isWindow()) { + QTLWExtra *topData = d->maybeTopData(); + if (topData) { + delete topData->platformWindow; + topData->platformWindow = 0; + } + } else { + if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) { + d->hide_sys(); + } + } + } } void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index d30746a..422222c 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -6,7 +6,7 @@ #include #include -QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen *scr) +QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QPlatformScreen *scr) : QGraphicsSystemCursor(scr), currentRect(QRect()), prevRect(QRect()) { graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); @@ -126,6 +126,8 @@ QGraphicsSystemFbScreen::~QGraphicsSystemFbScreen() void QGraphicsSystemFbScreen::setDirty(const QRect &rect) { + +// qDebug() << "QGraphicsSystemFbScreen::setDirty" << rect; repaintRegion += rect; if (!redrawTimer.isActive()) { redrawTimer.start(); @@ -140,7 +142,7 @@ void QGraphicsSystemFbScreen::generateRects() for (int i = 0; i < windowStack.length(); i++) { if (remainingScreen.isEmpty()) break; - if (!windowStack[i]->window()->testAttribute(Qt::WA_TranslucentBackground)) { + if (!windowStack[i]->widget()->testAttribute(Qt::WA_TranslucentBackground)) { remainingScreen -= windowStack[i]->geometry(); QRegion windowRegion(windowStack[i]->geometry()); windowRegion -= remainingScreen; @@ -197,12 +199,13 @@ QRegion QGraphicsSystemFbScreen::doRedraw() for (int layerIndex = layer; layerIndex != -1; layerIndex--) { if (!windowStack[layerIndex]->visible()) continue; - if (windowStack[layerIndex]->window()->isMinimized()) + if (windowStack[layerIndex]->widget()->isMinimized()) continue; QRect windowRect = windowStack[layerIndex]->geometry(); QRect windowIntersect = rect.translated(-windowRect.left(), -windowRect.top()); - compositePainter->drawImage(rect, windowStack[layerIndex]->image(), +// qDebug() << " compositing" << layerIndex << windowStack[layerIndex]->surface->image().size(); + compositePainter->drawImage(rect, windowStack[layerIndex]->surface->image(), windowIntersect); if (firstLayer) { firstLayer = false; @@ -224,24 +227,29 @@ QRegion QGraphicsSystemFbScreen::doRedraw() touchedRegion += repaintRegion; repaintRegion = QRegion(); + + +// qDebug() << "QGraphicsSystemFbScreen::doRedraw" << windowStack.size() << mScreenImage->size() << touchedRegion; + + return touchedRegion; } -void QGraphicsSystemFbScreen::removeWindowSurface(QGraphicsSystemFbWindowSurface * surface) +void QGraphicsSystemFbScreen::removeWindow(QFbWindow * surface) { windowStack.removeOne(surface); invalidateRectCache(); setDirty(surface->geometry()); } -void QGraphicsSystemFbWindowSurface::raise() +void QFbWindow::raise() { mScreen->raise(this); } -void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) +void QGraphicsSystemFbScreen::raise(QPlatformWindow * surface) { - QGraphicsSystemFbWindowSurface *s = static_cast(surface); + QFbWindow *s = static_cast(surface); int index = windowStack.indexOf(s); if (index <= 0) return; @@ -250,14 +258,14 @@ void QGraphicsSystemFbScreen::raise(QWindowSurface * surface) setDirty(s->geometry()); } -void QGraphicsSystemFbWindowSurface::lower() +void QFbWindow::lower() { mScreen->lower(this); } -void QGraphicsSystemFbScreen::lower(QWindowSurface * surface) +void QGraphicsSystemFbScreen::lower(QPlatformWindow * surface) { - QGraphicsSystemFbWindowSurface *s = static_cast(surface); + QFbWindow *s = static_cast(surface); int index = windowStack.indexOf(s); if (index == -1 || index == (windowStack.size() - 1)) return; @@ -271,34 +279,61 @@ QWidget * QGraphicsSystemFbScreen::topLevelAt(const QPoint & p) const for(int i = 0; i < windowStack.size(); i++) { if (windowStack[i]->geometry().contains(p, false) && windowStack[i]->visible() && - !windowStack[i]->window()->isMinimized()) { - return windowStack[i]->window(); + !windowStack[i]->widget()->isMinimized()) { + return windowStack[i]->widget(); } } return 0; } -QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window) - : QWindowSurface(window), + + +QFbWindow::QFbWindow(QGraphicsSystemFbScreen *screen, QWidget *window) + :QPlatformWindow(window), mScreen(screen), visibleFlag(false) { static QAtomicInt winIdGenerator(1); + windowId = winIdGenerator.fetchAndAddRelaxed(1); +} + + +QFbWindow::~QFbWindow() +{ + mScreen->removeWindow(this); +} + +QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen) +{ mImage = QImage(window->size(), mScreen->format()); - windowId = winIdGenerator.fetchAndAddRelaxed(1); + + platformWindow = static_cast(window->platformWindow()); + platformWindow->surface = this; } QGraphicsSystemFbWindowSurface::~QGraphicsSystemFbWindowSurface() { - mScreen->removeWindowSurface(this); } + void QGraphicsSystemFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(widget); Q_UNUSED(offset); + +// qDebug() << "QGraphicsSystemFbWindowSurface::flush" << region; + + + platformWindow->repaint(region); +} + + +void QFbWindow::repaint(const QRegion ®ion) +{ QRect currentGeometry = geometry(); // If this is a move, redraw the previous location if (oldGeometry != currentGeometry) { @@ -314,21 +349,30 @@ void QGraphicsSystemFbWindowSurface::flush(QWidget *widget, const QRegion ®io mScreen->setDirty(dirtyRegion); } -void QGraphicsSystemFbWindowSurface::setGeometry(const QRect &rect) +void QGraphicsSystemFbWindowSurface::resize(const QSize &size) { - // store previous geometry for screen update + // change the widget's QImage if this is a resize + if (mImage.size() != size) + mImage = QImage(size, mScreen->format()); + QWindowSurface::resize(size); +} + +void QFbWindow::setGeometry(const QRect &rect) +{ +// store previous geometry for screen update oldGeometry = geometry(); - // change the widget's QImage if this is a resize - if (mImage.size() != rect.size()) - mImage = QImage(rect.size(), mScreen->format()); mScreen->invalidateRectCache(); - QWindowSystemInterface::handleGeometryChange(window(), rect); +//### QWindowSystemInterface::handleGeometryChange(window(), rect); - QWindowSurface::setGeometry(rect); + QPlatformWindow::setGeometry(rect); } + + + + bool QGraphicsSystemFbWindowSurface::scroll(const QRegion &area, int dx, int dy) { return QWindowSurface::scroll(area, dx, dy); @@ -344,21 +388,21 @@ void QGraphicsSystemFbWindowSurface::endPaint(const QRegion ®ion) Q_UNUSED(region); } -void QGraphicsSystemFbWindowSurface::setVisible(bool visible) +void QFbWindow::setVisible(bool visible) { visibleFlag = visible; mScreen->invalidateRectCache(); mScreen->setDirty(geometry()); } -Qt::WindowFlags QGraphicsSystemFbWindowSurface::setWindowFlags(Qt::WindowFlags type) +Qt::WindowFlags QFbWindow::setWindowFlags(Qt::WindowFlags type) { flags = type; mScreen->invalidateRectCache(); return flags; } -Qt::WindowFlags QGraphicsSystemFbWindowSurface::windowFlags() const +Qt::WindowFlags QFbWindow::windowFlags() const { return flags; } diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index 7f9b005..8df6b8e 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -1,12 +1,14 @@ #ifndef QLIGHTHOUSEGRAPHICSSCREEN_H #define QLIGHTHOUSEGRAPHICSSCREEN_H -#include +//#include #include #include #include #include #include +#include +#include class QMouseEvent; class QSize; @@ -17,7 +19,7 @@ class QGraphicsSystemFbScreen; class QGraphicsSystemSoftwareCursor : public QGraphicsSystemCursor { public: - QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen * scr); + QGraphicsSystemSoftwareCursor(QPlatformScreen * scr); // output methods QRect dirtyRect(); @@ -39,6 +41,9 @@ private: QRect getCurrentRect(); }; + +class QFbWindow; + class QGraphicsSystemFbWindowSurface : public QWindowSurface { public: @@ -51,30 +56,58 @@ public: virtual void beginPaint(const QRegion ®ion); virtual void endPaint(const QRegion ®ion); - virtual void setVisible(bool visible); - virtual bool visible() { return visibleFlag; } + const QImage image() { return mImage; } - void setGeometry(const QRect &rect); + void resize(const QSize &size); + +protected: + friend class QFbWindow; + QFbWindow *platformWindow; + + QGraphicsSystemFbScreen *mScreen; + QImage mImage; +}; + + +class QFbWindow : public QPlatformWindow +{ +public: + + QFbWindow(QGraphicsSystemFbScreen *screen, QWidget *window); + ~QFbWindow(); + + + virtual void setVisible(bool visible); + virtual bool visible() { return visibleFlag; } virtual void raise(); virtual void lower(); + void setGeometry(const QRect &rect); + virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type); virtual Qt::WindowFlags windowFlags() const; WId winId() const { return windowId; } + + virtual void repaint(const QRegion&); + protected: + friend class QGraphicsSystemFbWindowSurface; + friend class QGraphicsSystemFbScreen; + QGraphicsSystemFbWindowSurface *surface; QGraphicsSystemFbScreen *mScreen; QRect oldGeometry; - QImage mImage; bool visibleFlag; Qt::WindowFlags flags; + WId windowId; }; -class QGraphicsSystemFbScreen : public QGraphicsSystemScreen + +class QGraphicsSystemFbScreen : public QPlatformScreen { Q_OBJECT public: @@ -93,18 +126,18 @@ public: virtual void setDirty(const QRect &rect); - virtual void removeWindowSurface(QGraphicsSystemFbWindowSurface * surface); - virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { + virtual void removeWindow(QFbWindow * surface); + virtual void addWindow(QFbWindow * surface) { windowStack.prepend(surface); invalidateRectCache(); } - virtual void raise(QWindowSurface * surface); - virtual void lower(QWindowSurface * surface); + virtual void raise(QPlatformWindow * surface); + virtual void lower(QPlatformWindow * surface); virtual QWidget * topLevelAt(const QPoint & p) const; QImage * image() const { return mScreenImage; } QPaintDevice * paintDevice() const { return mScreenImage; } protected: - QList windowStack; + QList windowStack; QRegion repaintRegion; QGraphicsSystemSoftwareCursor * cursor; QTimer redrawTimer; @@ -126,6 +159,7 @@ private: void invalidateRectCache() { isUpToDate = false; } friend class QGraphicsSystemFbWindowSurface; + friend class QFbWindow; bool isUpToDate; }; diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index db3904f..0b215e3 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -622,6 +622,7 @@ void QTestLiteWindow::setGeometry(const QRect &rect) //if unchanged ### XMoveResizeWindow(xd->display, x_window, rect.x(), rect.y(), rect.width(), rect.height()); + QPlatformWindow::setGeometry(rect); } diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp index f10748a..9de33eb 100644 --- a/src/plugins/platforms/vnc/main.cpp +++ b/src/plugins/platforms/vnc/main.cpp @@ -39,17 +39,17 @@ ** ****************************************************************************/ -#include #include "qgraphicssystem_vnc.h" #include +#include QT_BEGIN_NAMESPACE -class QVNCGraphicsSystemPlugin : public QGraphicsSystemPlugin +class QVNCGraphicsSystemPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QGraphicsSystem *create(const QString&); + QPlatformIntegration *create(const QString&); }; QStringList QVNCGraphicsSystemPlugin::keys() const @@ -59,7 +59,7 @@ QStringList QVNCGraphicsSystemPlugin::keys() const return list; } -QGraphicsSystem* QVNCGraphicsSystemPlugin::create(const QString& system) +QPlatformIntegration* QVNCGraphicsSystemPlugin::create(const QString& system) { if (system.toLower() == "vnc") return new QVNCGraphicsSystem; diff --git a/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp b/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp index 7815f24..ef50230 100644 --- a/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp +++ b/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp @@ -104,12 +104,30 @@ QPixmapData *QVNCGraphicsSystem::createPixmapData(QPixmapData::PixelType type) c return new QRasterPixmapData(type); } -QWindowSurface *QVNCGraphicsSystem::createWindowSurface(QWidget *widget) const +// QWindowSurface *QVNCGraphicsSystem::createWindowSurface(QWidget *widget) const +// { +// if (widget->windowType() == Qt::Desktop) +// return 0; // Don't create an explicit window surface for the destkop. +// QGraphicsSystemFbWindowSurface * surface; +// surface = new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); +// mPrimaryScreen->addWindowSurface(surface); +// return surface; +// } + +QWindowSurface *QVNCGraphicsSystem::createWindowSurfaceForWindow(QWidget *widget, WId) const { if (widget->windowType() == Qt::Desktop) return 0; // Don't create an explicit window surface for the destkop. QGraphicsSystemFbWindowSurface * surface; surface = new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); - mPrimaryScreen->addWindowSurface(surface); return surface; } + + +QPlatformWindow *QVNCGraphicsSystem::createPlatformWindow(QWidget *widget, WId /*winId*/) const +{ + QFbWindow *w = new QFbWindow(mPrimaryScreen, widget); + mPrimaryScreen->addWindow(w); + return w; +} + diff --git a/src/plugins/platforms/vnc/qgraphicssystem_vnc.h b/src/plugins/platforms/vnc/qgraphicssystem_vnc.h index b3349b7..3205872 100644 --- a/src/plugins/platforms/vnc/qgraphicssystem_vnc.h +++ b/src/plugins/platforms/vnc/qgraphicssystem_vnc.h @@ -42,9 +42,9 @@ #ifndef QGRAPHICSSYSTEM_VNC_H #define QGRAPHICSSYSTEM_VNC_H -#include #include "qvnccursor.h" #include "../fb_base/fb_base.h" +#include QT_BEGIN_NAMESPACE @@ -73,20 +73,21 @@ private: class QVNCGraphicsSystemPrivate; -class QVNCGraphicsSystem : public QGraphicsSystem +class QVNCGraphicsSystem : public QPlatformIntegration { public: QVNCGraphicsSystem(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const; - QList screens() const { return mScreens; } + QList screens() const { return mScreens; } private: QVNCGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; + QList mScreens; }; diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro index 0b73b5b..b1da572 100644 --- a/src/plugins/platforms/vnc/vnc.pro +++ b/src/plugins/platforms/vnc/vnc.pro @@ -1,7 +1,7 @@ TARGET = qvncgraphicssystem include(../../qpluginbase.pri) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms SOURCES = main.cpp qgraphicssystem_vnc.cpp HEADERS = qgraphicssystem_vnc.h @@ -14,6 +14,6 @@ SOURCES += qvnccursor.cpp include(../fb_base/fb_base.pri) -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target -- cgit v0.12 From a87d8966946c47e234b8d5268c287ac96f1ea4c4 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 12 Apr 2010 15:44:57 +0200 Subject: Make hide() work. --- src/plugins/platforms/fb_base/fb_base.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index 422222c..25426eb 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -142,6 +142,9 @@ void QGraphicsSystemFbScreen::generateRects() for (int i = 0; i < windowStack.length(); i++) { if (remainingScreen.isEmpty()) break; + if (!windowStack[i]->visible()) + continue; + if (!windowStack[i]->widget()->testAttribute(Qt::WA_TranslucentBackground)) { remainingScreen -= windowStack[i]->geometry(); QRegion windowRegion(windowStack[i]->geometry()); -- cgit v0.12 From 3a8b3299d7c956e3a9f4733bc7d459757081bdc2 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 12 Apr 2010 16:55:56 +0200 Subject: Make LinuxFb work --- src/gui/kernel/qapplication_lite.cpp | 11 +++++++++++ src/plugins/platforms/linuxfb/linuxfb.pro | 4 ++-- src/plugins/platforms/linuxfb/main.cpp | 8 ++++---- .../platforms/linuxfb/qgraphicssystem_linuxfb.cpp | 16 ++++++++++++++-- src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h | 11 ++++++----- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 87fa933..867c2dc 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -422,6 +422,15 @@ static void init_platform(const QString &name) } + +static void cleanup_platform() +{ + delete QApplicationPrivate::platform_integration; + QApplicationPrivate::platform_integration = 0; + delete QApplicationPrivate::graphics_system; + QApplicationPrivate::graphics_system = 0; +} + static void init_plugins(const QList pluginList) { for (int i = 0; i < pluginList.count(); ++i) { @@ -520,6 +529,8 @@ void qt_init(QApplicationPrivate *priv, int type) void qt_cleanup() { + cleanup_platform(); + QPixmapCache::clear(); #ifndef QT_NO_CURSOR QCursorData::cleanup(); diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro index 031b843..2633a10 100644 --- a/src/plugins/platforms/linuxfb/linuxfb.pro +++ b/src/plugins/platforms/linuxfb/linuxfb.pro @@ -1,12 +1,12 @@ TARGET = qlinuxfbgraphicssystem include(../../qpluginbase.pri) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms SOURCES = main.cpp qgraphicssystem_linuxfb.cpp HEADERS = qgraphicssystem_linuxfb.h include(../fb_base/fb_base.pri) -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/linuxfb/main.cpp b/src/plugins/platforms/linuxfb/main.cpp index 4d03fe5..15305ed 100644 --- a/src/plugins/platforms/linuxfb/main.cpp +++ b/src/plugins/platforms/linuxfb/main.cpp @@ -39,16 +39,16 @@ ** ****************************************************************************/ -#include +#include #include "qgraphicssystem_linuxfb.h" QT_BEGIN_NAMESPACE -class QLinuxFbGraphicsSystemPlugin : public QGraphicsSystemPlugin +class QLinuxFbGraphicsSystemPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QGraphicsSystem *create(const QString&); + QPlatformIntegration *create(const QString&); }; QStringList QLinuxFbGraphicsSystemPlugin::keys() const @@ -58,7 +58,7 @@ QStringList QLinuxFbGraphicsSystemPlugin::keys() const return list; } -QGraphicsSystem* QLinuxFbGraphicsSystemPlugin::create(const QString& system) +QPlatformIntegration* QLinuxFbGraphicsSystemPlugin::create(const QString& system) { if (system.toLower() == "linuxfb") return new QLinuxFbGraphicsSystem; diff --git a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp index 44960bb..cca567c 100644 --- a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp +++ b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp @@ -786,16 +786,28 @@ QPixmapData *QLinuxFbGraphicsSystem::createPixmapData(QPixmapData::PixelType typ return new QRasterPixmapData(type); } -QWindowSurface *QLinuxFbGraphicsSystem::createWindowSurface(QWidget *widget) const +QWindowSurface *QLinuxFbGraphicsSystem::createWindowSurfaceForWindow(QWidget *widget, WId) const { if (widget->windowType() == Qt::Desktop) return 0; // Don't create an explicit window surface for the destkop. QGraphicsSystemFbWindowSurface * surface = new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); - mPrimaryScreen->addWindowSurface(surface); return surface; } + + +QPlatformWindow *QLinuxFbGraphicsSystem::createPlatformWindow(QWidget *widget, WId /*winId*/) const +{ + QFbWindow *w = new QFbWindow(mPrimaryScreen, widget); + mPrimaryScreen->addWindow(w); + return w; +} + + + + + QLinuxFbGraphicsSystemScreen::QLinuxFbGraphicsSystemScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat) : compositePainter(0) { diff --git a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h index cc8ce7e..873b463 100644 --- a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h +++ b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h @@ -42,7 +42,7 @@ #ifndef QGRAPHICSSYSTEM_LINUXFB_H #define QGRAPHICSSYSTEM_LINUXFB_H -#include +#include #include "../fb_base/fb_base.h" QT_BEGIN_NAMESPACE @@ -70,20 +70,21 @@ struct fb_cmap; struct fb_var_screeninfo; struct fb_fix_screeninfo; -class QLinuxFbGraphicsSystem : public QGraphicsSystem +class QLinuxFbGraphicsSystem : public QPlatformIntegration { public: QLinuxFbGraphicsSystem(); ~QLinuxFbGraphicsSystem(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId WinId) const; + QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId WinId) const; - QList screens() const { return mScreens; } + QList screens() const { return mScreens; } private: QLinuxFbGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; + QList mScreens; QLinuxFbGraphicsSystemPrivate *d_ptr; enum PixelType { NormalPixel, BGRPixel }; -- cgit v0.12 From c8f86b525a6eabb91ad4da2dfdd423a32263359a Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 13 Apr 2010 10:57:50 +0200 Subject: Rename classes to get rid of "GraphicsSystem" --- src/plugins/platforms/fb_base/fb_base.cpp | 48 ++++++++-------- src/plugins/platforms/fb_base/fb_base.h | 28 +++++----- src/plugins/platforms/linuxfb/main.cpp | 10 ++-- .../platforms/linuxfb/qgraphicssystem_linuxfb.cpp | 64 +++++++++++----------- .../platforms/linuxfb/qgraphicssystem_linuxfb.h | 16 +++--- src/plugins/platforms/vnc/main.cpp | 10 ++-- src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp | 32 +++++------ src/plugins/platforms/vnc/qgraphicssystem_vnc.h | 16 +++--- src/plugins/platforms/vnc/qvnccursor.cpp | 2 +- src/plugins/platforms/vnc/qvnccursor.h | 4 +- src/plugins/platforms/vnc/qvncserver.cpp | 16 +++--- src/plugins/platforms/vnc/qvncserver.h | 26 ++++----- 12 files changed, 136 insertions(+), 136 deletions(-) diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index 25426eb..1a6d04e 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -81,7 +81,7 @@ void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget screen->setDirty(currentRect); } -QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false) +QFbScreen::QFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false) { mScreenImage = new QImage(mGeometry.size(), mFormat); redrawTimer.setSingleShot(true); @@ -89,7 +89,7 @@ QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() : cursor(0), mGeometry(), mDe QObject::connect(&redrawTimer, SIGNAL(timeout()), this, SLOT(doRedraw())); } -void QGraphicsSystemFbScreen::setGeometry(QRect rect) +void QFbScreen::setGeometry(QRect rect) { delete mScreenImage; mGeometry = rect; @@ -99,17 +99,17 @@ void QGraphicsSystemFbScreen::setGeometry(QRect rect) invalidateRectCache(); } -void QGraphicsSystemFbScreen::setDepth(int depth) +void QFbScreen::setDepth(int depth) { mDepth = depth; } -void QGraphicsSystemFbScreen::setPhysicalSize(QSize size) +void QFbScreen::setPhysicalSize(QSize size) { mPhysicalSize = size; } -void QGraphicsSystemFbScreen::setFormat(QImage::Format format) +void QFbScreen::setFormat(QImage::Format format) { mFormat = format; delete mScreenImage; @@ -118,23 +118,23 @@ void QGraphicsSystemFbScreen::setFormat(QImage::Format format) compositePainter = 0; } -QGraphicsSystemFbScreen::~QGraphicsSystemFbScreen() +QFbScreen::~QFbScreen() { delete compositePainter; delete mScreenImage; } -void QGraphicsSystemFbScreen::setDirty(const QRect &rect) +void QFbScreen::setDirty(const QRect &rect) { -// qDebug() << "QGraphicsSystemFbScreen::setDirty" << rect; +// qDebug() << "QFbScreen::setDirty" << rect; repaintRegion += rect; if (!redrawTimer.isActive()) { redrawTimer.start(); } } -void QGraphicsSystemFbScreen::generateRects() +void QFbScreen::generateRects() { cachedRects.clear(); QRegion remainingScreen(mGeometry); @@ -162,7 +162,7 @@ void QGraphicsSystemFbScreen::generateRects() -QRegion QGraphicsSystemFbScreen::doRedraw() +QRegion QFbScreen::doRedraw() { QRegion touchedRegion; if (cursor) @@ -232,13 +232,13 @@ QRegion QGraphicsSystemFbScreen::doRedraw() -// qDebug() << "QGraphicsSystemFbScreen::doRedraw" << windowStack.size() << mScreenImage->size() << touchedRegion; +// qDebug() << "QFbScreen::doRedraw" << windowStack.size() << mScreenImage->size() << touchedRegion; return touchedRegion; } -void QGraphicsSystemFbScreen::removeWindow(QFbWindow * surface) +void QFbScreen::removeWindow(QFbWindow * surface) { windowStack.removeOne(surface); invalidateRectCache(); @@ -250,7 +250,7 @@ void QFbWindow::raise() mScreen->raise(this); } -void QGraphicsSystemFbScreen::raise(QPlatformWindow * surface) +void QFbScreen::raise(QPlatformWindow * surface) { QFbWindow *s = static_cast(surface); int index = windowStack.indexOf(s); @@ -266,7 +266,7 @@ void QFbWindow::lower() mScreen->lower(this); } -void QGraphicsSystemFbScreen::lower(QPlatformWindow * surface) +void QFbScreen::lower(QPlatformWindow * surface) { QFbWindow *s = static_cast(surface); int index = windowStack.indexOf(s); @@ -277,7 +277,7 @@ void QGraphicsSystemFbScreen::lower(QPlatformWindow * surface) setDirty(s->geometry()); } -QWidget * QGraphicsSystemFbScreen::topLevelAt(const QPoint & p) const +QWidget * QFbScreen::topLevelAt(const QPoint & p) const { for(int i = 0; i < windowStack.size(); i++) { if (windowStack[i]->geometry().contains(p, false) && @@ -291,7 +291,7 @@ QWidget * QGraphicsSystemFbScreen::topLevelAt(const QPoint & p) const -QFbWindow::QFbWindow(QGraphicsSystemFbScreen *screen, QWidget *window) +QFbWindow::QFbWindow(QFbScreen *screen, QWidget *window) :QPlatformWindow(window), mScreen(screen), visibleFlag(false) @@ -307,7 +307,7 @@ QFbWindow::~QFbWindow() } -QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window) +QFbWindowSurface::QFbWindowSurface(QFbScreen *screen, QWidget *window) : QWindowSurface(window), mScreen(screen) { @@ -317,18 +317,18 @@ QGraphicsSystemFbWindowSurface::QGraphicsSystemFbWindowSurface(QGraphicsSystemFb platformWindow->surface = this; } -QGraphicsSystemFbWindowSurface::~QGraphicsSystemFbWindowSurface() +QFbWindowSurface::~QFbWindowSurface() { } -void QGraphicsSystemFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +void QFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(widget); Q_UNUSED(offset); -// qDebug() << "QGraphicsSystemFbWindowSurface::flush" << region; +// qDebug() << "QFbWindowSurface::flush" << region; platformWindow->repaint(region); @@ -352,7 +352,7 @@ void QFbWindow::repaint(const QRegion ®ion) mScreen->setDirty(dirtyRegion); } -void QGraphicsSystemFbWindowSurface::resize(const QSize &size) +void QFbWindowSurface::resize(const QSize &size) { // change the widget's QImage if this is a resize if (mImage.size() != size) @@ -376,17 +376,17 @@ void QFbWindow::setGeometry(const QRect &rect) -bool QGraphicsSystemFbWindowSurface::scroll(const QRegion &area, int dx, int dy) +bool QFbWindowSurface::scroll(const QRegion &area, int dx, int dy) { return QWindowSurface::scroll(area, dx, dy); } -void QGraphicsSystemFbWindowSurface::beginPaint(const QRegion ®ion) +void QFbWindowSurface::beginPaint(const QRegion ®ion) { Q_UNUSED(region); } -void QGraphicsSystemFbWindowSurface::endPaint(const QRegion ®ion) +void QFbWindowSurface::endPaint(const QRegion ®ion) { Q_UNUSED(region); } diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index 8df6b8e..2738768 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -14,7 +14,7 @@ class QMouseEvent; class QSize; class QPainter; -class QGraphicsSystemFbScreen; +class QFbScreen; class QGraphicsSystemSoftwareCursor : public QGraphicsSystemCursor { @@ -44,11 +44,11 @@ private: class QFbWindow; -class QGraphicsSystemFbWindowSurface : public QWindowSurface +class QFbWindowSurface : public QWindowSurface { public: - QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window); - ~QGraphicsSystemFbWindowSurface(); + QFbWindowSurface(QFbScreen *screen, QWidget *window); + ~QFbWindowSurface(); virtual QPaintDevice *paintDevice() { return &mImage; } virtual void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); @@ -65,7 +65,7 @@ protected: friend class QFbWindow; QFbWindow *platformWindow; - QGraphicsSystemFbScreen *mScreen; + QFbScreen *mScreen; QImage mImage; }; @@ -74,7 +74,7 @@ class QFbWindow : public QPlatformWindow { public: - QFbWindow(QGraphicsSystemFbScreen *screen, QWidget *window); + QFbWindow(QFbScreen *screen, QWidget *window); ~QFbWindow(); @@ -94,10 +94,10 @@ public: virtual void repaint(const QRegion&); protected: - friend class QGraphicsSystemFbWindowSurface; - friend class QGraphicsSystemFbScreen; - QGraphicsSystemFbWindowSurface *surface; - QGraphicsSystemFbScreen *mScreen; + friend class QFbWindowSurface; + friend class QFbScreen; + QFbWindowSurface *surface; + QFbScreen *mScreen; QRect oldGeometry; bool visibleFlag; Qt::WindowFlags flags; @@ -107,12 +107,12 @@ protected: }; -class QGraphicsSystemFbScreen : public QPlatformScreen +class QFbScreen : public QPlatformScreen { Q_OBJECT public: - QGraphicsSystemFbScreen(); - ~QGraphicsSystemFbScreen(); + QFbScreen(); + ~QFbScreen(); virtual QRect geometry() const { return mGeometry; } virtual int depth() const { return mDepth; } @@ -158,7 +158,7 @@ private: QList > cachedRects; void invalidateRectCache() { isUpToDate = false; } - friend class QGraphicsSystemFbWindowSurface; + friend class QFbWindowSurface; friend class QFbWindow; bool isUpToDate; }; diff --git a/src/plugins/platforms/linuxfb/main.cpp b/src/plugins/platforms/linuxfb/main.cpp index 15305ed..1ee24b6 100644 --- a/src/plugins/platforms/linuxfb/main.cpp +++ b/src/plugins/platforms/linuxfb/main.cpp @@ -44,28 +44,28 @@ QT_BEGIN_NAMESPACE -class QLinuxFbGraphicsSystemPlugin : public QPlatformIntegrationPlugin +class QLinuxFbIntegrationPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; QPlatformIntegration *create(const QString&); }; -QStringList QLinuxFbGraphicsSystemPlugin::keys() const +QStringList QLinuxFbIntegrationPlugin::keys() const { QStringList list; list << "LinuxFb"; return list; } -QPlatformIntegration* QLinuxFbGraphicsSystemPlugin::create(const QString& system) +QPlatformIntegration* QLinuxFbIntegrationPlugin::create(const QString& system) { if (system.toLower() == "linuxfb") - return new QLinuxFbGraphicsSystem; + return new QLinuxFbIntegration; return 0; } -Q_EXPORT_PLUGIN2(linuxfb, QLinuxFbGraphicsSystemPlugin) +Q_EXPORT_PLUGIN2(linuxfb, QLinuxFbIntegrationPlugin) QT_END_NAMESPACE diff --git a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp index cca567c..25cdc7b 100644 --- a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp +++ b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp @@ -69,11 +69,11 @@ QT_BEGIN_NAMESPACE -class QLinuxFbGraphicsSystemPrivate +class QLinuxFbIntegrationPrivate { public: - QLinuxFbGraphicsSystemPrivate(); - ~QLinuxFbGraphicsSystemPrivate(); + QLinuxFbIntegrationPrivate(); + ~QLinuxFbIntegrationPrivate(); void openTty(); void closeTty(); @@ -94,7 +94,7 @@ public: QString displaySpec; }; -QLinuxFbGraphicsSystemPrivate::QLinuxFbGraphicsSystemPrivate() +QLinuxFbIntegrationPrivate::QLinuxFbIntegrationPrivate() : fd(-1), blank(true), doGraphicsMode(true), #ifdef QT_QWS_DEPTH_GENERIC doGenericColors(false), @@ -103,12 +103,12 @@ QLinuxFbGraphicsSystemPrivate::QLinuxFbGraphicsSystemPrivate() { } -QLinuxFbGraphicsSystemPrivate::~QLinuxFbGraphicsSystemPrivate() +QLinuxFbIntegrationPrivate::~QLinuxFbIntegrationPrivate() { closeTty(); } -void QLinuxFbGraphicsSystemPrivate::openTty() +void QLinuxFbIntegrationPrivate::openTty() { const char *const devs[] = {"/dev/tty0", "/dev/tty", "/dev/console", 0}; @@ -139,7 +139,7 @@ void QLinuxFbGraphicsSystemPrivate::openTty() QT_WRITE(ttyfd, termctl, sizeof(termctl)); } -void QLinuxFbGraphicsSystemPrivate::closeTty() +void QLinuxFbIntegrationPrivate::closeTty() { if (ttyfd == -1) return; @@ -155,33 +155,33 @@ void QLinuxFbGraphicsSystemPrivate::closeTty() ttyfd = -1; } -QLinuxFbGraphicsSystem::QLinuxFbGraphicsSystem() +QLinuxFbIntegration::QLinuxFbIntegration() { - d_ptr = new QLinuxFbGraphicsSystemPrivate(); + d_ptr = new QLinuxFbIntegrationPrivate(); // XXX QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY")); if (!connect(displaySpec)) - qFatal("QLinuxFbGraphicsSystem: could not initialize screen"); + qFatal("QLinuxFbIntegration: could not initialize screen"); initDevice(); // Create a QImage directly on the screen's framebuffer. // This is the blit target for copying windows to the screen. - mPrimaryScreen = new QLinuxFbGraphicsSystemScreen(data, w, h, lstep, + mPrimaryScreen = new QLinuxFbScreen(data, w, h, lstep, screenFormat); mPrimaryScreen->setPhysicalSize(QSize(physWidth, physHeight)); mScreens.append(mPrimaryScreen); } -QLinuxFbGraphicsSystem::~QLinuxFbGraphicsSystem() +QLinuxFbIntegration::~QLinuxFbIntegration() { delete mPrimaryScreen; delete d_ptr; } -bool QLinuxFbGraphicsSystem::connect(const QString &displaySpec) +bool QLinuxFbIntegration::connect(const QString &displaySpec) { const QStringList args = displaySpec.split(QLatin1Char(':')); @@ -237,7 +237,7 @@ bool QLinuxFbGraphicsSystem::connect(const QString &displaySpec) /* Get fixed screen information */ if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) { - perror("QLinuxFbGraphicsSystem::connect"); + perror("QLinuxFbIntegration::connect"); qWarning("Error reading fixed information"); return false; } @@ -249,7 +249,7 @@ bool QLinuxFbGraphicsSystem::connect(const QString &displaySpec) /* Get variable screen information */ if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) { - perror("QLinuxFbGraphicsSystem::connect"); + perror("QLinuxFbIntegration::connect"); qWarning("Error reading variable information"); return false; } @@ -295,7 +295,7 @@ bool QLinuxFbGraphicsSystem::connect(const QString &displaySpec) } if (w == 0 || h == 0) { - qWarning("QLinuxFbGraphicsSystem::connect(): Unable to find screen geometry, " + qWarning("QLinuxFbIntegration::connect(): Unable to find screen geometry, " "will use 320x240."); dw = w = 320; dh = h = 240; @@ -347,7 +347,7 @@ bool QLinuxFbGraphicsSystem::connect(const QString &displaySpec) MAP_SHARED, d_ptr->fd, 0); if ((long)data == -1) { - perror("QLinuxFbGraphicsSystem::connect"); + perror("QLinuxFbIntegration::connect"); qWarning("Error: failed to map framebuffer device to memory."); return false; } else { @@ -377,7 +377,7 @@ bool QLinuxFbGraphicsSystem::connect(const QString &displaySpec) startcmap.transp=(unsigned short int *) malloc(sizeof(unsigned short int)*screencols); if (d_ptr->fd == -1 || ioctl(d_ptr->fd, FBIOGETCMAP, &startcmap)) { - perror("QLinuxFbGraphicsSystem::connect"); + perror("QLinuxFbIntegration::connect"); qWarning("Error reading palette from framebuffer, using default palette"); createPalette(startcmap, vinfo, finfo); } @@ -411,7 +411,7 @@ bool QLinuxFbGraphicsSystem::connect(const QString &displaySpec) return true; } -bool QLinuxFbGraphicsSystem::initDevice() +bool QLinuxFbIntegration::initDevice() { d_ptr->openTty(); @@ -538,7 +538,7 @@ bool QLinuxFbGraphicsSystem::initDevice() return true; } -void QLinuxFbGraphicsSystem::setPixelFormat(struct fb_var_screeninfo info) +void QLinuxFbIntegration::setPixelFormat(struct fb_var_screeninfo info) { const fb_bitfield rgba[4] = { info.red, info.green, info.blue, info.transp }; @@ -626,7 +626,7 @@ void QLinuxFbGraphicsSystem::setPixelFormat(struct fb_var_screeninfo info) screenFormat = format; } -void QLinuxFbGraphicsSystem::createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo) +void QLinuxFbIntegration::createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo) { if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; @@ -756,7 +756,7 @@ void QLinuxFbGraphicsSystem::createPalette(fb_cmap &cmap, fb_var_screeninfo &vin } } -void QLinuxFbGraphicsSystem::blank(bool on) +void QLinuxFbIntegration::blank(bool on) { if (d_ptr->blank == on) return; @@ -781,23 +781,23 @@ void QLinuxFbGraphicsSystem::blank(bool on) d_ptr->blank = on; } -QPixmapData *QLinuxFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +QPixmapData *QLinuxFbIntegration::createPixmapData(QPixmapData::PixelType type) const { return new QRasterPixmapData(type); } -QWindowSurface *QLinuxFbGraphicsSystem::createWindowSurfaceForWindow(QWidget *widget, WId) const +QWindowSurface *QLinuxFbIntegration::createWindowSurfaceForWindow(QWidget *widget, WId) const { if (widget->windowType() == Qt::Desktop) return 0; // Don't create an explicit window surface for the destkop. - QGraphicsSystemFbWindowSurface * surface = - new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); + QFbWindowSurface * surface = + new QFbWindowSurface(mPrimaryScreen, widget); return surface; } -QPlatformWindow *QLinuxFbGraphicsSystem::createPlatformWindow(QWidget *widget, WId /*winId*/) const +QPlatformWindow *QLinuxFbIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const { QFbWindow *w = new QFbWindow(mPrimaryScreen, widget); mPrimaryScreen->addWindow(w); @@ -808,7 +808,7 @@ QPlatformWindow *QLinuxFbGraphicsSystem::createPlatformWindow(QWidget *widget, W -QLinuxFbGraphicsSystemScreen::QLinuxFbGraphicsSystemScreen(uchar * d, int w, +QLinuxFbScreen::QLinuxFbScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat) : compositePainter(0) { data = d; @@ -823,7 +823,7 @@ QLinuxFbGraphicsSystemScreen::QLinuxFbGraphicsSystemScreen(uchar * d, int w, cursor = new QGraphicsSystemSoftwareCursor(this); } -void QLinuxFbGraphicsSystemScreen::setGeometry(QRect rect) +void QLinuxFbScreen::setGeometry(QRect rect) { mGeometry = rect; delete mFbScreenImage; @@ -837,7 +837,7 @@ void QLinuxFbGraphicsSystemScreen::setGeometry(QRect rect) mFormat); } -void QLinuxFbGraphicsSystemScreen::setFormat(QImage::Format format) +void QLinuxFbScreen::setFormat(QImage::Format format) { mFormat = format; delete mFbScreenImage; @@ -851,10 +851,10 @@ void QLinuxFbGraphicsSystemScreen::setFormat(QImage::Format format) mFormat); } -QRegion QLinuxFbGraphicsSystemScreen::doRedraw() +QRegion QLinuxFbScreen::doRedraw() { QRegion touched; - touched = QGraphicsSystemFbScreen::doRedraw(); + touched = QFbScreen::doRedraw(); if (!compositePainter) { compositePainter = new QPainter(mFbScreenImage); diff --git a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h index 873b463..7d4c031 100644 --- a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h +++ b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h @@ -47,10 +47,10 @@ QT_BEGIN_NAMESPACE -class QLinuxFbGraphicsSystemScreen : public QGraphicsSystemFbScreen +class QLinuxFbScreen : public QFbScreen { public: - QLinuxFbGraphicsSystemScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat); + QLinuxFbScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat); void setGeometry(QRect rect); void setFormat(QImage::Format format); @@ -65,16 +65,16 @@ private: QPainter *compositePainter; }; -class QLinuxFbGraphicsSystemPrivate; +class QLinuxFbIntegrationPrivate; struct fb_cmap; struct fb_var_screeninfo; struct fb_fix_screeninfo; -class QLinuxFbGraphicsSystem : public QPlatformIntegration +class QLinuxFbIntegration : public QPlatformIntegration { public: - QLinuxFbGraphicsSystem(); - ~QLinuxFbGraphicsSystem(); + QLinuxFbIntegration(); + ~QLinuxFbIntegration(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId WinId) const; @@ -83,9 +83,9 @@ public: QList screens() const { return mScreens; } private: - QLinuxFbGraphicsSystemScreen *mPrimaryScreen; + QLinuxFbScreen *mPrimaryScreen; QList mScreens; - QLinuxFbGraphicsSystemPrivate *d_ptr; + QLinuxFbIntegrationPrivate *d_ptr; enum PixelType { NormalPixel, BGRPixel }; diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp index 9de33eb..23d78c1 100644 --- a/src/plugins/platforms/vnc/main.cpp +++ b/src/plugins/platforms/vnc/main.cpp @@ -45,28 +45,28 @@ QT_BEGIN_NAMESPACE -class QVNCGraphicsSystemPlugin : public QPlatformIntegrationPlugin +class QVNCIntegrationPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; QPlatformIntegration *create(const QString&); }; -QStringList QVNCGraphicsSystemPlugin::keys() const +QStringList QVNCIntegrationPlugin::keys() const { QStringList list; list << "VNC"; return list; } -QPlatformIntegration* QVNCGraphicsSystemPlugin::create(const QString& system) +QPlatformIntegration* QVNCIntegrationPlugin::create(const QString& system) { if (system.toLower() == "vnc") - return new QVNCGraphicsSystem; + return new QVNCIntegration; return 0; } -Q_EXPORT_PLUGIN2(vnc, QVNCGraphicsSystemPlugin) +Q_EXPORT_PLUGIN2(vnc, QVNCIntegrationPlugin) QT_END_NAMESPACE diff --git a/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp b/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp index ef50230..cbc8bbd 100644 --- a/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp +++ b/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp @@ -51,8 +51,8 @@ #include -QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() - : QGraphicsSystemFbScreen::QGraphicsSystemFbScreen() +QVNCScreen::QVNCScreen() + : QFbScreen::QFbScreen() { int w = 800; int h = 600; @@ -69,21 +69,21 @@ QVNCGraphicsSystemScreen::QVNCGraphicsSystemScreen() setPhysicalSize((geometry().size()*254)/720); - d_ptr = new QVNCGraphicsSystemScreenPrivate(this); + d_ptr = new QVNCScreenPrivate(this); cursor = new QVNCCursor(d_ptr->vncServer, this); d_ptr->vncServer->setCursor(static_cast(cursor)); } -QVNCDirtyMap *QVNCGraphicsSystemScreen::dirtyMap() +QVNCDirtyMap *QVNCScreen::dirtyMap() { return d_ptr->dirty; } -QRegion QVNCGraphicsSystemScreen::doRedraw() +QRegion QVNCScreen::doRedraw() { QRegion touched; - touched = QGraphicsSystemFbScreen::doRedraw(); + touched = QFbScreen::doRedraw(); QVector rects = touched.rects(); for (int i = 0; i < rects.size(); i++) @@ -92,39 +92,39 @@ QRegion QVNCGraphicsSystemScreen::doRedraw() } -QVNCGraphicsSystem::QVNCGraphicsSystem() +QVNCIntegration::QVNCIntegration() { - mPrimaryScreen = new QVNCGraphicsSystemScreen(); + mPrimaryScreen = new QVNCScreen(); mScreens.append(mPrimaryScreen); } -QPixmapData *QVNCGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +QPixmapData *QVNCIntegration::createPixmapData(QPixmapData::PixelType type) const { return new QRasterPixmapData(type); } -// QWindowSurface *QVNCGraphicsSystem::createWindowSurface(QWidget *widget) const +// QWindowSurface *QVNCIntegration::createWindowSurface(QWidget *widget) const // { // if (widget->windowType() == Qt::Desktop) // return 0; // Don't create an explicit window surface for the destkop. -// QGraphicsSystemFbWindowSurface * surface; -// surface = new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); +// QFbWindowSurface * surface; +// surface = new QFbWindowSurface(mPrimaryScreen, widget); // mPrimaryScreen->addWindowSurface(surface); // return surface; // } -QWindowSurface *QVNCGraphicsSystem::createWindowSurfaceForWindow(QWidget *widget, WId) const +QWindowSurface *QVNCIntegration::createWindowSurfaceForWindow(QWidget *widget, WId) const { if (widget->windowType() == Qt::Desktop) return 0; // Don't create an explicit window surface for the destkop. - QGraphicsSystemFbWindowSurface * surface; - surface = new QGraphicsSystemFbWindowSurface(mPrimaryScreen, widget); + QFbWindowSurface * surface; + surface = new QFbWindowSurface(mPrimaryScreen, widget); return surface; } -QPlatformWindow *QVNCGraphicsSystem::createPlatformWindow(QWidget *widget, WId /*winId*/) const +QPlatformWindow *QVNCIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const { QFbWindow *w = new QFbWindow(mPrimaryScreen, widget); mPrimaryScreen->addWindow(w); diff --git a/src/plugins/platforms/vnc/qgraphicssystem_vnc.h b/src/plugins/platforms/vnc/qgraphicssystem_vnc.h index 3205872..887ccc3 100644 --- a/src/plugins/platforms/vnc/qgraphicssystem_vnc.h +++ b/src/plugins/platforms/vnc/qgraphicssystem_vnc.h @@ -51,32 +51,32 @@ QT_BEGIN_NAMESPACE class QVNCServer; class QVNCDirtyMap; -class QVNCGraphicsSystemScreenPrivate; +class QVNCScreenPrivate; -class QVNCGraphicsSystemScreen : public QGraphicsSystemFbScreen +class QVNCScreen : public QFbScreen { public: - QVNCGraphicsSystemScreen(); + QVNCScreen(); int linestep() const { return image() ? image()->bytesPerLine() : 0; } uchar *base() const { return image() ? image()->bits() : 0; } QVNCDirtyMap *dirtyMap(); public: - QVNCGraphicsSystemScreenPrivate *d_ptr; + QVNCScreenPrivate *d_ptr; private: QVNCServer *server; QRegion doRedraw(); }; -class QVNCGraphicsSystemPrivate; +class QVNCIntegrationPrivate; -class QVNCGraphicsSystem : public QPlatformIntegration +class QVNCIntegration : public QPlatformIntegration { public: - QVNCGraphicsSystem(); + QVNCIntegration(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; @@ -86,7 +86,7 @@ public: private: - QVNCGraphicsSystemScreen *mPrimaryScreen; + QVNCScreen *mPrimaryScreen; QList mScreens; }; diff --git a/src/plugins/platforms/vnc/qvnccursor.cpp b/src/plugins/platforms/vnc/qvnccursor.cpp index fb214d8..78da53b 100644 --- a/src/plugins/platforms/vnc/qvnccursor.cpp +++ b/src/plugins/platforms/vnc/qvnccursor.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE -QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCGraphicsSystemScreen *scr ) +QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCScreen *scr ) :QGraphicsSystemSoftwareCursor(scr), useVncCursor(false), server(srvr) { } diff --git a/src/plugins/platforms/vnc/qvnccursor.h b/src/plugins/platforms/vnc/qvnccursor.h index 8ea0f45..2c6ff5b 100644 --- a/src/plugins/platforms/vnc/qvnccursor.h +++ b/src/plugins/platforms/vnc/qvnccursor.h @@ -48,12 +48,12 @@ QT_BEGIN_NAMESPACE -class QVNCGraphicsSystemScreen; +class QVNCScreen; class QVNCServer; class QVNCCursor : public QGraphicsSystemSoftwareCursor { public: - QVNCCursor(QVNCServer *, QVNCGraphicsSystemScreen *); + QVNCCursor(QVNCServer *, QVNCScreen *); // input methods void setCursorMode(bool vnc); diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp index ea576d4..ab0a2f3 100644 --- a/src/plugins/platforms/vnc/qvncserver.cpp +++ b/src/plugins/platforms/vnc/qvncserver.cpp @@ -358,13 +358,13 @@ bool QRfbClientCutText::read(QTcpSocket *s) //=========================================================================== -QVNCServer::QVNCServer(QVNCGraphicsSystemScreen *screen) +QVNCServer::QVNCServer(QVNCScreen *screen) : qvnc_screen(screen), cursor(0) { init(5900); } -QVNCServer::QVNCServer(QVNCGraphicsSystemScreen *screen, int id) +QVNCServer::QVNCServer(QVNCScreen *screen, int id) : qvnc_screen(screen), cursor(0) { init(5900 + id); @@ -620,7 +620,7 @@ void QVNCServer::readClient() } #if 0//Q_BYTE_ORDER == Q_BIG_ENDIAN -bool QVNCGraphicsSystemScreen::swapBytes() const +bool QVNCScreen::swapBytes() const { if (depth() != 16) return false; @@ -1499,7 +1499,7 @@ static void blendCursor(QImage &image, const QRect &imageRect) } #endif // QT_NO_QWS_CURSOR -QVNCDirtyMap::QVNCDirtyMap(QVNCGraphicsSystemScreen *s) +QVNCDirtyMap::QVNCDirtyMap(QVNCScreen *s) : bytesPerPixel(0), numDirty(0), screen(s) { bytesPerPixel = (screen->depth() + 7) / 8; @@ -1885,7 +1885,7 @@ void QVNCServer::discardClient() -QVNCGraphicsSystemScreenPrivate::QVNCGraphicsSystemScreenPrivate(QVNCGraphicsSystemScreen *parent) +QVNCScreenPrivate::QVNCScreenPrivate(QVNCScreen *parent) : dpiX(72), dpiY(72), doOnScreenSurface(false), refreshRate(25), vncServer(0), q_ptr(parent) { @@ -1902,12 +1902,12 @@ QVNCGraphicsSystemScreenPrivate::QVNCGraphicsSystemScreenPrivate(QVNCGraphicsSys dirty = new QVNCDirtyMapOptimized(q_ptr); } -QVNCGraphicsSystemScreenPrivate::~QVNCGraphicsSystemScreenPrivate() +QVNCScreenPrivate::~QVNCScreenPrivate() { } -void QVNCGraphicsSystemScreenPrivate::setDirty(const QRect& rect, bool force) +void QVNCScreenPrivate::setDirty(const QRect& rect, bool force) { if (rect.isEmpty()) return; @@ -1916,7 +1916,7 @@ void QVNCGraphicsSystemScreenPrivate::setDirty(const QRect& rect, bool force) // q_ptr->screen()->setDirty(rect); if (!vncServer || !vncServer->isConnected()) { -// qDebug() << "QVNCGraphicsSystemScreenPrivate::setDirty() - Not connected"; +// qDebug() << "QVNCScreenPrivate::setDirty() - Not connected"; return; } const QRect r = rect; // .translated(-q_ptr->offset()); diff --git a/src/plugins/platforms/vnc/qvncserver.h b/src/plugins/platforms/vnc/qvncserver.h index 4fcdbae..41cadab 100644 --- a/src/plugins/platforms/vnc/qvncserver.h +++ b/src/plugins/platforms/vnc/qvncserver.h @@ -72,7 +72,7 @@ class QVNCServer; class QVNCCursor : public QProxyScreenCursor { public: - QVNCCursor(QVNCGraphicsSystemScreen *s); + QVNCCursor(QVNCScreen *s); ~QVNCCursor(); void hide(); @@ -82,7 +82,7 @@ public: private: void setDirty(const QRect &r) const; - QVNCGraphicsSystemScreen *screen; + QVNCScreen *screen; }; class QVNCClientCursor : public QProxyScreenCursor @@ -106,7 +106,7 @@ private: class QVNCDirtyMap { public: - QVNCDirtyMap(QVNCGraphicsSystemScreen *screen); + QVNCDirtyMap(QVNCScreen *screen); virtual ~QVNCDirtyMap(); void reset(); @@ -122,7 +122,7 @@ public: protected: uchar *map; - QVNCGraphicsSystemScreen *screen; + QVNCScreen *screen; uchar *buffer; int bufferWidth; int bufferHeight; @@ -134,7 +134,7 @@ template class QVNCDirtyMapOptimized : public QVNCDirtyMap { public: - QVNCDirtyMapOptimized(QVNCGraphicsSystemScreen *screen) : QVNCDirtyMap(screen) {} + QVNCDirtyMapOptimized(QVNCScreen *screen) : QVNCDirtyMap(screen) {} ~QVNCDirtyMapOptimized() {} void setDirty(int x, int y, bool force = false); @@ -246,11 +246,11 @@ public: quint32 length; }; -class QVNCGraphicsSystemScreenPrivate : public QObject +class QVNCScreenPrivate : public QObject { public: - QVNCGraphicsSystemScreenPrivate(QVNCGraphicsSystemScreen *parent); - ~QVNCGraphicsSystemScreenPrivate(); + QVNCScreenPrivate(QVNCScreen *parent); + ~QVNCScreenPrivate(); void setDirty(const QRect &rect, bool force = false); void configure(); @@ -266,7 +266,7 @@ public: QSharedMemory shm; #endif - QVNCGraphicsSystemScreen *q_ptr; + QVNCScreen *q_ptr; }; class QRfbEncoder @@ -438,8 +438,8 @@ class QVNCServer : public QObject { Q_OBJECT public: - QVNCServer(QVNCGraphicsSystemScreen *screen); - QVNCServer(QVNCGraphicsSystemScreen *screen, int id); + QVNCServer(QVNCScreen *screen); + QVNCServer(QVNCScreen *screen, int id); ~QVNCServer(); void setDirty(); @@ -464,7 +464,7 @@ public: return pixelFormat.bitsPerPixel / 8; } - inline QVNCGraphicsSystemScreen* screen() const { return qvnc_screen; } + inline QVNCScreen* screen() const { return qvnc_screen; } inline QVNCDirtyMap* dirtyMap() const { return qvnc_screen->dirtyMap(); } inline QTcpSocket* clientSocket() const { return client; } QImage *screenImage() const; @@ -519,7 +519,7 @@ private: #endif bool dirtyCursor; int refreshRate; - QVNCGraphicsSystemScreen *qvnc_screen; + QVNCScreen *qvnc_screen; #ifndef QT_NO_QWS_CURSOR QVNCClientCursor *qvnc_cursor; #endif -- cgit v0.12 From e8af272c0c95ab531a060d3e8e8e75b7b03619f4 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 13 Apr 2010 11:38:49 +0200 Subject: Port the QVFb backend to the new API --- src/plugins/platforms/qvfb/main.cpp | 16 +- .../platforms/qvfb/qgraphicssystem_qvfb.cpp | 434 -------------------- src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h | 95 ----- src/plugins/platforms/qvfb/qvfb.pro | 11 +- src/plugins/platforms/qvfb/qvfbintegration.cpp | 439 +++++++++++++++++++++ src/plugins/platforms/qvfb/qvfbintegration.h | 97 +++++ src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp | 38 +- src/plugins/platforms/qvfb/qwindowsurface_qvfb.h | 26 +- 8 files changed, 586 insertions(+), 570 deletions(-) delete mode 100644 src/plugins/platforms/qvfb/qgraphicssystem_qvfb.cpp delete mode 100644 src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h create mode 100644 src/plugins/platforms/qvfb/qvfbintegration.cpp create mode 100644 src/plugins/platforms/qvfb/qvfbintegration.h diff --git a/src/plugins/platforms/qvfb/main.cpp b/src/plugins/platforms/qvfb/main.cpp index b28dde8..409f11c 100644 --- a/src/plugins/platforms/qvfb/main.cpp +++ b/src/plugins/platforms/qvfb/main.cpp @@ -39,34 +39,34 @@ ** ****************************************************************************/ -#include -#include "qgraphicssystem_qvfb.h" +#include +#include "qvfbintegration.h" #include QT_BEGIN_NAMESPACE -class QVFbGraphicsSystemPlugin : public QGraphicsSystemPlugin +class QVFbIntegrationPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QGraphicsSystem *create(const QString&); + QPlatformIntegration *create(const QString&); }; -QStringList QVFbGraphicsSystemPlugin::keys() const +QStringList QVFbIntegrationPlugin::keys() const { QStringList list; list << "QVFb"; return list; } -QGraphicsSystem* QVFbGraphicsSystemPlugin::create(const QString& system) +QPlatformIntegration* QVFbIntegrationPlugin::create(const QString& system) { if (system.toLower() == "qvfb") - return new QVFbGraphicsSystem; + return new QVFbIntegration; return 0; } -Q_EXPORT_PLUGIN2(qvfb, QVFbGraphicsSystemPlugin) +Q_EXPORT_PLUGIN2(qvfb, QVFbIntegrationPlugin) QT_END_NAMESPACE diff --git a/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.cpp b/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.cpp deleted file mode 100644 index 19058a6..0000000 --- a/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.cpp +++ /dev/null @@ -1,434 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include // overrides QT_OPEN - -#include -#include - -#include "qgraphicssystem_qvfb.h" -#include "qwindowsurface_qvfb.h" -#include -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - - -class QVFbGraphicsSystemScreenKeyboardHandler : public QObject -{ - Q_OBJECT -public: - QVFbGraphicsSystemScreenKeyboardHandler(); - ~QVFbGraphicsSystemScreenKeyboardHandler(); - -private slots: - void readKeyboardData(); - -private: - int kbdFD; - int kbdIdx; - int kbdBufferLen; - unsigned char *kbdBuffer; - QSocketNotifier *keyNotifier; -}; - -QVFbGraphicsSystemScreenKeyboardHandler::QVFbGraphicsSystemScreenKeyboardHandler() -{ - int displayId = 0; //TODO displayId - const QString keyboardDev = QT_VFB_KEYBOARD_PIPE(displayId); - - - kbdFD = -1; - kbdIdx = 0; - kbdBufferLen = sizeof(QVFbKeyData) * 5; - kbdBuffer = new unsigned char [kbdBufferLen]; - - kbdFD = QT_OPEN(keyboardDev.toLatin1().constData(), O_RDWR | O_NDELAY); - - if (kbdFD == -1) { - perror("QVFbGraphicsSystemScreenKeyboardHandler"); - qWarning("QVFbGraphicsSystemScreenKeyboardHandler: Unable to open device %s", - qPrintable(keyboardDev)); - return; - } - - // Clear pending input - char buf[2]; - while (QT_READ(kbdFD, buf, 1) > 0) { } - - keyNotifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this); - connect(keyNotifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData())); - -} - -QVFbGraphicsSystemScreenKeyboardHandler::~QVFbGraphicsSystemScreenKeyboardHandler() -{ - if (kbdFD >= 0) - QT_CLOSE(kbdFD); - delete [] kbdBuffer; -} - - -void QVFbGraphicsSystemScreenKeyboardHandler::readKeyboardData() -{ - int n; - do { - n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx); - if (n > 0) - kbdIdx += n; - } while (n > 0); - - int idx = 0; - while (kbdIdx - idx >= (int)sizeof(QVFbKeyData)) { - QVFbKeyData *kd = (QVFbKeyData *)(kbdBuffer + idx); - if (kd->unicode == 0 && kd->keycode == 0 && kd->modifiers == 0 && kd->press) { - // magic exit key - qWarning("Instructed to quit by Virtual Keyboard"); - qApp->quit(); - } - - //QWSServer::processKeyEvent(kd->unicode ? kd->unicode : 0xffff, kd->keycode, kd->modifiers, kd->press, kd->repeat); - - QEvent::Type type = kd->press ? QEvent::KeyPress : QEvent::KeyRelease; - - QString text; - if (kd->unicode && kd->unicode != 0xffff) - text += QChar(kd->unicode); - -// qDebug() << "readKeyboardData" << type << hex << kd->keycode << kd->modifiers << text; - - QWindowSystemInterface::handleKeyEvent(0, type, kd->keycode, kd->modifiers, text, kd->repeat, int(text.length())); - idx += sizeof(QVFbKeyData); - } - - int surplus = kbdIdx - idx; - for (int i = 0; i < surplus; i++) - kbdBuffer[i] = kbdBuffer[idx+i]; - kbdIdx = surplus; -} - - - - -class QVFbGraphicsSystemScreenMouseHandler : public QObject -{ - Q_OBJECT -public: - QVFbGraphicsSystemScreenMouseHandler(); - ~QVFbGraphicsSystemScreenMouseHandler(); - -private slots: - void readMouseData(); - -private: - int mouseFD; - int mouseIdx; - enum {mouseBufSize = 128}; - uchar mouseBuf[mouseBufSize]; - QSocketNotifier *mouseNotifier; - - int oldButtonState; -}; - -QVFbGraphicsSystemScreenMouseHandler::QVFbGraphicsSystemScreenMouseHandler() -{ - int displayId = 0; //TODO: displayId - QString mouseDev = QT_VFB_MOUSE_PIPE(displayId); - - mouseFD = QT_OPEN(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY); - - if (mouseFD == -1) { - perror("QVFbMouseHandler::QVFbMouseHandler"); - qWarning("QVFbMouseHander: Unable to open device %s", - qPrintable(mouseDev)); - return; - } - - // Clear pending input - char buf[2]; - while (QT_READ(mouseFD, buf, 1) > 0) { } - - mouseIdx = 0; - oldButtonState = 0; - mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this); - connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData())); -} - - -QVFbGraphicsSystemScreenMouseHandler::~QVFbGraphicsSystemScreenMouseHandler() -{ - if (mouseFD >= 0) - QT_CLOSE(mouseFD); -} - -void QVFbGraphicsSystemScreenMouseHandler::readMouseData() -{ - int n; - do { - n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx); - if (n > 0) - mouseIdx += n; - } while (n > 0); - - int idx = 0; - static const int packetsize = sizeof(QPoint) + 2*sizeof(int); - while (mouseIdx-idx >= packetsize) { - uchar *mb = mouseBuf+idx; - QPoint mousePos = *reinterpret_cast(mb); - mb += sizeof(QPoint); - int bstate = *reinterpret_cast(mb); - mb += sizeof(int); - int wheel = *reinterpret_cast(mb); - - int button = bstate ^ oldButtonState; - QEvent::Type type = QEvent::MouseMove; - - if (button) { - type = (button & bstate) ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - } - QWindowSystemInterface::handleMouseEvent(0, mousePos, mousePos, Qt::MouseButtons(bstate)); - -// qDebug() << "readMouseData" << mousePos << button << bstate << oldButtonState << type; - - oldButtonState = bstate; - - idx += packetsize; - } - - int surplus = mouseIdx - idx; - for (int i = 0; i < surplus; i++) - mouseBuf[i] = mouseBuf[idx+i]; - mouseIdx = surplus; - -} - - -class QVFbGraphicsSystemScreenPrivate -{ -public: - QVFbGraphicsSystemScreenPrivate(QVFbGraphicsSystemScreen *) - : shmrgn(0), hdr(0), data(0), mouseHandler(0), keyboardHandler(0) - { - connect(0); //for now we only handle one screen - } - - ~QVFbGraphicsSystemScreenPrivate() { disconnect(); } - void setDirty(const QRect &r); - - bool connect(int displayId); - void disconnect(); - - QImage *screenImage() { return &img; } - QSize screenSize() { return img.size(); } - - int depth() const { return img.depth(); } - QImage::Format format() const { return img.format(); } - -private: - unsigned char *shmrgn; - QVFbHeader *hdr; - uchar *data; - QVFbGraphicsSystemScreenMouseHandler *mouseHandler; - QVFbGraphicsSystemScreenKeyboardHandler *keyboardHandler; - - - QImage img; -}; - - -void QVFbGraphicsSystemScreenPrivate::setDirty(const QRect &r) -{ - hdr->dirty = true; - hdr->update = hdr->update.united(r); -} - - -bool QVFbGraphicsSystemScreenPrivate::connect(int displayId) -{ - - key_t key = ftok(QT_VFB_MOUSE_PIPE(displayId).toLatin1(), 'b'); - - if (key == -1) - return false; - - - int shmId = shmget(key, 0, 0); - if (shmId != -1) - shmrgn = (unsigned char *)shmat(shmId, 0, 0); - else - return false; - - if ((long)shmrgn == -1 || shmrgn == 0) { - qDebug("No shmrgn %ld", (long)shmrgn); - return false; - } - - hdr = (QVFbHeader *)shmrgn; - data = shmrgn + hdr->dataoffset; - - int w = hdr->width; - int h = hdr->height; - int d = hdr->depth; - int lstep = hdr->linestep; - - QImage::Format format = QImage::Format_Invalid; - if (d == 32) - format = QImage::Format_ARGB32_Premultiplied; - else if (d == 16) - format = QImage::Format_RGB16; - - - if (format == QImage::Format_Invalid) { - img = QImage(); - return false; - } - - img = QImage(data, w, h, lstep, format); - - qDebug("connected %dx%d %d bpp", w, h, d); - - - mouseHandler = new QVFbGraphicsSystemScreenMouseHandler; - keyboardHandler = new QVFbGraphicsSystemScreenKeyboardHandler; - return true; -} - -void QVFbGraphicsSystemScreenPrivate::disconnect() -{ - if ((long)shmrgn != -1 && shmrgn) { - shmdt((char*)shmrgn); - shmrgn = 0; - } - delete mouseHandler; - mouseHandler = 0; - delete keyboardHandler; - keyboardHandler = 0; -} - - -QVFbGraphicsSystemScreen::QVFbGraphicsSystemScreen() -{ - d_ptr = new QVFbGraphicsSystemScreenPrivate(this); -} - - -QVFbGraphicsSystemScreen::~QVFbGraphicsSystemScreen() -{ - delete d_ptr; -} - -void QVFbGraphicsSystemScreen::setDirty(const QRect &rect) -{ - d_ptr->setDirty(rect); -} - - - -QRect QVFbGraphicsSystemScreen::geometry() const { - return QRect(QPoint(), d_ptr->screenSize()); -} - - -int QVFbGraphicsSystemScreen::depth() const -{ - return d_ptr->depth(); -} - -QImage::Format QVFbGraphicsSystemScreen::format() const -{ - return d_ptr->format(); -} - -QSize QVFbGraphicsSystemScreen::physicalSize() const { - return (d_ptr->screenSize()*254)/720; -} - -#if 0 -int QVFbGraphicsSystemScreen::linestep() const { - return d_ptr->screenImage() ? d_ptr->screenImage()->bytesPerLine() : 0; -} - -uchar *QVFbGraphicsSystemScreen::base() const { - return d_ptr->screenImage() ? d_ptr->screenImage()->bits() : 0; -} -#endif - -QImage *QVFbGraphicsSystemScreen::screenImage() -{ - return d_ptr->screenImage(); -} - -QVFbGraphicsSystem::QVFbGraphicsSystem() -{ - mPrimaryScreen = new QVFbGraphicsSystemScreen(); - - mScreens.append(mPrimaryScreen); -} - -QPixmapData *QVFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -QWindowSurface *QVFbGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - if (widget->windowType() == Qt::Desktop) - return 0; // Don't create an explicit window surface for the destkop. - return new QVFbWindowSurface - (const_cast(this), mPrimaryScreen, widget); -} - -QT_END_NAMESPACE - -#include "qgraphicssystem_qvfb.moc" diff --git a/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h b/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h deleted file mode 100644 index b31869c..0000000 --- a/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_QVFB_H -#define QGRAPHICSSYSTEM_QVFB_H - -#include - -QT_BEGIN_NAMESPACE - - -class QVFbGraphicsSystemScreenPrivate; - -class QVFbGraphicsSystemScreen : public QGraphicsSystemScreen -{ -public: - QVFbGraphicsSystemScreen(); - ~QVFbGraphicsSystemScreen(); - - QRect geometry() const; - int depth() const; - QImage::Format format() const; - QSize physicalSize() const; - - QImage *screenImage(); - - void setDirty(const QRect &rect); - -public: - - QVFbGraphicsSystemScreenPrivate *d_ptr; -}; - -class QVFbGraphicsSystemPrivate; - - -class QVFbGraphicsSystem : public QGraphicsSystem -{ -public: - QVFbGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - - QList screens() const { return mScreens; } - -private: - QVFbGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; -}; - - - -QT_END_NAMESPACE - - -#endif diff --git a/src/plugins/platforms/qvfb/qvfb.pro b/src/plugins/platforms/qvfb/qvfb.pro index b321725..4dec274 100644 --- a/src/plugins/platforms/qvfb/qvfb.pro +++ b/src/plugins/platforms/qvfb/qvfb.pro @@ -1,12 +1,11 @@ -TARGET = qvfbgraphicssystem +TARGET = qvfbintegration include(../../qpluginbase.pri) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms +SOURCES = main.cpp qvfbintegration.cpp qwindowsurface_qvfb.cpp +HEADERS = qvfbintegration.h qwindowsurface_qvfb.h -SOURCES = main.cpp qgraphicssystem_qvfb.cpp qwindowsurface_qvfb.cpp -HEADERS = qgraphicssystem_qvfb.h qwindowsurface_qvfb.h - -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/qvfb/qvfbintegration.cpp b/src/plugins/platforms/qvfb/qvfbintegration.cpp new file mode 100644 index 0000000..2a877e0 --- /dev/null +++ b/src/plugins/platforms/qvfb/qvfbintegration.cpp @@ -0,0 +1,439 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include // overrides QT_OPEN + +#include +#include + +#include "qvfbintegration.h" +#include "qwindowsurface_qvfb.h" +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + + +class QVFbScreenKeyboardHandler : public QObject +{ + Q_OBJECT +public: + QVFbScreenKeyboardHandler(); + ~QVFbScreenKeyboardHandler(); + +private slots: + void readKeyboardData(); + +private: + int kbdFD; + int kbdIdx; + int kbdBufferLen; + unsigned char *kbdBuffer; + QSocketNotifier *keyNotifier; +}; + +QVFbScreenKeyboardHandler::QVFbScreenKeyboardHandler() +{ + int displayId = 0; //TODO displayId + const QString keyboardDev = QT_VFB_KEYBOARD_PIPE(displayId); + + + kbdFD = -1; + kbdIdx = 0; + kbdBufferLen = sizeof(QVFbKeyData) * 5; + kbdBuffer = new unsigned char [kbdBufferLen]; + + kbdFD = QT_OPEN(keyboardDev.toLatin1().constData(), O_RDWR | O_NDELAY); + + if (kbdFD == -1) { + perror("QVFbScreenKeyboardHandler"); + qWarning("QVFbScreenKeyboardHandler: Unable to open device %s", + qPrintable(keyboardDev)); + return; + } + + // Clear pending input + char buf[2]; + while (QT_READ(kbdFD, buf, 1) > 0) { } + + keyNotifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this); + connect(keyNotifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData())); + +} + +QVFbScreenKeyboardHandler::~QVFbScreenKeyboardHandler() +{ + if (kbdFD >= 0) + QT_CLOSE(kbdFD); + delete [] kbdBuffer; +} + + +void QVFbScreenKeyboardHandler::readKeyboardData() +{ + int n; + do { + n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx); + if (n > 0) + kbdIdx += n; + } while (n > 0); + + int idx = 0; + while (kbdIdx - idx >= (int)sizeof(QVFbKeyData)) { + QVFbKeyData *kd = (QVFbKeyData *)(kbdBuffer + idx); + if (kd->unicode == 0 && kd->keycode == 0 && kd->modifiers == 0 && kd->press) { + // magic exit key + qWarning("Instructed to quit by Virtual Keyboard"); + qApp->quit(); + } + + //QWSServer::processKeyEvent(kd->unicode ? kd->unicode : 0xffff, kd->keycode, kd->modifiers, kd->press, kd->repeat); + + QEvent::Type type = kd->press ? QEvent::KeyPress : QEvent::KeyRelease; + + QString text; + if (kd->unicode && kd->unicode != 0xffff) + text += QChar(kd->unicode); + +// qDebug() << "readKeyboardData" << type << hex << kd->keycode << kd->modifiers << text; + + QWindowSystemInterface::handleKeyEvent(0, type, kd->keycode, kd->modifiers, text, kd->repeat, int(text.length())); + idx += sizeof(QVFbKeyData); + } + + int surplus = kbdIdx - idx; + for (int i = 0; i < surplus; i++) + kbdBuffer[i] = kbdBuffer[idx+i]; + kbdIdx = surplus; +} + + + + +class QVFbScreenMouseHandler : public QObject +{ + Q_OBJECT +public: + QVFbScreenMouseHandler(); + ~QVFbScreenMouseHandler(); + +private slots: + void readMouseData(); + +private: + int mouseFD; + int mouseIdx; + enum {mouseBufSize = 128}; + uchar mouseBuf[mouseBufSize]; + QSocketNotifier *mouseNotifier; + + int oldButtonState; +}; + +QVFbScreenMouseHandler::QVFbScreenMouseHandler() +{ + int displayId = 0; //TODO: displayId + QString mouseDev = QT_VFB_MOUSE_PIPE(displayId); + + mouseFD = QT_OPEN(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY); + + if (mouseFD == -1) { + perror("QVFbMouseHandler::QVFbMouseHandler"); + qWarning("QVFbMouseHander: Unable to open device %s", + qPrintable(mouseDev)); + return; + } + + // Clear pending input + char buf[2]; + while (QT_READ(mouseFD, buf, 1) > 0) { } + + mouseIdx = 0; + oldButtonState = 0; + mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this); + connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData())); +} + + +QVFbScreenMouseHandler::~QVFbScreenMouseHandler() +{ + if (mouseFD >= 0) + QT_CLOSE(mouseFD); +} + +void QVFbScreenMouseHandler::readMouseData() +{ + int n; + do { + n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx); + if (n > 0) + mouseIdx += n; + } while (n > 0); + + int idx = 0; + static const int packetsize = sizeof(QPoint) + 2*sizeof(int); + while (mouseIdx-idx >= packetsize) { + uchar *mb = mouseBuf+idx; + QPoint mousePos = *reinterpret_cast(mb); + mb += sizeof(QPoint); + int bstate = *reinterpret_cast(mb); + mb += sizeof(int); + //int wheel = *reinterpret_cast(mb); + + int button = bstate ^ oldButtonState; + QEvent::Type type = QEvent::MouseMove; + + if (button) { + type = (button & bstate) ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; + } + QWindowSystemInterface::handleMouseEvent(0, mousePos, mousePos, Qt::MouseButtons(bstate)); + +// qDebug() << "readMouseData" << mousePos << button << bstate << oldButtonState << type; + + oldButtonState = bstate; + + idx += packetsize; + } + + int surplus = mouseIdx - idx; + for (int i = 0; i < surplus; i++) + mouseBuf[i] = mouseBuf[idx+i]; + mouseIdx = surplus; + +} + + +class QVFbScreenPrivate +{ +public: + QVFbScreenPrivate(QVFbScreen *) + : shmrgn(0), hdr(0), data(0), mouseHandler(0), keyboardHandler(0) + { + connect(0); //for now we only handle one screen + } + + ~QVFbScreenPrivate() { disconnect(); } + void setDirty(const QRect &r); + + bool connect(int displayId); + void disconnect(); + + QImage *screenImage() { return &img; } + QSize screenSize() { return img.size(); } + + int depth() const { return img.depth(); } + QImage::Format format() const { return img.format(); } + +private: + unsigned char *shmrgn; + QVFbHeader *hdr; + uchar *data; + QVFbScreenMouseHandler *mouseHandler; + QVFbScreenKeyboardHandler *keyboardHandler; + + + QImage img; +}; + + +void QVFbScreenPrivate::setDirty(const QRect &r) +{ + hdr->dirty = true; + hdr->update = hdr->update.united(r); +} + + +bool QVFbScreenPrivate::connect(int displayId) +{ + + key_t key = ftok(QT_VFB_MOUSE_PIPE(displayId).toLatin1(), 'b'); + + if (key == -1) + return false; + + + int shmId = shmget(key, 0, 0); + if (shmId != -1) + shmrgn = (unsigned char *)shmat(shmId, 0, 0); + else + return false; + + if ((long)shmrgn == -1 || shmrgn == 0) { + qDebug("No shmrgn %ld", (long)shmrgn); + return false; + } + + hdr = (QVFbHeader *)shmrgn; + data = shmrgn + hdr->dataoffset; + + int w = hdr->width; + int h = hdr->height; + int d = hdr->depth; + int lstep = hdr->linestep; + + QImage::Format format = QImage::Format_Invalid; + if (d == 32) + format = QImage::Format_ARGB32_Premultiplied; + else if (d == 16) + format = QImage::Format_RGB16; + + + if (format == QImage::Format_Invalid) { + img = QImage(); + return false; + } + + img = QImage(data, w, h, lstep, format); + + qDebug("connected %dx%d %d bpp", w, h, d); + + + mouseHandler = new QVFbScreenMouseHandler; + keyboardHandler = new QVFbScreenKeyboardHandler; + return true; +} + +void QVFbScreenPrivate::disconnect() +{ + if ((long)shmrgn != -1 && shmrgn) { + shmdt((char*)shmrgn); + shmrgn = 0; + } + delete mouseHandler; + mouseHandler = 0; + delete keyboardHandler; + keyboardHandler = 0; +} + + +QVFbScreen::QVFbScreen() +{ + d_ptr = new QVFbScreenPrivate(this); +} + + +QVFbScreen::~QVFbScreen() +{ + delete d_ptr; +} + +void QVFbScreen::setDirty(const QRect &rect) +{ + d_ptr->setDirty(rect); +} + + + +QRect QVFbScreen::geometry() const { + return QRect(QPoint(), d_ptr->screenSize()); +} + + +int QVFbScreen::depth() const +{ + return d_ptr->depth(); +} + +QImage::Format QVFbScreen::format() const +{ + return d_ptr->format(); +} + +QSize QVFbScreen::physicalSize() const { + return (d_ptr->screenSize()*254)/720; +} + +#if 0 +int QVFbScreen::linestep() const { + return d_ptr->screenImage() ? d_ptr->screenImage()->bytesPerLine() : 0; +} + +uchar *QVFbScreen::base() const { + return d_ptr->screenImage() ? d_ptr->screenImage()->bits() : 0; +} +#endif + +QImage *QVFbScreen::screenImage() +{ + return d_ptr->screenImage(); +} + +QVFbIntegration::QVFbIntegration() +{ + mPrimaryScreen = new QVFbScreen(); + + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QVFbIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QVFbIntegration::createWindowSurfaceForWindow(QWidget *widget, WId) const +{ + if (widget->windowType() == Qt::Desktop) + return 0; // Don't create an explicit window surface for the destkop. + return new QVFbWindowSurface(mPrimaryScreen, widget); +} + + +QPlatformWindow *QVFbIntegration::createPlatformWindow(QWidget *widget, WId) const +{ + return new QVFbWindow(mPrimaryScreen, widget); +} + +QT_END_NAMESPACE + +#include "qgraphicssystem_qvfb.moc" diff --git a/src/plugins/platforms/qvfb/qvfbintegration.h b/src/plugins/platforms/qvfb/qvfbintegration.h new file mode 100644 index 0000000..1207678 --- /dev/null +++ b/src/plugins/platforms/qvfb/qvfbintegration.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_QVFB_H +#define QGRAPHICSSYSTEM_QVFB_H + +#include +#include + +QT_BEGIN_NAMESPACE + + +class QVFbScreenPrivate; + +class QVFbScreen : public QPlatformScreen +{ +public: + QVFbScreen(); + ~QVFbScreen(); + + QRect geometry() const; + int depth() const; + QImage::Format format() const; + QSize physicalSize() const; + + QImage *screenImage(); + + void setDirty(const QRect &rect); + +public: + + QVFbScreenPrivate *d_ptr; +}; + +class QVFbIntegrationPrivate; + + +class QVFbIntegration : public QPlatformIntegration +{ +public: + QVFbIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const; + + QList screens() const { return mScreens; } + +private: + QVFbScreen *mPrimaryScreen; + QList mScreens; +}; + + + +QT_END_NAMESPACE + + +#endif diff --git a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp index 0aafe28..b46d9c0 100644 --- a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp +++ b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp @@ -41,15 +41,15 @@ #include "qwindowsurface_qvfb.h" -#include "qgraphicssystem_qvfb.h" +#include "qvfbintegration.h" #include #include #include QT_BEGIN_NAMESPACE -QVFbWindowSurface::QVFbWindowSurface(QVFbGraphicsSystem *graphicsSystem, - QVFbGraphicsSystemScreen *screen, QWidget *window) +QVFbWindowSurface::QVFbWindowSurface(//QVFbIntegration *graphicsSystem, + QVFbScreen *screen, QWidget *window) : QWindowSurface(window), mScreen(screen) { @@ -69,36 +69,40 @@ void QVFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi Q_UNUSED(widget); Q_UNUSED(offset); - QRect rect = geometry(); - QPoint topLeft = rect.topLeft(); +// QRect rect = geometry(); +// QPoint topLeft = rect.topLeft(); mScreen->setDirty(region.boundingRect()); } -void QVFbWindowSurface::setGeometry(const QRect &) +void QVFbWindowSurface::resize(const QSize&) { // any size you like as long as it's full-screen... QRect rect(mScreen->availableGeometry()); - QWindowSystemInterface::handleGeometryChange(this->window(), rect); - - QWindowSurface::setGeometry(rect); + QWindowSurface::resize(rect.size()); } -bool QVFbWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - return QWindowSurface::scroll(area, dx, dy); -} -void QVFbWindowSurface::beginPaint(const QRegion ®ion) +QVFbWindow::QVFbWindow(QVFbScreen *screen, QWidget *window) + : QPlatformWindow(window), + mScreen(screen) { - Q_UNUSED(region); } -void QVFbWindowSurface::endPaint(const QRegion ®ion) + +void QVFbWindow::setGeometry(const QRect &) { - Q_UNUSED(region); + +// any size you like as long as it's full-screen... + + QRect rect(mScreen->availableGeometry()); + QWindowSystemInterface::handleGeometryChange(this->widget(), rect); + + QPlatformWindow::setGeometry(rect); } + + QT_END_NAMESPACE diff --git a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h index 1971caa..9228189 100644 --- a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h +++ b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h @@ -43,32 +43,38 @@ #define QWINDOWSURFACE_QVFB_H #include +#include QT_BEGIN_NAMESPACE -class QVFbGraphicsSystem; -class QVFbGraphicsSystemScreen; +class QVFbIntegration; +class QVFbScreen; class QVFbWindowSurface : public QWindowSurface { public: - QVFbWindowSurface(QVFbGraphicsSystem *graphicsSystem, - QVFbGraphicsSystemScreen *screen, QWidget *window); + QVFbWindowSurface(QVFbScreen *screen, QWidget *window); ~QVFbWindowSurface(); QPaintDevice *paintDevice(); void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); - bool scroll(const QRegion &area, int dx, int dy); + void resize(const QSize &size); + +private: + QVFbScreen *mScreen; +}; - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); +class QVFbWindow : public QPlatformWindow +{ +public: + QVFbWindow(QVFbScreen *screen, QWidget *window); + void setGeometry(const QRect &rect); private: - QVFbGraphicsSystem *mGraphicsSystem; - QVFbGraphicsSystemScreen *mScreen; + QVFbScreen *mScreen; }; + QT_END_NAMESPACE #endif -- cgit v0.12 From f507dca0b179b85455662c69029435310320f4c0 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 13 Apr 2010 16:11:27 +0200 Subject: Oops, don't crash in raise()/lower() --- src/plugins/platforms/testlite/qplatformintegration_testlite.cpp | 2 +- src/plugins/platforms/testlite/qtestlitewindow.cpp | 6 +++--- src/plugins/platforms/testlite/qtestlitewindow.h | 3 +-- src/plugins/platforms/testlite/qwindowsurface_testlite.cpp | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp index f9b3135..f13951d 100644 --- a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp +++ b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp @@ -113,7 +113,7 @@ QWindowSurface *QTestLiteIntegration::createWindowSurfaceForWindow(QWidget *widg QPlatformWindow *QTestLiteIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const { - return new QTestLiteWindow(const_cast(this), mPrimaryScreen, widget); + return new QTestLiteWindow(this, mPrimaryScreen, widget); } diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index 0b215e3..108f732 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -143,7 +143,7 @@ private: -QTestLiteWindow::QTestLiteWindow(QTestLiteIntegration *platformIntegration, +QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration, QTestLiteScreen */*screen*/, QWidget *window) :QPlatformWindow(window) { @@ -638,12 +638,12 @@ WId QTestLiteWindow::winId() const void QTestLiteWindow::raise() { - XRaiseWindow(mPlatformIntegration->xd->display, x_window); + XRaiseWindow(xd->display, x_window); } void QTestLiteWindow::lower() { - XLowerWindow(mPlatformIntegration->xd->display, x_window); + XLowerWindow(xd->display, x_window); } void QTestLiteWindow::setWindowTitle(const QString &title) diff --git a/src/plugins/platforms/testlite/qtestlitewindow.h b/src/plugins/platforms/testlite/qtestlitewindow.h index 6fb7ed2..3624854 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.h +++ b/src/plugins/platforms/testlite/qtestlitewindow.h @@ -99,7 +99,7 @@ class QWindowSurface; class QTestLiteWindow : public QPlatformWindow { public: - QTestLiteWindow(QTestLiteIntegration *platformIntegration, + QTestLiteWindow(const QTestLiteIntegration *platformIntegration, QTestLiteScreen *screen, QWidget *window); ~QTestLiteWindow(); @@ -143,7 +143,6 @@ private: QWindowSurface *windowSurface; MyDisplay *xd; - QTestLiteIntegration *mPlatformIntegration; QTestLiteScreen *mScreen; Qt::WindowFlags window_flags; diff --git a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp index b5a0f74..af10368 100644 --- a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp +++ b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp @@ -137,7 +137,6 @@ QTestLiteWindowSurface::QTestLiteWindowSurface (QTestLiteScreen */*screen*/, QWi QTestLiteWindowSurface::~QTestLiteWindowSurface() { - qDebug() << "~QTestLiteWindowSurface"; delete image_info; } -- cgit v0.12 From b2315a45cb1d64b86a4974ae0dac97c877a69d91 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 14 Apr 2010 11:07:02 +0200 Subject: Implement createWindowSurface, so that reparenting works MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jørgen --- src/gui/painting/qgraphicssystem_lite.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/painting/qgraphicssystem_lite.cpp b/src/gui/painting/qgraphicssystem_lite.cpp index a62abbb..68d880b 100644 --- a/src/gui/painting/qgraphicssystem_lite.cpp +++ b/src/gui/painting/qgraphicssystem_lite.cpp @@ -51,8 +51,7 @@ QPixmapData *QLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) QWindowSurface *QLiteGraphicsSystem::createWindowSurface(QWidget *widget) const { - qFatal("should not use QLiteGraphicsSystem::createWindowSurface"); - return 0; + return QApplicationPrivate::platformIntegration()->createWindowSurfaceForWindow(widget, widget->winId()); } QBlittable *QLiteGraphicsSystem::createBlittable(const QSize &size) const -- cgit v0.12 From 4e42cea17031ff90481a674686afdd5548fba4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 14 Apr 2010 12:38:01 +0200 Subject: Refactored directfb plugin --- src/plugins/platforms/directfb/directfb.pro | 12 +- src/plugins/platforms/directfb/main.cpp | 2 +- .../platforms/directfb/qblitter_directfb.cpp | 114 ----------------- src/plugins/platforms/directfb/qblitter_directfb.h | 29 ----- .../platforms/directfb/qdirectfbblitter.cpp | 114 +++++++++++++++++ src/plugins/platforms/directfb/qdirectfbblitter.h | 29 +++++ .../platforms/directfb/qdirectfbconvenience.cpp | 2 +- src/plugins/platforms/directfb/qdirectfbcursor.cpp | 3 - .../platforms/directfb/qdirectfbintegration.cpp | 125 ++++++++++++++++++ .../platforms/directfb/qdirectfbintegration.h | 100 +++++++++++++++ .../platforms/directfb/qdirectfbwindowsurface.cpp | 141 +++++++++++++++++++++ .../platforms/directfb/qdirectfbwindowsurface.h | 77 +++++++++++ .../directfb/qplatformintegration_directfb.cpp | 125 ------------------ .../directfb/qplatformintegration_directfb.h | 99 --------------- .../platforms/directfb/qwindowsurface_directfb.cpp | 141 --------------------- .../platforms/directfb/qwindowsurface_directfb.h | 77 ----------- 16 files changed, 594 insertions(+), 596 deletions(-) delete mode 100644 src/plugins/platforms/directfb/qblitter_directfb.cpp delete mode 100644 src/plugins/platforms/directfb/qblitter_directfb.h create mode 100644 src/plugins/platforms/directfb/qdirectfbblitter.cpp create mode 100644 src/plugins/platforms/directfb/qdirectfbblitter.h create mode 100644 src/plugins/platforms/directfb/qdirectfbintegration.cpp create mode 100644 src/plugins/platforms/directfb/qdirectfbintegration.h create mode 100644 src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp create mode 100644 src/plugins/platforms/directfb/qdirectfbwindowsurface.h delete mode 100644 src/plugins/platforms/directfb/qplatformintegration_directfb.cpp delete mode 100644 src/plugins/platforms/directfb/qplatformintegration_directfb.h delete mode 100644 src/plugins/platforms/directfb/qwindowsurface_directfb.cpp delete mode 100644 src/plugins/platforms/directfb/qwindowsurface_directfb.h diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro index ec5f0f1..f81ec31 100644 --- a/src/plugins/platforms/directfb/directfb.pro +++ b/src/plugins/platforms/directfb/directfb.pro @@ -13,16 +13,16 @@ INCLUDEPATH += $$DIRECTFB_INCLUDEPATH LIBS += $$DIRECTFB_LIBS SOURCES = main.cpp \ - qplatformintegration_directfb.cpp \ - qwindowsurface_directfb.cpp \ - qblitter_directfb.cpp \ + qdirectfbintegration.cpp \ + qdirectfbwindowsurface.cpp \ + qdirectfbblitter.cpp \ qdirectfbconvenience.cpp \ qdirectfbinput.cpp \ qdirectfbcursor.cpp \ qdirectfbwindow.cpp -HEADERS = qplatformintegration_directfb.h \ - qwindowsurface_directfb.h \ - qblitter_directfb.h \ +HEADERS = qdirectfbintegration.h \ + qdirectfbwindowsurface.h \ + qdirectfbblitter.h \ qdirectfbconvenience.h \ qdirectfbinput.h \ qdirectfbcursor.h \ diff --git a/src/plugins/platforms/directfb/main.cpp b/src/plugins/platforms/directfb/main.cpp index 1f0f081..9c7bcf6 100644 --- a/src/plugins/platforms/directfb/main.cpp +++ b/src/plugins/platforms/directfb/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include -#include "qplatformintegration_directfb.h" +#include "qdirectfbintegration.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/directfb/qblitter_directfb.cpp b/src/plugins/platforms/directfb/qblitter_directfb.cpp deleted file mode 100644 index 20f8741..0000000 --- a/src/plugins/platforms/directfb/qblitter_directfb.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include "qblitter_directfb.h" -#include "qdirectfbconvenience.h" - -#include - -#include - -#include - -QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, IDirectFBSurface *surface) - : QBlittable(rect, QBlittable::Capabilities(QBlittable::SolidRectCapability - |QBlittable::SourcePixmapCapability - |QBlittable::SourceOverPixmapCapability - |QBlittable::SourceOverScaledPixmapCapability)) -{ - if (surface) { - m_surface = surface; - } else { - DFBSurfaceDescription surfaceDesc; - memset(&surfaceDesc,0,sizeof(DFBSurfaceDescription)); - surfaceDesc.width = rect.width(); - surfaceDesc.height = rect.height(); - surfaceDesc.caps = DSCAPS_PREMULTIPLIED; - surfaceDesc.pixelformat = DSPF_ARGB; - surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT); - - IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); - dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); - m_surface->Clear(m_surface,0,0,0,0); - } - -} - -QDirectFbBlitter::~QDirectFbBlitter() -{ - unlock(); - m_surface->Release(m_surface); -} - -void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color) -{ - m_surface->SetColor(m_surface, color.red(), color.green(), color.blue(), color.alpha()); -// When the blitter api supports non opaque blits, also remember to change -// qpixmap_blitter.cpp::fill -// DFBSurfaceDrawingFlags drawingFlags = color.alpha() ? DSDRAW_BLEND : DSDRAW_NOFX; -// m_surface->SetDrawingFlags(m_surface, drawingFlags); - m_surface->SetDrawingFlags(m_surface, DSDRAW_NOFX); - m_surface->FillRectangle(m_surface, rect.x(), rect.y(), - rect.width(), rect.height()); -} - -void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &srcRect) -{ - QPixmapData *data = pixmap.pixmapData(); - Q_ASSERT(data->width() && data->height()); - Q_ASSERT(data->classId() == QPixmapData::BlitterClass); - QBlittablePixmapData *blitPm = static_cast(data); - QDirectFbBlitter *dfbBlitter = static_cast(blitPm->blittable()); - dfbBlitter->unlock(); - - IDirectFBSurface *s = dfbBlitter->m_surface; - - DFBSurfaceBlittingFlags blittingFlags = DSBLIT_NOFX; - DFBSurfacePorterDuffRule porterDuff = DSPD_SRC; - if (pixmap.hasAlpha()) { - blittingFlags = DSBLIT_BLEND_ALPHACHANNEL; - porterDuff = DSPD_SRC_OVER; - } - - m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags)); - m_surface->SetPorterDuff(m_surface,porterDuff); - m_surface->SetDstBlendFunction(m_surface,DSBF_INVSRCALPHA); - - const DFBRectangle sRect = { srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height() }; - - DFBResult result; - if (rect.width() == srcRect.width() && rect.height() == srcRect.height()) - result = m_surface->Blit(m_surface, s, &sRect, rect.x(), rect.y()); - else { - const DFBRectangle dRect = { rect.x(), rect.y(), rect.width(), rect.height() }; - result = m_surface->StretchBlit(m_surface, s, &sRect, &dRect); - } - if (result != DFB_OK) - DirectFBError("QDirectFBBlitter::drawPixmap()", result); -} - -QImage *QDirectFbBlitter::doLock() -{ - Q_ASSERT(m_surface); - Q_ASSERT(size().isValid()); - - void *mem; - int bpl; - const DFBResult result = m_surface->Lock(m_surface, DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast(&mem), &bpl); - if (result == DFB_OK) { - DFBSurfacePixelFormat dfbFormat; - DFBSurfaceCapabilities dfbCaps; - m_surface->GetPixelFormat(m_surface,&dfbFormat); - m_surface->GetCapabilities(m_surface,&dfbCaps); - QImage::Format format = QDirectFbConvenience::imageFormatFromSurfaceFormat(dfbFormat, dfbCaps); - int w, h; - m_surface->GetSize(m_surface,&w,&h); - m_image = QImage(static_cast(mem),w,h,bpl,format); - } else { - DirectFBError("Failed to lock image", result); - } - - return &m_image; -} - -void QDirectFbBlitter::doUnlock() -{ - m_surface->Unlock(m_surface); -} diff --git a/src/plugins/platforms/directfb/qblitter_directfb.h b/src/plugins/platforms/directfb/qblitter_directfb.h deleted file mode 100644 index 85a303a..0000000 --- a/src/plugins/platforms/directfb/qblitter_directfb.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef QDIRECTFBBLITTER_H -#define QDIRECTFBBLITTER_H - -#include "qdirectfbconvenience.h" - -#include - -#include - -class QDirectFbBlitter : public QBlittable -{ -public: - QDirectFbBlitter(const QSize &size, IDirectFBSurface *surface = 0); - virtual ~QDirectFbBlitter(); - - virtual void fillRect(const QRectF &rect, const QColor &color); - virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect); - -protected: - virtual QImage *doLock(); - virtual void doUnlock(); - - IDirectFBSurface *m_surface; - QImage m_image; - - friend class QDirectFbConvenience; -}; - -#endif // QDIRECTFBBLITTER_H diff --git a/src/plugins/platforms/directfb/qdirectfbblitter.cpp b/src/plugins/platforms/directfb/qdirectfbblitter.cpp new file mode 100644 index 0000000..15bb18b --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbblitter.cpp @@ -0,0 +1,114 @@ +#include "qdirectfbblitter.h" +#include "qdirectfbconvenience.h" + +#include + +#include + +#include + +QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, IDirectFBSurface *surface) + : QBlittable(rect, QBlittable::Capabilities(QBlittable::SolidRectCapability + |QBlittable::SourcePixmapCapability + |QBlittable::SourceOverPixmapCapability + |QBlittable::SourceOverScaledPixmapCapability)) +{ + if (surface) { + m_surface = surface; + } else { + DFBSurfaceDescription surfaceDesc; + memset(&surfaceDesc,0,sizeof(DFBSurfaceDescription)); + surfaceDesc.width = rect.width(); + surfaceDesc.height = rect.height(); + surfaceDesc.caps = DSCAPS_PREMULTIPLIED; + surfaceDesc.pixelformat = DSPF_ARGB; + surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT); + + IDirectFB *dfb = QDirectFbConvenience::dfbInterface(); + dfb->CreateSurface(dfb,&surfaceDesc, &m_surface); + m_surface->Clear(m_surface,0,0,0,0); + } + +} + +QDirectFbBlitter::~QDirectFbBlitter() +{ + unlock(); + m_surface->Release(m_surface); +} + +void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color) +{ + m_surface->SetColor(m_surface, color.red(), color.green(), color.blue(), color.alpha()); +// When the blitter api supports non opaque blits, also remember to change +// qpixmap_blitter.cpp::fill +// DFBSurfaceDrawingFlags drawingFlags = color.alpha() ? DSDRAW_BLEND : DSDRAW_NOFX; +// m_surface->SetDrawingFlags(m_surface, drawingFlags); + m_surface->SetDrawingFlags(m_surface, DSDRAW_NOFX); + m_surface->FillRectangle(m_surface, rect.x(), rect.y(), + rect.width(), rect.height()); +} + +void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &srcRect) +{ + QPixmapData *data = pixmap.pixmapData(); + Q_ASSERT(data->width() && data->height()); + Q_ASSERT(data->classId() == QPixmapData::BlitterClass); + QBlittablePixmapData *blitPm = static_cast(data); + QDirectFbBlitter *dfbBlitter = static_cast(blitPm->blittable()); + dfbBlitter->unlock(); + + IDirectFBSurface *s = dfbBlitter->m_surface; + + DFBSurfaceBlittingFlags blittingFlags = DSBLIT_NOFX; + DFBSurfacePorterDuffRule porterDuff = DSPD_SRC; + if (pixmap.hasAlpha()) { + blittingFlags = DSBLIT_BLEND_ALPHACHANNEL; + porterDuff = DSPD_SRC_OVER; + } + + m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags)); + m_surface->SetPorterDuff(m_surface,porterDuff); + m_surface->SetDstBlendFunction(m_surface,DSBF_INVSRCALPHA); + + const DFBRectangle sRect = { srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height() }; + + DFBResult result; + if (rect.width() == srcRect.width() && rect.height() == srcRect.height()) + result = m_surface->Blit(m_surface, s, &sRect, rect.x(), rect.y()); + else { + const DFBRectangle dRect = { rect.x(), rect.y(), rect.width(), rect.height() }; + result = m_surface->StretchBlit(m_surface, s, &sRect, &dRect); + } + if (result != DFB_OK) + DirectFBError("QDirectFBBlitter::drawPixmap()", result); +} + +QImage *QDirectFbBlitter::doLock() +{ + Q_ASSERT(m_surface); + Q_ASSERT(size().isValid()); + + void *mem; + int bpl; + const DFBResult result = m_surface->Lock(m_surface, DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast(&mem), &bpl); + if (result == DFB_OK) { + DFBSurfacePixelFormat dfbFormat; + DFBSurfaceCapabilities dfbCaps; + m_surface->GetPixelFormat(m_surface,&dfbFormat); + m_surface->GetCapabilities(m_surface,&dfbCaps); + QImage::Format format = QDirectFbConvenience::imageFormatFromSurfaceFormat(dfbFormat, dfbCaps); + int w, h; + m_surface->GetSize(m_surface,&w,&h); + m_image = QImage(static_cast(mem),w,h,bpl,format); + } else { + DirectFBError("Failed to lock image", result); + } + + return &m_image; +} + +void QDirectFbBlitter::doUnlock() +{ + m_surface->Unlock(m_surface); +} diff --git a/src/plugins/platforms/directfb/qdirectfbblitter.h b/src/plugins/platforms/directfb/qdirectfbblitter.h new file mode 100644 index 0000000..85a303a --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbblitter.h @@ -0,0 +1,29 @@ +#ifndef QDIRECTFBBLITTER_H +#define QDIRECTFBBLITTER_H + +#include "qdirectfbconvenience.h" + +#include + +#include + +class QDirectFbBlitter : public QBlittable +{ +public: + QDirectFbBlitter(const QSize &size, IDirectFBSurface *surface = 0); + virtual ~QDirectFbBlitter(); + + virtual void fillRect(const QRectF &rect, const QColor &color); + virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect); + +protected: + virtual QImage *doLock(); + virtual void doUnlock(); + + IDirectFBSurface *m_surface; + QImage m_image; + + friend class QDirectFbConvenience; +}; + +#endif // QDIRECTFBBLITTER_H diff --git a/src/plugins/platforms/directfb/qdirectfbconvenience.cpp b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp index 8594c09..adf9687 100644 --- a/src/plugins/platforms/directfb/qdirectfbconvenience.cpp +++ b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp @@ -1,5 +1,5 @@ #include "qdirectfbconvenience.h" -#include "qblitter_directfb.h" +#include "qdirectfbblitter.h" #include diff --git a/src/plugins/platforms/directfb/qdirectfbcursor.cpp b/src/plugins/platforms/directfb/qdirectfbcursor.cpp index bb7088f..2edae45 100644 --- a/src/plugins/platforms/directfb/qdirectfbcursor.cpp +++ b/src/plugins/platforms/directfb/qdirectfbcursor.cpp @@ -1,9 +1,6 @@ #include "qdirectfbcursor.h" -#include "qblitter_directfb.h" -#include "qplatformintegration_directfb.h" #include "qdirectfbconvenience.h" -#include QDirectFBCursor::QDirectFBCursor(QPlatformScreen* screen) : QGraphicsSystemCursor(screen), surface(0) diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp new file mode 100644 index 0000000..b096081 --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdirectfbintegration.h" +#include "qdirectfbwindowsurface.h" +#include "qdirectfbblitter.h" +#include "qdirectfbconvenience.h" +#include "qdirectfbcursor.h" +#include "qdirectfbwindow.h" + +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QDirectFbScreen::QDirectFbScreen(int display) + :QPlatformScreen() +{ + m_layer = QDirectFbConvenience::dfbDisplayLayer(display); + m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); + + DFBDisplayLayerConfig config; + m_layer->GetConfiguration(m_layer, &config); + + m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps); + m_geometry = QRect(0,0,config.width,config.height); + const int dpi = 72; + const qreal inch = 25.4; + m_depth = 32; + m_physicalSize = QSize(qRound(config.width * inch / dpi), qRound(config.height *inch / dpi)); + + cursor = new QDirectFBCursor(this); +} + +QDirectFbScreen::~QDirectFbScreen() +{ +} + +QDirectFbIntegration::QDirectFbIntegration() +{ + const QStringList args = QCoreApplication::arguments(); + int argc = args.size(); + char **argv = new char*[argc]; + + for (int i = 0; i < argc; ++i) + argv[i] = qstrdup(args.at(i).toLocal8Bit().constData()); + + DFBResult result = DirectFBInit(&argc, &argv); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreen: error initializing DirectFB", + result); + } + delete[] argv; + + QDirectFbScreen *primaryScreen = new QDirectFbScreen(0); + mScreens.append(primaryScreen); +} + +QPixmapData *QDirectFbIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + if (type == QPixmapData::BitmapType) + return new QRasterPixmapData(type); + else + return new QBlittablePixmapData(type); +} + +QPlatformWindow *QDirectFbIntegration::createPlatformWindow(QWidget *widget, WId winId) const +{ + Q_UNUSED(winId); + return new QDirectFbWindow(widget); +} + +QWindowSurface *QDirectFbIntegration::createWindowSurfaceForWindow(QWidget *widget, WId winId) const +{ + return new QDirectFbWindowSurface(widget,winId); +} + +QBlittable *QDirectFbIntegration::createBlittable(const QSize &size) const +{ + return new QDirectFbBlitter(size); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.h b/src/plugins/platforms/directfb/qdirectfbintegration.h new file mode 100644 index 0000000..808bc9d --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbintegration.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMINTEGRATION_DIRECTFB_H +#define QPLATFORMINTEGRATION_DIRECTFB_H + +#include "qdirectfbinput.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QDirectFBCursor; + +class QDirectFbScreen : public QPlatformScreen +{ +Q_OBJECT +public: + QDirectFbScreen(int display); + ~QDirectFbScreen(); + + 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; } + +public: + QRect m_geometry; + int m_depth; + QImage::Format m_format; + QSize m_physicalSize; + + IDirectFBDisplayLayer *m_layer; + +private: + QDirectFBCursor * cursor; + +}; + +class QDirectFbIntegration : public QPlatformIntegration +{ +public: + QDirectFbIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; + QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const; + QBlittable *createBlittable(const QSize &size) const; + + QList screens() const { return mScreens; } + + + +private: + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp b/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp new file mode 100644 index 0000000..4ca9a72 --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdirectfbwindowsurface.h" +#include "qdirectfbintegration.h" +#include "qdirectfbblitter.h" +#include "qdirectfbconvenience.h" +#include + +#include + +QT_BEGIN_NAMESPACE + +QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window, WId wId) + : QWindowSurface(window), m_pixmap(0), m_pmdata(0), m_dfbSurface(0) +{ + + IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); + + DFBWindowID id(wId); + IDirectFBWindow *dfbWindow; + + layer->GetWindow(layer,id,&dfbWindow); + + dfbWindow->GetSurface(dfbWindow,&m_dfbSurface); +//WRONGSIZE + QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect().size(), m_dfbSurface); + m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); + m_pmdata->setBlittable(blitter); + m_pixmap = new QPixmap(m_pmdata); +} + +QDirectFbWindowSurface::~QDirectFbWindowSurface() +{ + +} + +QPaintDevice *QDirectFbWindowSurface::paintDevice() +{ + return m_pixmap; +} + +void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + m_pmdata->blittable()->unlock(); + + QVector rects = region.rects(); + for (int i = 0 ; i < rects.size(); i++) { + const QRect rect = rects.at(i); + DFBRegion dfbReg = { rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()}; + m_dfbSurface->Flip(m_dfbSurface, &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC)); + } +} + +void QDirectFbWindowSurface::resize(const QSize &size) +{ + QWindowSurface::resize(size); + + //Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable + m_dfbSurface->AddRef(m_dfbSurface); + QDirectFbBlitter *blitter = new QDirectFbBlitter(size,m_dfbSurface); + m_pmdata->setBlittable(blitter); +} + +static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) +{ + const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; + surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy); + const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy }; + surface->Flip(surface, ®ion, DFBSurfaceFlipFlags(DSFLIP_BLIT)); +} + +bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + m_pmdata->blittable()->unlock(); + + if (!m_dfbSurface || area.isEmpty()) + return false; + m_dfbSurface->SetBlittingFlags(m_dfbSurface, DSBLIT_NOFX); + if (area.rectCount() == 1) { + scrollSurface(m_dfbSurface, area.boundingRect(), dx, dy); + } else { + const QVector rects = area.rects(); + const int n = rects.size(); + for (int i=0; i +#include + +#include + +QT_BEGIN_NAMESPACE + +class QDirectFbWindowSurface : public QWindowSurface +{ +public: + QDirectFbWindowSurface(QWidget *window, WId wid); + ~QDirectFbWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void resize (const QSize &size); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + +private: + void lockSurfaceToImage(); + + QPixmap *m_pixmap; + QBlittablePixmapData *m_pmdata; + + IDirectFBSurface *m_dfbSurface; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/directfb/qplatformintegration_directfb.cpp b/src/plugins/platforms/directfb/qplatformintegration_directfb.cpp deleted file mode 100644 index 5f428ef..0000000 --- a/src/plugins/platforms/directfb/qplatformintegration_directfb.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qplatformintegration_directfb.h" -#include "qwindowsurface_directfb.h" -#include "qblitter_directfb.h" -#include "qdirectfbconvenience.h" -#include "qdirectfbcursor.h" -#include "qdirectfbwindow.h" - -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QDirectFbScreen::QDirectFbScreen(int display) - :QPlatformScreen() -{ - m_layer = QDirectFbConvenience::dfbDisplayLayer(display); - m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED); - - DFBDisplayLayerConfig config; - m_layer->GetConfiguration(m_layer, &config); - - m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps); - m_geometry = QRect(0,0,config.width,config.height); - const int dpi = 72; - const qreal inch = 25.4; - m_depth = 32; - m_physicalSize = QSize(qRound(config.width * inch / dpi), qRound(config.height *inch / dpi)); - - cursor = new QDirectFBCursor(this); -} - -QDirectFbScreen::~QDirectFbScreen() -{ -} - -QDirectFbIntegration::QDirectFbIntegration() -{ - const QStringList args = QCoreApplication::arguments(); - int argc = args.size(); - char **argv = new char*[argc]; - - for (int i = 0; i < argc; ++i) - argv[i] = qstrdup(args.at(i).toLocal8Bit().constData()); - - DFBResult result = DirectFBInit(&argc, &argv); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreen: error initializing DirectFB", - result); - } - delete[] argv; - - QDirectFbScreen *primaryScreen = new QDirectFbScreen(0); - mScreens.append(primaryScreen); -} - -QPixmapData *QDirectFbIntegration::createPixmapData(QPixmapData::PixelType type) const -{ - if (type == QPixmapData::BitmapType) - return new QRasterPixmapData(type); - else - return new QBlittablePixmapData(type); -} - -QPlatformWindow *QDirectFbIntegration::createPlatformWindow(QWidget *widget, WId winId) const -{ - Q_UNUSED(winId); - return new QDirectFbWindow(widget); -} - -QWindowSurface *QDirectFbIntegration::createWindowSurfaceForWindow(QWidget *widget, WId winId) const -{ - return new QDirectFbWindowSurface(widget,winId); -} - -QBlittable *QDirectFbIntegration::createBlittable(const QSize &size) const -{ - return new QDirectFbBlitter(size); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/directfb/qplatformintegration_directfb.h b/src/plugins/platforms/directfb/qplatformintegration_directfb.h deleted file mode 100644 index a8489c0..0000000 --- a/src/plugins/platforms/directfb/qplatformintegration_directfb.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPLATFORMINTEGRATION_DIRECTFB_H -#define QPLATFORMINTEGRATION_DIRECTFB_H - -#include "qdirectfbinput.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDirectFBCursor; - -class QDirectFbScreen : public QPlatformScreen -{ -public: - QDirectFbScreen(int display); - ~QDirectFbScreen(); - - 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; } - -public: - QRect m_geometry; - int m_depth; - QImage::Format m_format; - QSize m_physicalSize; - - IDirectFBDisplayLayer *m_layer; - -private: - QDirectFBCursor * cursor; - -}; - -class QDirectFbIntegration : public QPlatformIntegration -{ -public: - QDirectFbIntegration(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; - QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const; - QBlittable *createBlittable(const QSize &size) const; - - QList screens() const { return mScreens; } - - - -private: - QList mScreens; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/directfb/qwindowsurface_directfb.cpp b/src/plugins/platforms/directfb/qwindowsurface_directfb.cpp deleted file mode 100644 index e978cae..0000000 --- a/src/plugins/platforms/directfb/qwindowsurface_directfb.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindowsurface_directfb.h" -#include "qplatformintegration_directfb.h" -#include "qblitter_directfb.h" -#include "qdirectfbconvenience.h" -#include - -#include - -QT_BEGIN_NAMESPACE - -QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window, WId wId) - : QWindowSurface(window), m_pixmap(0), m_pmdata(0), m_dfbSurface(0) -{ - - IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); - - DFBWindowID id(wId); - IDirectFBWindow *dfbWindow; - - layer->GetWindow(layer,id,&dfbWindow); - - dfbWindow->GetSurface(dfbWindow,&m_dfbSurface); -//WRONGSIZE - QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect().size(), m_dfbSurface); - m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); - m_pmdata->setBlittable(blitter); - m_pixmap = new QPixmap(m_pmdata); -} - -QDirectFbWindowSurface::~QDirectFbWindowSurface() -{ - -} - -QPaintDevice *QDirectFbWindowSurface::paintDevice() -{ - return m_pixmap; -} - -void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - m_pmdata->blittable()->unlock(); - - QVector rects = region.rects(); - for (int i = 0 ; i < rects.size(); i++) { - const QRect rect = rects.at(i); - DFBRegion dfbReg = { rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()}; - m_dfbSurface->Flip(m_dfbSurface, &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC)); - } -} - -void QDirectFbWindowSurface::resize(const QSize &size) -{ - QWindowSurface::resize(size); - - //Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable - m_dfbSurface->AddRef(m_dfbSurface); - QDirectFbBlitter *blitter = new QDirectFbBlitter(size,m_dfbSurface); - m_pmdata->setBlittable(blitter); -} - -static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) -{ - const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; - surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy); - const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy }; - surface->Flip(surface, ®ion, DFBSurfaceFlipFlags(DSFLIP_BLIT)); -} - -bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - m_pmdata->blittable()->unlock(); - - if (!m_dfbSurface || area.isEmpty()) - return false; - m_dfbSurface->SetBlittingFlags(m_dfbSurface, DSBLIT_NOFX); - if (area.rectCount() == 1) { - scrollSurface(m_dfbSurface, area.boundingRect(), dx, dy); - } else { - const QVector rects = area.rects(); - const int n = rects.size(); - for (int i=0; i -#include - -#include - -QT_BEGIN_NAMESPACE - -class QDirectFbWindowSurface : public QWindowSurface -{ -public: - QDirectFbWindowSurface(QWidget *window, WId wid); - ~QDirectFbWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void resize (const QSize &size); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - -private: - void lockSurfaceToImage(); - - QPixmap *m_pixmap; - QBlittablePixmapData *m_pmdata; - - IDirectFBSurface *m_dfbSurface; -}; - -QT_END_NAMESPACE - -#endif -- cgit v0.12 From a43355f7d10a72f60719f7e5a617bcd0031f8fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 19 Apr 2010 12:54:09 +0200 Subject: QPlatformScreen now has default implementation for physicalSize assuming dpi = 100. This also simplifies minimal slightly. Also use propper apis in qfont for default dpi by using QPlatformScreen --- src/gui/kernel/qplatformscreen_lite.cpp | 8 ++++++++ src/gui/kernel/qplatformscreen_lite.h | 2 +- src/gui/text/qfont.cpp | 14 ++++++++++++-- .../platforms/minimal/qplatformintegration_minimal.cpp | 1 - .../platforms/minimal/qplatformintegration_minimal.h | 1 - 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qplatformscreen_lite.cpp b/src/gui/kernel/qplatformscreen_lite.cpp index 4492463..4c0a02b 100644 --- a/src/gui/kernel/qplatformscreen_lite.cpp +++ b/src/gui/kernel/qplatformscreen_lite.cpp @@ -56,3 +56,11 @@ QWidget *QPlatformScreen::topLevelAt(const QPoint & pos) const return 0; } +QSize QPlatformScreen::physicalSize() const +{ + static const int dpi = 100; + int width = geometry().width() / dpi * qreal(25.4) ; + int height = geometry().height() / dpi * qreal(25.4) ; + return QSize(width,height); +} + diff --git a/src/gui/kernel/qplatformscreen_lite.h b/src/gui/kernel/qplatformscreen_lite.h index cae5f42..7d0e28d 100644 --- a/src/gui/kernel/qplatformscreen_lite.h +++ b/src/gui/kernel/qplatformscreen_lite.h @@ -62,7 +62,7 @@ public: virtual QRect availableGeometry() const {return geometry();}; virtual int depth() const = 0; virtual QImage::Format format() const = 0; - virtual QSize physicalSize() const = 0; + virtual QSize physicalSize() const; virtual void setDirty(const QRect &) {} virtual QWidget *topLevelAt(const QPoint &point) const; }; diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 01e4ef6..81d431c 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -75,6 +75,10 @@ #ifdef Q_OS_SYMBIAN #include "qt_s60_p.h" #endif +#ifdef Q_WS_LITE +#include +#include +#endif #include @@ -173,7 +177,10 @@ Q_GUI_EXPORT int qt_defaultDpiX() screen = subScreens.at(0); dpi = qRound(screen->width() / (screen->physicalWidth() / qreal(25.4))); #elif defined(Q_WS_LITE) - dpi = 72; + QPlatformScreen *screen = QApplicationPrivate::platformIntegration()->screens().at(0); + const QSize screenSize = screen->geometry().size(); + const QSize physicalSize = screen->physicalSize(); + dpi = qRound(screenSize.width() / (physicalSize.width() / qreal(25.4))); #elif defined(Q_OS_SYMBIAN) dpi = S60->defaultDpiX; #endif // Q_WS_X11 @@ -203,7 +210,10 @@ Q_GUI_EXPORT int qt_defaultDpiY() screen = subScreens.at(0); dpi = qRound(screen->height() / (screen->physicalHeight() / qreal(25.4))); #elif defined(Q_WS_LITE) - dpi = 72; + QPlatformScreen *screen = QApplicationPrivate::platformIntegration()->screens().at(0); + const QSize screenSize = screen->geometry().size(); + const QSize physicalSize = screen->physicalSize(); + dpi = qRound(screenSize.height() / (physicalSize.height() / qreal(25.4))); #elif defined(Q_OS_SYMBIAN) dpi = S60->defaultDpiY; #endif // Q_WS_X11 diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp index 404ffbc..94aa4f3 100644 --- a/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp +++ b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp @@ -11,7 +11,6 @@ QMinimalIntegration::QMinimalIntegration() mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320); mPrimaryScreen->mDepth = 16; mPrimaryScreen->mFormat = QImage::Format_RGB16; - mPrimaryScreen->mPhysicalSize = QSize(40, 54); mScreens.append(mPrimaryScreen); } diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.h b/src/plugins/platforms/minimal/qplatformintegration_minimal.h index 2e8a8cf..fefe6c3 100644 --- a/src/plugins/platforms/minimal/qplatformintegration_minimal.h +++ b/src/plugins/platforms/minimal/qplatformintegration_minimal.h @@ -57,7 +57,6 @@ public: QRect geometry() const { return mGeometry; } int depth() const { return mDepth; } QImage::Format format() const { return mFormat; } - QSize physicalSize() const { return mPhysicalSize; } public: QRect mGeometry; -- cgit v0.12 From 66e4d48129d6baa405ed9a4a22b12913227a8c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 21 Apr 2010 08:28:30 +0200 Subject: Renamed createWindowSurfaceForWindow to createWindowSurface. Gave also a default dpi when there is no platform integration, ie. it has not been initialised yet or is being initialised. --- src/gui/kernel/qplatformintegration_lite.h | 2 +- src/gui/kernel/qwidget_lite.cpp | 2 +- src/gui/painting/qgraphicssystem_lite.cpp | 2 +- src/gui/text/qfont.cpp | 28 +++++++++++++++------- .../platforms/directfb/qdirectfbintegration.cpp | 2 +- .../platforms/directfb/qdirectfbintegration.h | 2 +- .../platforms/linuxfb/qgraphicssystem_linuxfb.cpp | 4 +--- .../platforms/linuxfb/qgraphicssystem_linuxfb.h | 2 +- .../minimal/qplatformintegration_minimal.cpp | 2 +- .../minimal/qplatformintegration_minimal.h | 2 +- src/plugins/platforms/qvfb/qvfbintegration.cpp | 6 ++--- src/plugins/platforms/qvfb/qvfbintegration.h | 2 +- .../testlite/qplatformintegration_testlite.cpp | 4 +--- .../testlite/qplatformintegration_testlite.h | 2 +- src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp | 4 +--- src/plugins/platforms/vnc/qgraphicssystem_vnc.h | 2 +- 16 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h index b13260e..ee6f833 100644 --- a/src/gui/kernel/qplatformintegration_lite.h +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -63,7 +63,7 @@ public: // GraphicsSystem functions virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; virtual QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const = 0; - virtual QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const = 0; + virtual QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const = 0; virtual QBlittable *createBlittable(const QSize &size) const; // Window System functions diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 465dbee..ee1a582 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -77,7 +77,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO Q_ASSERT(platformWindow); if (!surface) { - surface = QApplicationPrivate::platformIntegration()->createWindowSurfaceForWindow(q,platformWindow->winId()); + surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId()); } Q_ASSERT(surface); diff --git a/src/gui/painting/qgraphicssystem_lite.cpp b/src/gui/painting/qgraphicssystem_lite.cpp index 68d880b..1d24129 100644 --- a/src/gui/painting/qgraphicssystem_lite.cpp +++ b/src/gui/painting/qgraphicssystem_lite.cpp @@ -51,7 +51,7 @@ QPixmapData *QLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) QWindowSurface *QLiteGraphicsSystem::createWindowSurface(QWidget *widget) const { - return QApplicationPrivate::platformIntegration()->createWindowSurfaceForWindow(widget, widget->winId()); + return QApplicationPrivate::platformIntegration()->createWindowSurface(widget, widget->winId()); } QBlittable *QLiteGraphicsSystem::createBlittable(const QSize &size) const diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 81d431c..2c2ceb1 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -177,10 +177,16 @@ Q_GUI_EXPORT int qt_defaultDpiX() screen = subScreens.at(0); dpi = qRound(screen->width() / (screen->physicalWidth() / qreal(25.4))); #elif defined(Q_WS_LITE) - QPlatformScreen *screen = QApplicationPrivate::platformIntegration()->screens().at(0); - const QSize screenSize = screen->geometry().size(); - const QSize physicalSize = screen->physicalSize(); - dpi = qRound(screenSize.width() / (physicalSize.width() / qreal(25.4))); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + if (pi) { + QPlatformScreen *screen = QApplicationPrivate::platformIntegration()->screens().at(0); + const QSize screenSize = screen->geometry().size(); + const QSize physicalSize = screen->physicalSize(); + dpi = qRound(screenSize.width() / (physicalSize.width() / qreal(25.4))); + } else { + //PI has not been initialised, or it is being initialised. Give a default dpi + dpi = 100; + } #elif defined(Q_OS_SYMBIAN) dpi = S60->defaultDpiX; #endif // Q_WS_X11 @@ -210,10 +216,16 @@ Q_GUI_EXPORT int qt_defaultDpiY() screen = subScreens.at(0); dpi = qRound(screen->height() / (screen->physicalHeight() / qreal(25.4))); #elif defined(Q_WS_LITE) - QPlatformScreen *screen = QApplicationPrivate::platformIntegration()->screens().at(0); - const QSize screenSize = screen->geometry().size(); - const QSize physicalSize = screen->physicalSize(); - dpi = qRound(screenSize.height() / (physicalSize.height() / qreal(25.4))); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + if (pi) { + QPlatformScreen *screen = QApplicationPrivate::platformIntegration()->screens().at(0); + const QSize screenSize = screen->geometry().size(); + const QSize physicalSize = screen->physicalSize(); + dpi = qRound(screenSize.height() / (physicalSize.height() / qreal(25.4))); + } else { + //PI has not been initialised, or it is being initialised. Give a default dpi + dpi = 100; + } #elif defined(Q_OS_SYMBIAN) dpi = S60->defaultDpiY; #endif // Q_WS_X11 diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp index b096081..60fce7e 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp +++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp @@ -112,7 +112,7 @@ QPlatformWindow *QDirectFbIntegration::createPlatformWindow(QWidget *widget, WId return new QDirectFbWindow(widget); } -QWindowSurface *QDirectFbIntegration::createWindowSurfaceForWindow(QWidget *widget, WId winId) const +QWindowSurface *QDirectFbIntegration::createWindowSurface(QWidget *widget, WId winId) const { return new QDirectFbWindowSurface(widget,winId); } diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.h b/src/plugins/platforms/directfb/qdirectfbintegration.h index 808bc9d..c0e770f 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.h +++ b/src/plugins/platforms/directfb/qdirectfbintegration.h @@ -84,7 +84,7 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; - QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; QBlittable *createBlittable(const QSize &size) const; QList screens() const { return mScreens; } diff --git a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp index 25cdc7b..acc254a 100644 --- a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp +++ b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp @@ -786,10 +786,8 @@ QPixmapData *QLinuxFbIntegration::createPixmapData(QPixmapData::PixelType type) return new QRasterPixmapData(type); } -QWindowSurface *QLinuxFbIntegration::createWindowSurfaceForWindow(QWidget *widget, WId) const +QWindowSurface *QLinuxFbIntegration::createWindowSurface(QWidget *widget, WId) const { - if (widget->windowType() == Qt::Desktop) - return 0; // Don't create an explicit window surface for the destkop. QFbWindowSurface * surface = new QFbWindowSurface(mPrimaryScreen, widget); return surface; diff --git a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h index 7d4c031..dc61df5 100644 --- a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h +++ b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h @@ -78,7 +78,7 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId WinId) const; - QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId WinId) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId WinId) const; QList screens() const { return mScreens; } diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp index 94aa4f3..73e025c 100644 --- a/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp +++ b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp @@ -26,7 +26,7 @@ QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWidget *widget, WId return new QPlatformWindow(widget); } -QWindowSurface *QMinimalIntegration::createWindowSurfaceForWindow(QWidget *widget, WId winId) const +QWindowSurface *QMinimalIntegration::createWindowSurface(QWidget *widget, WId winId) const { Q_UNUSED(winId); return new QMinimalWindowSurface(widget); diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.h b/src/plugins/platforms/minimal/qplatformintegration_minimal.h index fefe6c3..a2f7449 100644 --- a/src/plugins/platforms/minimal/qplatformintegration_minimal.h +++ b/src/plugins/platforms/minimal/qplatformintegration_minimal.h @@ -72,7 +72,7 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; - QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; QList screens() const { return mScreens; } diff --git a/src/plugins/platforms/qvfb/qvfbintegration.cpp b/src/plugins/platforms/qvfb/qvfbintegration.cpp index 2a877e0..e22c724 100644 --- a/src/plugins/platforms/qvfb/qvfbintegration.cpp +++ b/src/plugins/platforms/qvfb/qvfbintegration.cpp @@ -421,10 +421,8 @@ QPixmapData *QVFbIntegration::createPixmapData(QPixmapData::PixelType type) cons return new QRasterPixmapData(type); } -QWindowSurface *QVFbIntegration::createWindowSurfaceForWindow(QWidget *widget, WId) const +QWindowSurface *QVFbIntegration::createWindowSurface(QWidget *widget, WId) const { - if (widget->windowType() == Qt::Desktop) - return 0; // Don't create an explicit window surface for the destkop. return new QVFbWindowSurface(mPrimaryScreen, widget); } @@ -436,4 +434,4 @@ QPlatformWindow *QVFbIntegration::createPlatformWindow(QWidget *widget, WId) con QT_END_NAMESPACE -#include "qgraphicssystem_qvfb.moc" +#include "qvfbintegration.moc" diff --git a/src/plugins/platforms/qvfb/qvfbintegration.h b/src/plugins/platforms/qvfb/qvfbintegration.h index 1207678..ab44d46 100644 --- a/src/plugins/platforms/qvfb/qvfbintegration.h +++ b/src/plugins/platforms/qvfb/qvfbintegration.h @@ -80,7 +80,7 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; - QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; QList screens() const { return mScreens; } diff --git a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp index f13951d..f657617 100644 --- a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp +++ b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp @@ -103,10 +103,8 @@ QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type) return new QRasterPixmapData(type); } -QWindowSurface *QTestLiteIntegration::createWindowSurfaceForWindow(QWidget *widget, WId) const +QWindowSurface *QTestLiteIntegration::createWindowSurface(QWidget *widget, WId) const { - if (widget->windowType() == Qt::Desktop) - return 0; // Don't create an explicit window surface for the destkop. return new QTestLiteWindowSurface(mPrimaryScreen, widget); } diff --git a/src/plugins/platforms/testlite/qplatformintegration_testlite.h b/src/plugins/platforms/testlite/qplatformintegration_testlite.h index bd27d89..729e74f 100644 --- a/src/plugins/platforms/testlite/qplatformintegration_testlite.h +++ b/src/plugins/platforms/testlite/qplatformintegration_testlite.h @@ -75,7 +75,7 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; - QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; QPixmap grabWindow(WId window, int x, int y, int width, int height) const; diff --git a/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp b/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp index cbc8bbd..a872991 100644 --- a/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp +++ b/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp @@ -114,10 +114,8 @@ QPixmapData *QVNCIntegration::createPixmapData(QPixmapData::PixelType type) cons // return surface; // } -QWindowSurface *QVNCIntegration::createWindowSurfaceForWindow(QWidget *widget, WId) const +QWindowSurface *QVNCIntegration::createWindowSurface(QWidget *widget, WId) const { - if (widget->windowType() == Qt::Desktop) - return 0; // Don't create an explicit window surface for the destkop. QFbWindowSurface * surface; surface = new QFbWindowSurface(mPrimaryScreen, widget); return surface; diff --git a/src/plugins/platforms/vnc/qgraphicssystem_vnc.h b/src/plugins/platforms/vnc/qgraphicssystem_vnc.h index 887ccc3..524b888 100644 --- a/src/plugins/platforms/vnc/qgraphicssystem_vnc.h +++ b/src/plugins/platforms/vnc/qgraphicssystem_vnc.h @@ -80,7 +80,7 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; - QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; QList screens() const { return mScreens; } -- cgit v0.12 From bf9b927dd7143ef02591308b1cecc0c44417deb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 21 Apr 2010 15:45:53 +0200 Subject: Rename files in platform plugins follow same pattern --- src/plugins/platforms/linuxfb/linuxfb.pro | 4 +- src/plugins/platforms/linuxfb/main.cpp | 2 +- .../platforms/linuxfb/qgraphicssystem_linuxfb.cpp | 859 --------------------- .../platforms/linuxfb/qgraphicssystem_linuxfb.h | 129 ---- .../platforms/linuxfb/qlinuxfbintegration.cpp | 859 +++++++++++++++++++++ .../platforms/linuxfb/qlinuxfbintegration.h | 129 ++++ src/plugins/platforms/minimal/main.cpp | 2 +- src/plugins/platforms/minimal/minimal.pro | 8 +- .../platforms/minimal/qminimalintegration.cpp | 33 + .../platforms/minimal/qminimalintegration.h | 85 ++ .../platforms/minimal/qminimalwindowsurface.cpp | 85 ++ .../platforms/minimal/qminimalwindowsurface.h | 67 ++ .../minimal/qplatformintegration_minimal.cpp | 33 - .../minimal/qplatformintegration_minimal.h | 85 -- .../platforms/minimal/qwindowsurface_minimal.cpp | 85 -- .../platforms/minimal/qwindowsurface_minimal.h | 67 -- src/plugins/platforms/qvfb/qvfb.pro | 4 +- src/plugins/platforms/qvfb/qvfbintegration.cpp | 2 +- src/plugins/platforms/qvfb/qvfbwindowsurface.cpp | 108 +++ src/plugins/platforms/qvfb/qvfbwindowsurface.h | 80 ++ src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp | 108 --- src/plugins/platforms/qvfb/qwindowsurface_qvfb.h | 80 -- src/plugins/platforms/testlite/main.cpp | 2 +- .../testlite/qplatformintegration_testlite.cpp | 143 ---- .../testlite/qplatformintegration_testlite.h | 98 --- .../platforms/testlite/qtestliteintegration.cpp | 143 ++++ .../platforms/testlite/qtestliteintegration.h | 98 +++ src/plugins/platforms/testlite/qtestlitewindow.cpp | 4 +- .../platforms/testlite/qtestlitewindowsurface.cpp | 273 +++++++ .../platforms/testlite/qtestlitewindowsurface.h | 88 +++ .../platforms/testlite/qwindowsurface_testlite.cpp | 273 ------- .../platforms/testlite/qwindowsurface_testlite.h | 88 --- src/plugins/platforms/testlite/testlite.pro | 4 +- src/plugins/platforms/vnc/main.cpp | 2 +- src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp | 131 ---- src/plugins/platforms/vnc/qgraphicssystem_vnc.h | 98 --- src/plugins/platforms/vnc/qvnccursor.cpp | 2 +- src/plugins/platforms/vnc/qvncintegration.cpp | 131 ++++ src/plugins/platforms/vnc/qvncintegration.h | 98 +++ src/plugins/platforms/vnc/qvncserver.h | 2 +- src/plugins/platforms/vnc/vnc.pro | 4 +- 41 files changed, 2298 insertions(+), 2298 deletions(-) delete mode 100644 src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp delete mode 100644 src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h create mode 100644 src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp create mode 100644 src/plugins/platforms/linuxfb/qlinuxfbintegration.h create mode 100644 src/plugins/platforms/minimal/qminimalintegration.cpp create mode 100644 src/plugins/platforms/minimal/qminimalintegration.h create mode 100644 src/plugins/platforms/minimal/qminimalwindowsurface.cpp create mode 100644 src/plugins/platforms/minimal/qminimalwindowsurface.h delete mode 100644 src/plugins/platforms/minimal/qplatformintegration_minimal.cpp delete mode 100644 src/plugins/platforms/minimal/qplatformintegration_minimal.h delete mode 100644 src/plugins/platforms/minimal/qwindowsurface_minimal.cpp delete mode 100644 src/plugins/platforms/minimal/qwindowsurface_minimal.h create mode 100644 src/plugins/platforms/qvfb/qvfbwindowsurface.cpp create mode 100644 src/plugins/platforms/qvfb/qvfbwindowsurface.h delete mode 100644 src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp delete mode 100644 src/plugins/platforms/qvfb/qwindowsurface_qvfb.h delete mode 100644 src/plugins/platforms/testlite/qplatformintegration_testlite.cpp delete mode 100644 src/plugins/platforms/testlite/qplatformintegration_testlite.h create mode 100644 src/plugins/platforms/testlite/qtestliteintegration.cpp create mode 100644 src/plugins/platforms/testlite/qtestliteintegration.h create mode 100644 src/plugins/platforms/testlite/qtestlitewindowsurface.cpp create mode 100644 src/plugins/platforms/testlite/qtestlitewindowsurface.h delete mode 100644 src/plugins/platforms/testlite/qwindowsurface_testlite.cpp delete mode 100644 src/plugins/platforms/testlite/qwindowsurface_testlite.h delete mode 100644 src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp delete mode 100644 src/plugins/platforms/vnc/qgraphicssystem_vnc.h create mode 100644 src/plugins/platforms/vnc/qvncintegration.cpp create mode 100644 src/plugins/platforms/vnc/qvncintegration.h diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro index 2633a10..8d4b6d7 100644 --- a/src/plugins/platforms/linuxfb/linuxfb.pro +++ b/src/plugins/platforms/linuxfb/linuxfb.pro @@ -3,8 +3,8 @@ include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms -SOURCES = main.cpp qgraphicssystem_linuxfb.cpp -HEADERS = qgraphicssystem_linuxfb.h +SOURCES = main.cpp qlinuxfbintegration.cpp +HEADERS = qlinuxfbintegration.h include(../fb_base/fb_base.pri) diff --git a/src/plugins/platforms/linuxfb/main.cpp b/src/plugins/platforms/linuxfb/main.cpp index 1ee24b6..65569ac 100644 --- a/src/plugins/platforms/linuxfb/main.cpp +++ b/src/plugins/platforms/linuxfb/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include -#include "qgraphicssystem_linuxfb.h" +#include "qlinuxfbintegration.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp deleted file mode 100644 index 321e90f..0000000 --- a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.cpp +++ /dev/null @@ -1,859 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_linuxfb.h" -#include "../fb_base/fb_base.h" -#include -#include // overrides QT_OPEN -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if !defined(Q_OS_DARWIN) && !defined(Q_OS_FREEBSD) -#include - -#ifdef __i386__ -#include -#endif -#endif - -QT_BEGIN_NAMESPACE - -class QLinuxFbIntegrationPrivate -{ -public: - QLinuxFbIntegrationPrivate(); - ~QLinuxFbIntegrationPrivate(); - - void openTty(); - void closeTty(); - - int fd; - int startupw; - int startuph; - int startupd; - bool blank; - - bool doGraphicsMode; -#ifdef QT_QWS_DEPTH_GENERIC - bool doGenericColors; -#endif - int ttyfd; - long oldKdMode; - QString ttyDevice; - QString displaySpec; -}; - -QLinuxFbIntegrationPrivate::QLinuxFbIntegrationPrivate() - : fd(-1), blank(true), doGraphicsMode(true), -#ifdef QT_QWS_DEPTH_GENERIC - doGenericColors(false), -#endif - ttyfd(-1), oldKdMode(KD_TEXT) -{ -} - -QLinuxFbIntegrationPrivate::~QLinuxFbIntegrationPrivate() -{ - closeTty(); -} - -void QLinuxFbIntegrationPrivate::openTty() -{ - const char *const devs[] = {"/dev/tty0", "/dev/tty", "/dev/console", 0}; - - if (ttyDevice.isEmpty()) { - for (const char * const *dev = devs; *dev; ++dev) { - ttyfd = QT_OPEN(*dev, O_RDWR); - if (ttyfd != -1) - break; - } - } else { - ttyfd = QT_OPEN(ttyDevice.toAscii().constData(), O_RDWR); - } - - if (ttyfd == -1) - return; - - if (doGraphicsMode) { - ioctl(ttyfd, KDGETMODE, &oldKdMode); - if (oldKdMode != KD_GRAPHICS) { - int ret = ioctl(ttyfd, KDSETMODE, KD_GRAPHICS); - if (ret == -1) - doGraphicsMode = false; - } - } - - // No blankin' screen, no blinkin' cursor!, no cursor! - const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c"; - QT_WRITE(ttyfd, termctl, sizeof(termctl)); -} - -void QLinuxFbIntegrationPrivate::closeTty() -{ - if (ttyfd == -1) - return; - - if (doGraphicsMode) - ioctl(ttyfd, KDSETMODE, oldKdMode); - - // Blankin' screen, blinkin' cursor! - const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c"; - QT_WRITE(ttyfd, termctl, sizeof(termctl)); - - QT_CLOSE(ttyfd); - ttyfd = -1; -} - -QLinuxFbIntegration::QLinuxFbIntegration() -{ - d_ptr = new QLinuxFbIntegrationPrivate(); - - // XXX - QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY")); - - if (!connect(displaySpec)) - qFatal("QLinuxFbIntegration: could not initialize screen"); - initDevice(); - - // Create a QImage directly on the screen's framebuffer. - // This is the blit target for copying windows to the screen. - mPrimaryScreen = new QLinuxFbScreen(data, w, h, lstep, - screenFormat); - mPrimaryScreen->setPhysicalSize(QSize(physWidth, physHeight)); - mScreens.append(mPrimaryScreen); -} - -QLinuxFbIntegration::~QLinuxFbIntegration() -{ - delete mPrimaryScreen; - delete d_ptr; -} - -bool QLinuxFbIntegration::connect(const QString &displaySpec) -{ - const QStringList args = displaySpec.split(QLatin1Char(':')); - - if (args.contains(QLatin1String("nographicsmodeswitch"))) - d_ptr->doGraphicsMode = false; - -#ifdef QT_QWS_DEPTH_GENERIC - if (args.contains(QLatin1String("genericcolors"))) - d_ptr->doGenericColors = true; -#endif - - QRegExp ttyRegExp(QLatin1String("tty=(.*)")); - if (args.indexOf(ttyRegExp) != -1) - d_ptr->ttyDevice = ttyRegExp.cap(1); - -#if 0 -#if Q_BYTE_ORDER == Q_BIG_ENDIAN -#ifndef QT_QWS_FRAMEBUFFER_LITTLE_ENDIAN - if (args.contains(QLatin1String("littleendian"))) -#endif - QScreen::setFrameBufferLittleEndian(true); -#endif -#endif - - // Check for explicitly specified device - const int len = 8; // "/dev/fbx" - int m = displaySpec.indexOf(QLatin1String("/dev/fb")); - - QString dev; - if (m > 0) - dev = displaySpec.mid(m, len); - else - dev = QLatin1String("/dev/fb0"); - - if (access(dev.toLatin1().constData(), R_OK|W_OK) == 0) - d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDWR); - if (d_ptr->fd == -1) { - if (access(dev.toLatin1().constData(), R_OK) == 0) - d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDONLY); - if (d_ptr->fd == 1) { - qWarning("Error opening framebuffer device %s", qPrintable(dev)); - return false; - } - } - - fb_fix_screeninfo finfo; - fb_var_screeninfo vinfo; - //####################### - // Shut up Valgrind - memset(&vinfo, 0, sizeof(vinfo)); - memset(&finfo, 0, sizeof(finfo)); - //####################### - - /* Get fixed screen information */ - if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) { - perror("QLinuxFbIntegration::connect"); - qWarning("Error reading fixed information"); - return false; - } - - if (finfo.type == FB_TYPE_VGA_PLANES) { - qWarning("VGA16 video mode not supported"); - return false; - } - - /* Get variable screen information */ - if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) { - perror("QLinuxFbIntegration::connect"); - qWarning("Error reading variable information"); - return false; - } - - grayscale = vinfo.grayscale; - d = vinfo.bits_per_pixel; - if (d == 24) { - d = vinfo.red.length + vinfo.green.length + vinfo.blue.length; - if (d <= 0) - d = 24; // reset if color component lengths are not reported - } else if (d == 16) { - d = vinfo.red.length + vinfo.green.length + vinfo.blue.length; - if (d <= 0) - d = 16; - } - lstep = finfo.line_length; - - int xoff = vinfo.xoffset; - int yoff = vinfo.yoffset; - const char* qwssize; - if((qwssize=::getenv("QWS_SIZE")) && sscanf(qwssize,"%dx%d",&w,&h)==2) { - if (d_ptr->fd != -1) { - if ((uint)w > vinfo.xres) w = vinfo.xres; - if ((uint)h > vinfo.yres) h = vinfo.yres; - } - dw=w; - dh=h; - int xxoff, yyoff; - if (sscanf(qwssize, "%*dx%*d+%d+%d", &xxoff, &yyoff) == 2) { - if (xxoff < 0 || xxoff + w > (int)(vinfo.xres)) - xxoff = vinfo.xres - w; - if (yyoff < 0 || yyoff + h > (int)(vinfo.yres)) - yyoff = vinfo.yres - h; - xoff += xxoff; - yoff += yyoff; - } else { - xoff += (vinfo.xres - w)/2; - yoff += (vinfo.yres - h)/2; - } - } else { - dw=w=vinfo.xres; - dh=h=vinfo.yres; - } - - if (w == 0 || h == 0) { - qWarning("QLinuxFbIntegration::connect(): Unable to find screen geometry, " - "will use 320x240."); - dw = w = 320; - dh = h = 240; - } - - setPixelFormat(vinfo); - - // Handle display physical size spec. - QStringList displayArgs = displaySpec.split(QLatin1Char(':')); - QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)")); - int dimIdxW = displayArgs.indexOf(mmWidthRx); - QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)")); - int dimIdxH = displayArgs.indexOf(mmHeightRx); - if (dimIdxW >= 0) { - mmWidthRx.exactMatch(displayArgs.at(dimIdxW)); - physWidth = mmWidthRx.cap(1).toInt(); - if (dimIdxH < 0) - physHeight = dh*physWidth/dw; - } - if (dimIdxH >= 0) { - mmHeightRx.exactMatch(displayArgs.at(dimIdxH)); - physHeight = mmHeightRx.cap(1).toInt(); - if (dimIdxW < 0) - physWidth = dw*physHeight/dh; - } - if (dimIdxW < 0 && dimIdxH < 0) { - if (vinfo.width != 0 && vinfo.height != 0 - && vinfo.width != UINT_MAX && vinfo.height != UINT_MAX) { - physWidth = vinfo.width; - physHeight = vinfo.height; - } else { - const int dpi = 72; - physWidth = qRound(dw * 25.4 / dpi); - physHeight = qRound(dh * 25.4 / dpi); - } - } - - dataoffset = yoff * lstep + xoff * d / 8; - //qDebug("Using %dx%dx%d screen",w,h,d); - - /* Figure out the size of the screen in bytes */ - size = h * lstep; - - mapsize = finfo.smem_len; - - data = (unsigned char *)-1; - if (d_ptr->fd != -1) - data = (unsigned char *)mmap(0, mapsize, PROT_READ | PROT_WRITE, - MAP_SHARED, d_ptr->fd, 0); - - if ((long)data == -1) { - perror("QLinuxFbIntegration::connect"); - qWarning("Error: failed to map framebuffer device to memory."); - return false; - } else { - data += dataoffset; - } - -#if 0 - canaccel = useOffscreen(); - if(canaccel) - setupOffScreen(); -#endif - canaccel = false; - - // Now read in palette - if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { - screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; - int loopc; - fb_cmap startcmap; - startcmap.start=0; - startcmap.len=screencols; - startcmap.red=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - startcmap.green=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - startcmap.blue=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - startcmap.transp=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - if (d_ptr->fd == -1 || ioctl(d_ptr->fd, FBIOGETCMAP, &startcmap)) { - perror("QLinuxFbIntegration::connect"); - qWarning("Error reading palette from framebuffer, using default palette"); - createPalette(startcmap, vinfo, finfo); - } - int bits_used = 0; - for(loopc=0;loopc> 8, - startcmap.green[loopc] >> 8, - startcmap.blue[loopc] >> 8); - bits_used |= startcmap.red[loopc] - | startcmap.green[loopc] - | startcmap.blue[loopc]; - } - // WORKAROUND: Some framebuffer drivers only return 8 bit - // color values, so we need to not bit shift them.. - if ((bits_used & 0x00ff) && !(bits_used & 0xff00)) { - for(loopc=0;loopcopenTty(); - - // Grab current mode so we can reset it - fb_var_screeninfo vinfo; - fb_fix_screeninfo finfo; - //####################### - // Shut up Valgrind - memset(&vinfo, 0, sizeof(vinfo)); - memset(&finfo, 0, sizeof(finfo)); - //####################### - - if (ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) { - perror("QLinuxFbScreen::initDevice"); - qFatal("Error reading variable information in card init"); - return false; - } - -#ifdef DEBUG_VINFO - qDebug("Greyscale %d",vinfo.grayscale); - qDebug("Nonstd %d",vinfo.nonstd); - qDebug("Red %d %d %d",vinfo.red.offset,vinfo.red.length, - vinfo.red.msb_right); - qDebug("Green %d %d %d",vinfo.green.offset,vinfo.green.length, - vinfo.green.msb_right); - qDebug("Blue %d %d %d",vinfo.blue.offset,vinfo.blue.length, - vinfo.blue.msb_right); - qDebug("Transparent %d %d %d",vinfo.transp.offset,vinfo.transp.length, - vinfo.transp.msb_right); -#endif - - d_ptr->startupw=vinfo.xres; - d_ptr->startuph=vinfo.yres; - d_ptr->startupd=vinfo.bits_per_pixel; - grayscale = vinfo.grayscale; - - if (ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) { - perror("QLinuxFbScreen::initDevice"); - qCritical("Error reading fixed information in card init"); - // It's not an /error/ as such, though definitely a bad sign - // so we return true - return true; - } - -#ifdef __i386__ - // Now init mtrr - if(!::getenv("QWS_NOMTRR")) { - int mfd=QT_OPEN("/proc/mtrr",O_WRONLY,0); - // MTRR entry goes away when file is closed - i.e. - // hopefully when QWS is killed - if(mfd != -1) { - mtrr_sentry sentry; - sentry.base=(unsigned long int)finfo.smem_start; - //qDebug("Physical framebuffer address %p",(void*)finfo.smem_start); - // Size needs to be in 4k chunks, but that's not always - // what we get thanks to graphics card registers. Write combining - // these is Not Good, so we write combine what we can - // (which is not much - 4 megs on an 8 meg card, it seems) - unsigned int size=finfo.smem_len; - size=size >> 22; - size=size << 22; - sentry.size=size; - sentry.type=MTRR_TYPE_WRCOMB; - if(ioctl(mfd,MTRRIOC_ADD_ENTRY,&sentry)==-1) { - //printf("Couldn't add mtrr entry for %lx %lx, %s\n", - //sentry.base,sentry.size,strerror(errno)); - } - } - - // Should we close mfd here? - //QT_CLOSE(mfd); - } -#endif - if ((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4) || (finfo.visual==FB_VISUAL_DIRECTCOLOR)) - { - fb_cmap cmap; - createPalette(cmap, vinfo, finfo); - if (ioctl(d_ptr->fd, FBIOPUTCMAP, &cmap)) { - perror("QLinuxFbScreen::initDevice"); - qWarning("Error writing palette to framebuffer"); - } - free(cmap.red); - free(cmap.green); - free(cmap.blue); - free(cmap.transp); - } - -#if 0 - if (canaccel) { - *entryp=0; - *lowest = mapsize; - insert_entry(*entryp, *lowest, *lowest); // dummy entry to mark start - } - - shared->fifocount = 0; - shared->buffer_offset = 0xffffffff; // 0 would be a sensible offset (screen) - shared->linestep = 0; - shared->cliptop = 0xffffffff; - shared->clipleft = 0xffffffff; - shared->clipright = 0xffffffff; - shared->clipbottom = 0xffffffff; - shared->rop = 0xffffffff; -#endif - -#ifdef QT_QWS_DEPTH_GENERIC - if (pixelFormat() == QImage::Format_Invalid && screencols == 0 - && d_ptr->doGenericColors) - { - qt_set_generic_blit(this, vinfo.bits_per_pixel, - vinfo.red.length, vinfo.green.length, - vinfo.blue.length, vinfo.transp.length, - vinfo.red.offset, vinfo.green.offset, - vinfo.blue.offset, vinfo.transp.offset); - } -#endif - -#if 0 -#ifndef QT_NO_QWS_CURSOR - QScreenCursor::initSoftwareCursor(); -#endif -#endif - blank(false); - - return true; -} - -void QLinuxFbIntegration::setPixelFormat(struct fb_var_screeninfo info) -{ - const fb_bitfield rgba[4] = { info.red, info.green, - info.blue, info.transp }; - - QImage::Format format = QImage::Format_Invalid; - - switch (d) { - case 32: { - const fb_bitfield argb8888[4] = {{16, 8, 0}, {8, 8, 0}, - {0, 8, 0}, {24, 8, 0}}; - const fb_bitfield abgr8888[4] = {{0, 8, 0}, {8, 8, 0}, - {16, 8, 0}, {24, 8, 0}}; - if (memcmp(rgba, argb8888, 4 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_ARGB32; - } else if (memcmp(rgba, argb8888, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB32; - } else if (memcmp(rgba, abgr8888, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB32; - pixeltype = BGRPixel; - } - break; - } - case 24: { - const fb_bitfield rgb888[4] = {{16, 8, 0}, {8, 8, 0}, - {0, 8, 0}, {0, 0, 0}}; - const fb_bitfield bgr888[4] = {{0, 8, 0}, {8, 8, 0}, - {16, 8, 0}, {0, 0, 0}}; - if (memcmp(rgba, rgb888, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB888; - } else if (memcmp(rgba, bgr888, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB888; - pixeltype = BGRPixel; - } - break; - } - case 18: { - const fb_bitfield rgb666[4] = {{12, 6, 0}, {6, 6, 0}, - {0, 6, 0}, {0, 0, 0}}; - if (memcmp(rgba, rgb666, 3 * sizeof(fb_bitfield)) == 0) - format = QImage::Format_RGB666; - break; - } - case 16: { - const fb_bitfield rgb565[4] = {{11, 5, 0}, {5, 6, 0}, - {0, 5, 0}, {0, 0, 0}}; - const fb_bitfield bgr565[4] = {{0, 5, 0}, {5, 6, 0}, - {11, 5, 0}, {0, 0, 0}}; - if (memcmp(rgba, rgb565, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB16; - } else if (memcmp(rgba, bgr565, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB16; - pixeltype = BGRPixel; - } - break; - } - case 15: { - const fb_bitfield rgb1555[4] = {{10, 5, 0}, {5, 5, 0}, - {0, 5, 0}, {15, 1, 0}}; - const fb_bitfield bgr1555[4] = {{0, 5, 0}, {5, 5, 0}, - {10, 5, 0}, {15, 1, 0}}; - if (memcmp(rgba, rgb1555, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB555; - } else if (memcmp(rgba, bgr1555, 3 * sizeof(fb_bitfield)) == 0) { - format = QImage::Format_RGB555; - pixeltype = BGRPixel; - } - break; - } - case 12: { - const fb_bitfield rgb444[4] = {{8, 4, 0}, {4, 4, 0}, - {0, 4, 0}, {0, 0, 0}}; - if (memcmp(rgba, rgb444, 3 * sizeof(fb_bitfield)) == 0) - format = QImage::Format_RGB444; - break; - } - case 8: - break; - case 1: - format = QImage::Format_Mono; //###: LSB??? - break; - default: - break; - } - - screenFormat = format; -} - -void QLinuxFbIntegration::createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo) -{ - if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { - screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; - cmap.start=0; - cmap.len=screencols; - cmap.red=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - cmap.green=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - cmap.blue=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - cmap.transp=(unsigned short int *) - malloc(sizeof(unsigned short int)*screencols); - - if (screencols==16) { - if (finfo.type == FB_TYPE_PACKED_PIXELS) { - // We'll setup a grayscale cmap for 4bpp linear - int val = 0; - for (int idx = 0; idx < 16; ++idx, val += 17) { - cmap.red[idx] = (val<<8)|val; - cmap.green[idx] = (val<<8)|val; - cmap.blue[idx] = (val<<8)|val; - screenclut[idx]=qRgb(val, val, val); - } - } else { - // Default 16 colour palette - // Green is now trolltech green so certain images look nicer - // black d_gray l_gray white red green blue cyan magenta yellow - unsigned char reds[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0xFF, 0xA2, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x82 }; - unsigned char greens[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0xC5, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F }; - unsigned char blues[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0x11, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00 }; - - for (int idx = 0; idx < 16; ++idx) { - cmap.red[idx] = ((reds[idx]) << 8)|reds[idx]; - cmap.green[idx] = ((greens[idx]) << 8)|greens[idx]; - cmap.blue[idx] = ((blues[idx]) << 8)|blues[idx]; - cmap.transp[idx] = 0; - screenclut[idx]=qRgb(reds[idx], greens[idx], blues[idx]); - } - } - } else { - if (grayscale) { - // Build grayscale palette - int i; - for(i=0;iblank == on) - return; - -#if defined(QT_QWS_IPAQ) - if (on) - system("apm -suspend"); -#else - if (d_ptr->fd == -1) - return; -// Some old kernel versions don't have this. These defines should go -// away eventually -#if defined(FBIOBLANK) -#if defined(VESA_POWERDOWN) && defined(VESA_NO_BLANKING) - ioctl(d_ptr->fd, FBIOBLANK, on ? VESA_POWERDOWN : VESA_NO_BLANKING); -#else - ioctl(d_ptr->fd, FBIOBLANK, on ? 1 : 0); -#endif -#endif -#endif - - d_ptr->blank = on; -} - -QPixmapData *QLinuxFbIntegration::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -QWindowSurface *QLinuxFbIntegration::createWindowSurface(QWidget *widget, WId) const -{ - QFbWindowSurface * surface = - new QFbWindowSurface(mPrimaryScreen, widget); - return surface; -} - -QPlatformWindow *QLinuxFbIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const -{ - QFbWindow *w = new QFbWindow(mPrimaryScreen, widget); - mPrimaryScreen->addWindow(w); - return w; -} - -QLinuxFbScreen::QLinuxFbScreen(uchar * d, int w, - int h, int lstep, QImage::Format screenFormat) : compositePainter(0) -{ - data = d; - mGeometry = QRect(0,0,w,h); - bytesPerLine = lstep; - mFormat = screenFormat; - mDepth = 16; - mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), - mFormat); - mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), - bytesPerLine, mFormat); - cursor = new QGraphicsSystemSoftwareCursor(this); -} - -void QLinuxFbScreen::setGeometry(QRect rect) -{ - mGeometry = rect; - delete mFbScreenImage; - mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), - bytesPerLine, mFormat); - delete compositePainter; - compositePainter = 0; - - delete mScreenImage; - mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), - mFormat); -} - -void QLinuxFbScreen::setFormat(QImage::Format format) -{ - mFormat = format; - delete mFbScreenImage; - mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), - bytesPerLine, mFormat); - delete compositePainter; - compositePainter = 0; - - delete mScreenImage; - mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), - mFormat); -} - -QRegion QLinuxFbScreen::doRedraw() -{ - QRegion touched; - touched = QFbScreen::doRedraw(); - - if (!compositePainter) { - compositePainter = new QPainter(mFbScreenImage); - } - - QVector rects = touched.rects(); - for (int i = 0; i < rects.size(); i++) - compositePainter->drawImage(rects[i], *mScreenImage, rects[i]); - return touched; -} -QT_END_NAMESPACE diff --git a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h b/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h deleted file mode 100644 index dc61df5..0000000 --- a/src/plugins/platforms/linuxfb/qgraphicssystem_linuxfb.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_LINUXFB_H -#define QGRAPHICSSYSTEM_LINUXFB_H - -#include -#include "../fb_base/fb_base.h" - -QT_BEGIN_NAMESPACE - -class QLinuxFbScreen : public QFbScreen -{ -public: - QLinuxFbScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat); - void setGeometry(QRect rect); - void setFormat(QImage::Format format); - -public slots: - QRegion doRedraw(); - -private: - QImage * mFbScreenImage; - uchar * data; - int bytesPerLine; - - QPainter *compositePainter; -}; - -class QLinuxFbIntegrationPrivate; -struct fb_cmap; -struct fb_var_screeninfo; -struct fb_fix_screeninfo; - -class QLinuxFbIntegration : public QPlatformIntegration -{ -public: - QLinuxFbIntegration(); - ~QLinuxFbIntegration(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QPlatformWindow *createPlatformWindow(QWidget *widget, WId WinId) const; - QWindowSurface *createWindowSurface(QWidget *widget, WId WinId) const; - - QList screens() const { return mScreens; } - -private: - QLinuxFbScreen *mPrimaryScreen; - QList mScreens; - QLinuxFbIntegrationPrivate *d_ptr; - - enum PixelType { NormalPixel, BGRPixel }; - - QRgb screenclut[256]; - int screencols; - - uchar * data; - - QImage::Format screenFormat; - int w; - int lstep; - int h; - int d; - PixelType pixeltype; - bool grayscale; - - int dw; - int dh; - - int size; // Screen size - int mapsize; // Total mapped memory - - int displayId; - - int physWidth; - int physHeight; - - bool canaccel; - int dataoffset; - int cacheStart; - - bool connect(const QString &displaySpec); - bool initDevice(); - void setPixelFormat(struct fb_var_screeninfo); - void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo); - void blank(bool on); -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp new file mode 100644 index 0000000..391e105 --- /dev/null +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp @@ -0,0 +1,859 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qlinuxfbintegration.h" +#include "../fb_base/fb_base.h" +#include +#include // overrides QT_OPEN +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if !defined(Q_OS_DARWIN) && !defined(Q_OS_FREEBSD) +#include + +#ifdef __i386__ +#include +#endif +#endif + +QT_BEGIN_NAMESPACE + +class QLinuxFbIntegrationPrivate +{ +public: + QLinuxFbIntegrationPrivate(); + ~QLinuxFbIntegrationPrivate(); + + void openTty(); + void closeTty(); + + int fd; + int startupw; + int startuph; + int startupd; + bool blank; + + bool doGraphicsMode; +#ifdef QT_QWS_DEPTH_GENERIC + bool doGenericColors; +#endif + int ttyfd; + long oldKdMode; + QString ttyDevice; + QString displaySpec; +}; + +QLinuxFbIntegrationPrivate::QLinuxFbIntegrationPrivate() + : fd(-1), blank(true), doGraphicsMode(true), +#ifdef QT_QWS_DEPTH_GENERIC + doGenericColors(false), +#endif + ttyfd(-1), oldKdMode(KD_TEXT) +{ +} + +QLinuxFbIntegrationPrivate::~QLinuxFbIntegrationPrivate() +{ + closeTty(); +} + +void QLinuxFbIntegrationPrivate::openTty() +{ + const char *const devs[] = {"/dev/tty0", "/dev/tty", "/dev/console", 0}; + + if (ttyDevice.isEmpty()) { + for (const char * const *dev = devs; *dev; ++dev) { + ttyfd = QT_OPEN(*dev, O_RDWR); + if (ttyfd != -1) + break; + } + } else { + ttyfd = QT_OPEN(ttyDevice.toAscii().constData(), O_RDWR); + } + + if (ttyfd == -1) + return; + + if (doGraphicsMode) { + ioctl(ttyfd, KDGETMODE, &oldKdMode); + if (oldKdMode != KD_GRAPHICS) { + int ret = ioctl(ttyfd, KDSETMODE, KD_GRAPHICS); + if (ret == -1) + doGraphicsMode = false; + } + } + + // No blankin' screen, no blinkin' cursor!, no cursor! + const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c"; + QT_WRITE(ttyfd, termctl, sizeof(termctl)); +} + +void QLinuxFbIntegrationPrivate::closeTty() +{ + if (ttyfd == -1) + return; + + if (doGraphicsMode) + ioctl(ttyfd, KDSETMODE, oldKdMode); + + // Blankin' screen, blinkin' cursor! + const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c"; + QT_WRITE(ttyfd, termctl, sizeof(termctl)); + + QT_CLOSE(ttyfd); + ttyfd = -1; +} + +QLinuxFbIntegration::QLinuxFbIntegration() +{ + d_ptr = new QLinuxFbIntegrationPrivate(); + + // XXX + QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY")); + + if (!connect(displaySpec)) + qFatal("QLinuxFbIntegration: could not initialize screen"); + initDevice(); + + // Create a QImage directly on the screen's framebuffer. + // This is the blit target for copying windows to the screen. + mPrimaryScreen = new QLinuxFbScreen(data, w, h, lstep, + screenFormat); + mPrimaryScreen->setPhysicalSize(QSize(physWidth, physHeight)); + mScreens.append(mPrimaryScreen); +} + +QLinuxFbIntegration::~QLinuxFbIntegration() +{ + delete mPrimaryScreen; + delete d_ptr; +} + +bool QLinuxFbIntegration::connect(const QString &displaySpec) +{ + const QStringList args = displaySpec.split(QLatin1Char(':')); + + if (args.contains(QLatin1String("nographicsmodeswitch"))) + d_ptr->doGraphicsMode = false; + +#ifdef QT_QWS_DEPTH_GENERIC + if (args.contains(QLatin1String("genericcolors"))) + d_ptr->doGenericColors = true; +#endif + + QRegExp ttyRegExp(QLatin1String("tty=(.*)")); + if (args.indexOf(ttyRegExp) != -1) + d_ptr->ttyDevice = ttyRegExp.cap(1); + +#if 0 +#if Q_BYTE_ORDER == Q_BIG_ENDIAN +#ifndef QT_QWS_FRAMEBUFFER_LITTLE_ENDIAN + if (args.contains(QLatin1String("littleendian"))) +#endif + QScreen::setFrameBufferLittleEndian(true); +#endif +#endif + + // Check for explicitly specified device + const int len = 8; // "/dev/fbx" + int m = displaySpec.indexOf(QLatin1String("/dev/fb")); + + QString dev; + if (m > 0) + dev = displaySpec.mid(m, len); + else + dev = QLatin1String("/dev/fb0"); + + if (access(dev.toLatin1().constData(), R_OK|W_OK) == 0) + d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDWR); + if (d_ptr->fd == -1) { + if (access(dev.toLatin1().constData(), R_OK) == 0) + d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDONLY); + if (d_ptr->fd == 1) { + qWarning("Error opening framebuffer device %s", qPrintable(dev)); + return false; + } + } + + fb_fix_screeninfo finfo; + fb_var_screeninfo vinfo; + //####################### + // Shut up Valgrind + memset(&vinfo, 0, sizeof(vinfo)); + memset(&finfo, 0, sizeof(finfo)); + //####################### + + /* Get fixed screen information */ + if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) { + perror("QLinuxFbIntegration::connect"); + qWarning("Error reading fixed information"); + return false; + } + + if (finfo.type == FB_TYPE_VGA_PLANES) { + qWarning("VGA16 video mode not supported"); + return false; + } + + /* Get variable screen information */ + if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) { + perror("QLinuxFbIntegration::connect"); + qWarning("Error reading variable information"); + return false; + } + + grayscale = vinfo.grayscale; + d = vinfo.bits_per_pixel; + if (d == 24) { + d = vinfo.red.length + vinfo.green.length + vinfo.blue.length; + if (d <= 0) + d = 24; // reset if color component lengths are not reported + } else if (d == 16) { + d = vinfo.red.length + vinfo.green.length + vinfo.blue.length; + if (d <= 0) + d = 16; + } + lstep = finfo.line_length; + + int xoff = vinfo.xoffset; + int yoff = vinfo.yoffset; + const char* qwssize; + if((qwssize=::getenv("QWS_SIZE")) && sscanf(qwssize,"%dx%d",&w,&h)==2) { + if (d_ptr->fd != -1) { + if ((uint)w > vinfo.xres) w = vinfo.xres; + if ((uint)h > vinfo.yres) h = vinfo.yres; + } + dw=w; + dh=h; + int xxoff, yyoff; + if (sscanf(qwssize, "%*dx%*d+%d+%d", &xxoff, &yyoff) == 2) { + if (xxoff < 0 || xxoff + w > (int)(vinfo.xres)) + xxoff = vinfo.xres - w; + if (yyoff < 0 || yyoff + h > (int)(vinfo.yres)) + yyoff = vinfo.yres - h; + xoff += xxoff; + yoff += yyoff; + } else { + xoff += (vinfo.xres - w)/2; + yoff += (vinfo.yres - h)/2; + } + } else { + dw=w=vinfo.xres; + dh=h=vinfo.yres; + } + + if (w == 0 || h == 0) { + qWarning("QLinuxFbIntegration::connect(): Unable to find screen geometry, " + "will use 320x240."); + dw = w = 320; + dh = h = 240; + } + + setPixelFormat(vinfo); + + // Handle display physical size spec. + QStringList displayArgs = displaySpec.split(QLatin1Char(':')); + QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)")); + int dimIdxW = displayArgs.indexOf(mmWidthRx); + QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)")); + int dimIdxH = displayArgs.indexOf(mmHeightRx); + if (dimIdxW >= 0) { + mmWidthRx.exactMatch(displayArgs.at(dimIdxW)); + physWidth = mmWidthRx.cap(1).toInt(); + if (dimIdxH < 0) + physHeight = dh*physWidth/dw; + } + if (dimIdxH >= 0) { + mmHeightRx.exactMatch(displayArgs.at(dimIdxH)); + physHeight = mmHeightRx.cap(1).toInt(); + if (dimIdxW < 0) + physWidth = dw*physHeight/dh; + } + if (dimIdxW < 0 && dimIdxH < 0) { + if (vinfo.width != 0 && vinfo.height != 0 + && vinfo.width != UINT_MAX && vinfo.height != UINT_MAX) { + physWidth = vinfo.width; + physHeight = vinfo.height; + } else { + const int dpi = 72; + physWidth = qRound(dw * 25.4 / dpi); + physHeight = qRound(dh * 25.4 / dpi); + } + } + + dataoffset = yoff * lstep + xoff * d / 8; + //qDebug("Using %dx%dx%d screen",w,h,d); + + /* Figure out the size of the screen in bytes */ + size = h * lstep; + + mapsize = finfo.smem_len; + + data = (unsigned char *)-1; + if (d_ptr->fd != -1) + data = (unsigned char *)mmap(0, mapsize, PROT_READ | PROT_WRITE, + MAP_SHARED, d_ptr->fd, 0); + + if ((long)data == -1) { + perror("QLinuxFbIntegration::connect"); + qWarning("Error: failed to map framebuffer device to memory."); + return false; + } else { + data += dataoffset; + } + +#if 0 + canaccel = useOffscreen(); + if(canaccel) + setupOffScreen(); +#endif + canaccel = false; + + // Now read in palette + if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { + screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; + int loopc; + fb_cmap startcmap; + startcmap.start=0; + startcmap.len=screencols; + startcmap.red=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + startcmap.green=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + startcmap.blue=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + startcmap.transp=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + if (d_ptr->fd == -1 || ioctl(d_ptr->fd, FBIOGETCMAP, &startcmap)) { + perror("QLinuxFbIntegration::connect"); + qWarning("Error reading palette from framebuffer, using default palette"); + createPalette(startcmap, vinfo, finfo); + } + int bits_used = 0; + for(loopc=0;loopc> 8, + startcmap.green[loopc] >> 8, + startcmap.blue[loopc] >> 8); + bits_used |= startcmap.red[loopc] + | startcmap.green[loopc] + | startcmap.blue[loopc]; + } + // WORKAROUND: Some framebuffer drivers only return 8 bit + // color values, so we need to not bit shift them.. + if ((bits_used & 0x00ff) && !(bits_used & 0xff00)) { + for(loopc=0;loopcopenTty(); + + // Grab current mode so we can reset it + fb_var_screeninfo vinfo; + fb_fix_screeninfo finfo; + //####################### + // Shut up Valgrind + memset(&vinfo, 0, sizeof(vinfo)); + memset(&finfo, 0, sizeof(finfo)); + //####################### + + if (ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) { + perror("QLinuxFbScreen::initDevice"); + qFatal("Error reading variable information in card init"); + return false; + } + +#ifdef DEBUG_VINFO + qDebug("Greyscale %d",vinfo.grayscale); + qDebug("Nonstd %d",vinfo.nonstd); + qDebug("Red %d %d %d",vinfo.red.offset,vinfo.red.length, + vinfo.red.msb_right); + qDebug("Green %d %d %d",vinfo.green.offset,vinfo.green.length, + vinfo.green.msb_right); + qDebug("Blue %d %d %d",vinfo.blue.offset,vinfo.blue.length, + vinfo.blue.msb_right); + qDebug("Transparent %d %d %d",vinfo.transp.offset,vinfo.transp.length, + vinfo.transp.msb_right); +#endif + + d_ptr->startupw=vinfo.xres; + d_ptr->startuph=vinfo.yres; + d_ptr->startupd=vinfo.bits_per_pixel; + grayscale = vinfo.grayscale; + + if (ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) { + perror("QLinuxFbScreen::initDevice"); + qCritical("Error reading fixed information in card init"); + // It's not an /error/ as such, though definitely a bad sign + // so we return true + return true; + } + +#ifdef __i386__ + // Now init mtrr + if(!::getenv("QWS_NOMTRR")) { + int mfd=QT_OPEN("/proc/mtrr",O_WRONLY,0); + // MTRR entry goes away when file is closed - i.e. + // hopefully when QWS is killed + if(mfd != -1) { + mtrr_sentry sentry; + sentry.base=(unsigned long int)finfo.smem_start; + //qDebug("Physical framebuffer address %p",(void*)finfo.smem_start); + // Size needs to be in 4k chunks, but that's not always + // what we get thanks to graphics card registers. Write combining + // these is Not Good, so we write combine what we can + // (which is not much - 4 megs on an 8 meg card, it seems) + unsigned int size=finfo.smem_len; + size=size >> 22; + size=size << 22; + sentry.size=size; + sentry.type=MTRR_TYPE_WRCOMB; + if(ioctl(mfd,MTRRIOC_ADD_ENTRY,&sentry)==-1) { + //printf("Couldn't add mtrr entry for %lx %lx, %s\n", + //sentry.base,sentry.size,strerror(errno)); + } + } + + // Should we close mfd here? + //QT_CLOSE(mfd); + } +#endif + if ((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4) || (finfo.visual==FB_VISUAL_DIRECTCOLOR)) + { + fb_cmap cmap; + createPalette(cmap, vinfo, finfo); + if (ioctl(d_ptr->fd, FBIOPUTCMAP, &cmap)) { + perror("QLinuxFbScreen::initDevice"); + qWarning("Error writing palette to framebuffer"); + } + free(cmap.red); + free(cmap.green); + free(cmap.blue); + free(cmap.transp); + } + +#if 0 + if (canaccel) { + *entryp=0; + *lowest = mapsize; + insert_entry(*entryp, *lowest, *lowest); // dummy entry to mark start + } + + shared->fifocount = 0; + shared->buffer_offset = 0xffffffff; // 0 would be a sensible offset (screen) + shared->linestep = 0; + shared->cliptop = 0xffffffff; + shared->clipleft = 0xffffffff; + shared->clipright = 0xffffffff; + shared->clipbottom = 0xffffffff; + shared->rop = 0xffffffff; +#endif + +#ifdef QT_QWS_DEPTH_GENERIC + if (pixelFormat() == QImage::Format_Invalid && screencols == 0 + && d_ptr->doGenericColors) + { + qt_set_generic_blit(this, vinfo.bits_per_pixel, + vinfo.red.length, vinfo.green.length, + vinfo.blue.length, vinfo.transp.length, + vinfo.red.offset, vinfo.green.offset, + vinfo.blue.offset, vinfo.transp.offset); + } +#endif + +#if 0 +#ifndef QT_NO_QWS_CURSOR + QScreenCursor::initSoftwareCursor(); +#endif +#endif + blank(false); + + return true; +} + +void QLinuxFbIntegration::setPixelFormat(struct fb_var_screeninfo info) +{ + const fb_bitfield rgba[4] = { info.red, info.green, + info.blue, info.transp }; + + QImage::Format format = QImage::Format_Invalid; + + switch (d) { + case 32: { + const fb_bitfield argb8888[4] = {{16, 8, 0}, {8, 8, 0}, + {0, 8, 0}, {24, 8, 0}}; + const fb_bitfield abgr8888[4] = {{0, 8, 0}, {8, 8, 0}, + {16, 8, 0}, {24, 8, 0}}; + if (memcmp(rgba, argb8888, 4 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_ARGB32; + } else if (memcmp(rgba, argb8888, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB32; + } else if (memcmp(rgba, abgr8888, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB32; + pixeltype = BGRPixel; + } + break; + } + case 24: { + const fb_bitfield rgb888[4] = {{16, 8, 0}, {8, 8, 0}, + {0, 8, 0}, {0, 0, 0}}; + const fb_bitfield bgr888[4] = {{0, 8, 0}, {8, 8, 0}, + {16, 8, 0}, {0, 0, 0}}; + if (memcmp(rgba, rgb888, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB888; + } else if (memcmp(rgba, bgr888, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB888; + pixeltype = BGRPixel; + } + break; + } + case 18: { + const fb_bitfield rgb666[4] = {{12, 6, 0}, {6, 6, 0}, + {0, 6, 0}, {0, 0, 0}}; + if (memcmp(rgba, rgb666, 3 * sizeof(fb_bitfield)) == 0) + format = QImage::Format_RGB666; + break; + } + case 16: { + const fb_bitfield rgb565[4] = {{11, 5, 0}, {5, 6, 0}, + {0, 5, 0}, {0, 0, 0}}; + const fb_bitfield bgr565[4] = {{0, 5, 0}, {5, 6, 0}, + {11, 5, 0}, {0, 0, 0}}; + if (memcmp(rgba, rgb565, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB16; + } else if (memcmp(rgba, bgr565, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB16; + pixeltype = BGRPixel; + } + break; + } + case 15: { + const fb_bitfield rgb1555[4] = {{10, 5, 0}, {5, 5, 0}, + {0, 5, 0}, {15, 1, 0}}; + const fb_bitfield bgr1555[4] = {{0, 5, 0}, {5, 5, 0}, + {10, 5, 0}, {15, 1, 0}}; + if (memcmp(rgba, rgb1555, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB555; + } else if (memcmp(rgba, bgr1555, 3 * sizeof(fb_bitfield)) == 0) { + format = QImage::Format_RGB555; + pixeltype = BGRPixel; + } + break; + } + case 12: { + const fb_bitfield rgb444[4] = {{8, 4, 0}, {4, 4, 0}, + {0, 4, 0}, {0, 0, 0}}; + if (memcmp(rgba, rgb444, 3 * sizeof(fb_bitfield)) == 0) + format = QImage::Format_RGB444; + break; + } + case 8: + break; + case 1: + format = QImage::Format_Mono; //###: LSB??? + break; + default: + break; + } + + screenFormat = format; +} + +void QLinuxFbIntegration::createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo) +{ + if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { + screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; + cmap.start=0; + cmap.len=screencols; + cmap.red=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + cmap.green=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + cmap.blue=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + cmap.transp=(unsigned short int *) + malloc(sizeof(unsigned short int)*screencols); + + if (screencols==16) { + if (finfo.type == FB_TYPE_PACKED_PIXELS) { + // We'll setup a grayscale cmap for 4bpp linear + int val = 0; + for (int idx = 0; idx < 16; ++idx, val += 17) { + cmap.red[idx] = (val<<8)|val; + cmap.green[idx] = (val<<8)|val; + cmap.blue[idx] = (val<<8)|val; + screenclut[idx]=qRgb(val, val, val); + } + } else { + // Default 16 colour palette + // Green is now trolltech green so certain images look nicer + // black d_gray l_gray white red green blue cyan magenta yellow + unsigned char reds[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0xFF, 0xA2, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x82 }; + unsigned char greens[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0xC5, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F }; + unsigned char blues[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0x11, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00 }; + + for (int idx = 0; idx < 16; ++idx) { + cmap.red[idx] = ((reds[idx]) << 8)|reds[idx]; + cmap.green[idx] = ((greens[idx]) << 8)|greens[idx]; + cmap.blue[idx] = ((blues[idx]) << 8)|blues[idx]; + cmap.transp[idx] = 0; + screenclut[idx]=qRgb(reds[idx], greens[idx], blues[idx]); + } + } + } else { + if (grayscale) { + // Build grayscale palette + int i; + for(i=0;iblank == on) + return; + +#if defined(QT_QWS_IPAQ) + if (on) + system("apm -suspend"); +#else + if (d_ptr->fd == -1) + return; +// Some old kernel versions don't have this. These defines should go +// away eventually +#if defined(FBIOBLANK) +#if defined(VESA_POWERDOWN) && defined(VESA_NO_BLANKING) + ioctl(d_ptr->fd, FBIOBLANK, on ? VESA_POWERDOWN : VESA_NO_BLANKING); +#else + ioctl(d_ptr->fd, FBIOBLANK, on ? 1 : 0); +#endif +#endif +#endif + + d_ptr->blank = on; +} + +QPixmapData *QLinuxFbIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QLinuxFbIntegration::createWindowSurface(QWidget *widget, WId) const +{ + QFbWindowSurface * surface = + new QFbWindowSurface(mPrimaryScreen, widget); + return surface; +} + +QPlatformWindow *QLinuxFbIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const +{ + QFbWindow *w = new QFbWindow(mPrimaryScreen, widget); + mPrimaryScreen->addWindow(w); + return w; +} + +QLinuxFbScreen::QLinuxFbScreen(uchar * d, int w, + int h, int lstep, QImage::Format screenFormat) : compositePainter(0) +{ + data = d; + mGeometry = QRect(0,0,w,h); + bytesPerLine = lstep; + mFormat = screenFormat; + mDepth = 16; + mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), + mFormat); + mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), + bytesPerLine, mFormat); + cursor = new QGraphicsSystemSoftwareCursor(this); +} + +void QLinuxFbScreen::setGeometry(QRect rect) +{ + mGeometry = rect; + delete mFbScreenImage; + mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), + bytesPerLine, mFormat); + delete compositePainter; + compositePainter = 0; + + delete mScreenImage; + mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), + mFormat); +} + +void QLinuxFbScreen::setFormat(QImage::Format format) +{ + mFormat = format; + delete mFbScreenImage; + mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), + bytesPerLine, mFormat); + delete compositePainter; + compositePainter = 0; + + delete mScreenImage; + mScreenImage = new QImage(mGeometry.width(), mGeometry.height(), + mFormat); +} + +QRegion QLinuxFbScreen::doRedraw() +{ + QRegion touched; + touched = QFbScreen::doRedraw(); + + if (!compositePainter) { + compositePainter = new QPainter(mFbScreenImage); + } + + QVector rects = touched.rects(); + for (int i = 0; i < rects.size(); i++) + compositePainter->drawImage(rects[i], *mScreenImage, rects[i]); + return touched; +} +QT_END_NAMESPACE diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h new file mode 100644 index 0000000..dc61df5 --- /dev/null +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_LINUXFB_H +#define QGRAPHICSSYSTEM_LINUXFB_H + +#include +#include "../fb_base/fb_base.h" + +QT_BEGIN_NAMESPACE + +class QLinuxFbScreen : public QFbScreen +{ +public: + QLinuxFbScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat); + void setGeometry(QRect rect); + void setFormat(QImage::Format format); + +public slots: + QRegion doRedraw(); + +private: + QImage * mFbScreenImage; + uchar * data; + int bytesPerLine; + + QPainter *compositePainter; +}; + +class QLinuxFbIntegrationPrivate; +struct fb_cmap; +struct fb_var_screeninfo; +struct fb_fix_screeninfo; + +class QLinuxFbIntegration : public QPlatformIntegration +{ +public: + QLinuxFbIntegration(); + ~QLinuxFbIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId WinId) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId WinId) const; + + QList screens() const { return mScreens; } + +private: + QLinuxFbScreen *mPrimaryScreen; + QList mScreens; + QLinuxFbIntegrationPrivate *d_ptr; + + enum PixelType { NormalPixel, BGRPixel }; + + QRgb screenclut[256]; + int screencols; + + uchar * data; + + QImage::Format screenFormat; + int w; + int lstep; + int h; + int d; + PixelType pixeltype; + bool grayscale; + + int dw; + int dh; + + int size; // Screen size + int mapsize; // Total mapped memory + + int displayId; + + int physWidth; + int physHeight; + + bool canaccel; + int dataoffset; + int cacheStart; + + bool connect(const QString &displaySpec); + bool initDevice(); + void setPixelFormat(struct fb_var_screeninfo); + void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo); + void blank(bool on); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/minimal/main.cpp b/src/plugins/platforms/minimal/main.cpp index 44c274b..4958468 100644 --- a/src/plugins/platforms/minimal/main.cpp +++ b/src/plugins/platforms/minimal/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include -#include "qplatformintegration_minimal.h" +#include "qminimalintegration.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro index 6c97f07..438a88e 100644 --- a/src/plugins/platforms/minimal/minimal.pro +++ b/src/plugins/platforms/minimal/minimal.pro @@ -4,10 +4,10 @@ include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms SOURCES = main.cpp \ - qplatformintegration_minimal.cpp \ - qwindowsurface_minimal.cpp -HEADERS = qplatformintegration_minimal.h \ - qwindowsurface_minimal.h + qminimalintegration.cpp \ + qminimalwindowsurface.cpp +HEADERS = qminimalintegration.h \ + qminimalwindowsurface.h target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp new file mode 100644 index 0000000..e947bf1 --- /dev/null +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -0,0 +1,33 @@ +#include "qminimalintegration.h" +#include "qminimalwindowsurface.h" + +#include +#include + +QMinimalIntegration::QMinimalIntegration() +{ + QMinimalScreen *mPrimaryScreen = new QMinimalScreen(); + + mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320); + mPrimaryScreen->mDepth = 16; + mPrimaryScreen->mFormat = QImage::Format_RGB16; + + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QMinimalIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWidget *widget, WId winId) const +{ + Q_UNUSED(winId); + return new QPlatformWindow(widget); +} + +QWindowSurface *QMinimalIntegration::createWindowSurface(QWidget *widget, WId winId) const +{ + Q_UNUSED(winId); + return new QMinimalWindowSurface(widget); +} diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h new file mode 100644 index 0000000..a2f7449 --- /dev/null +++ b/src/plugins/platforms/minimal/qminimalintegration.h @@ -0,0 +1,85 @@ + +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMINTEGRATION_MINIMAL_H +#define QPLATFORMINTEGRATION_MINIMAL_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QMinimalScreen : public QPlatformScreen +{ +public: + QMinimalScreen() + : mDepth(16), mFormat(QImage::Format_RGB16) {} + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; +}; + +class QMinimalIntegration : public QPlatformIntegration +{ +public: + QMinimalIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + + QList screens() const { return mScreens; } + +private: + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/minimal/qminimalwindowsurface.cpp b/src/plugins/platforms/minimal/qminimalwindowsurface.cpp new file mode 100644 index 0000000..ad5997e --- /dev/null +++ b/src/plugins/platforms/minimal/qminimalwindowsurface.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qminimalwindowsurface.h" +#include +#include + +QT_BEGIN_NAMESPACE + +QMinimalWindowSurface::QMinimalWindowSurface(QWidget *window) + : QWindowSurface(window) +{ + //qDebug() << "QMinimalWindowSurface::QMinimalWindowSurface:" << (long)this; +} + +QMinimalWindowSurface::~QMinimalWindowSurface() +{ +} + +QPaintDevice *QMinimalWindowSurface::paintDevice() +{ + //qDebug() << "QMinimalWindowSurface::paintDevice"; + return &mImage; +} + +void QMinimalWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); + + static int c = 0; + QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0')); + qDebug() << "QMinimalWindowSurface::flush() saving contents to" << filename.toLocal8Bit().constData(); + mImage.save(filename); +} + +void QMinimalWindowSurface::resize(const QSize &size) +{ + //qDebug() << "QMinimalWindowSurface::setGeometry:" << (long)this << rect; + QWindowSurface::resize(size); + QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format(); + if (mImage.size() != size) + mImage = QImage(size, format); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimal/qminimalwindowsurface.h b/src/plugins/platforms/minimal/qminimalwindowsurface.h new file mode 100644 index 0000000..96f989d --- /dev/null +++ b/src/plugins/platforms/minimal/qminimalwindowsurface.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_MINIMAL_H +#define QWINDOWSURFACE_MINIMAL_H + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QMinimalWindowSurface : public QWindowSurface +{ +public: + QMinimalWindowSurface(QWidget *window); + ~QMinimalWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void resize(const QSize &size); + +private: + QImage mImage; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp deleted file mode 100644 index 73e025c..0000000 --- a/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "qplatformintegration_minimal.h" -#include "qwindowsurface_minimal.h" - -#include -#include - -QMinimalIntegration::QMinimalIntegration() -{ - QMinimalScreen *mPrimaryScreen = new QMinimalScreen(); - - mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320); - mPrimaryScreen->mDepth = 16; - mPrimaryScreen->mFormat = QImage::Format_RGB16; - - mScreens.append(mPrimaryScreen); -} - -QPixmapData *QMinimalIntegration::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWidget *widget, WId winId) const -{ - Q_UNUSED(winId); - return new QPlatformWindow(widget); -} - -QWindowSurface *QMinimalIntegration::createWindowSurface(QWidget *widget, WId winId) const -{ - Q_UNUSED(winId); - return new QMinimalWindowSurface(widget); -} diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.h b/src/plugins/platforms/minimal/qplatformintegration_minimal.h deleted file mode 100644 index a2f7449..0000000 --- a/src/plugins/platforms/minimal/qplatformintegration_minimal.h +++ /dev/null @@ -1,85 +0,0 @@ - -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPLATFORMINTEGRATION_MINIMAL_H -#define QPLATFORMINTEGRATION_MINIMAL_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QMinimalScreen : public QPlatformScreen -{ -public: - QMinimalScreen() - : mDepth(16), mFormat(QImage::Format_RGB16) {} - - QRect geometry() const { return mGeometry; } - int depth() const { return mDepth; } - QImage::Format format() const { return mFormat; } - -public: - QRect mGeometry; - int mDepth; - QImage::Format mFormat; - QSize mPhysicalSize; -}; - -class QMinimalIntegration : public QPlatformIntegration -{ -public: - QMinimalIntegration(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; - QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; - - QList screens() const { return mScreens; } - -private: - QList mScreens; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp b/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp deleted file mode 100644 index 2f8b1f0..0000000 --- a/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindowsurface_minimal.h" -#include -#include - -QT_BEGIN_NAMESPACE - -QMinimalWindowSurface::QMinimalWindowSurface(QWidget *window) - : QWindowSurface(window) -{ - //qDebug() << "QMinimalWindowSurface::QMinimalWindowSurface:" << (long)this; -} - -QMinimalWindowSurface::~QMinimalWindowSurface() -{ -} - -QPaintDevice *QMinimalWindowSurface::paintDevice() -{ - //qDebug() << "QMinimalWindowSurface::paintDevice"; - return &mImage; -} - -void QMinimalWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(region); - Q_UNUSED(offset); - - static int c = 0; - QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0')); - qDebug() << "QMinimalWindowSurface::flush() saving contents to" << filename.toLocal8Bit().constData(); - mImage.save(filename); -} - -void QMinimalWindowSurface::resize(const QSize &size) -{ - //qDebug() << "QMinimalWindowSurface::setGeometry:" << (long)this << rect; - QWindowSurface::resize(size); - QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format(); - if (mImage.size() != size) - mImage = QImage(size, format); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimal/qwindowsurface_minimal.h b/src/plugins/platforms/minimal/qwindowsurface_minimal.h deleted file mode 100644 index 96f989d..0000000 --- a/src/plugins/platforms/minimal/qwindowsurface_minimal.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_MINIMAL_H -#define QWINDOWSURFACE_MINIMAL_H - -#include - -#include - -QT_BEGIN_NAMESPACE - -class QMinimalWindowSurface : public QWindowSurface -{ -public: - QMinimalWindowSurface(QWidget *window); - ~QMinimalWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void resize(const QSize &size); - -private: - QImage mImage; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/qvfb/qvfb.pro b/src/plugins/platforms/qvfb/qvfb.pro index 4dec274..a560755 100644 --- a/src/plugins/platforms/qvfb/qvfb.pro +++ b/src/plugins/platforms/qvfb/qvfb.pro @@ -4,8 +4,8 @@ include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms -SOURCES = main.cpp qvfbintegration.cpp qwindowsurface_qvfb.cpp -HEADERS = qvfbintegration.h qwindowsurface_qvfb.h +SOURCES = main.cpp qvfbintegration.cpp qvfbwindowsurface.cpp +HEADERS = qvfbintegration.h qvfbwindowsurface.h target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/qvfb/qvfbintegration.cpp b/src/plugins/platforms/qvfb/qvfbintegration.cpp index e22c724..84ab9fb 100644 --- a/src/plugins/platforms/qvfb/qvfbintegration.cpp +++ b/src/plugins/platforms/qvfb/qvfbintegration.cpp @@ -53,7 +53,7 @@ #include #include "qvfbintegration.h" -#include "qwindowsurface_qvfb.h" +#include "qvfbwindowsurface.h" #include #include #include diff --git a/src/plugins/platforms/qvfb/qvfbwindowsurface.cpp b/src/plugins/platforms/qvfb/qvfbwindowsurface.cpp new file mode 100644 index 0000000..6699072 --- /dev/null +++ b/src/plugins/platforms/qvfb/qvfbwindowsurface.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qvfbwindowsurface.h" +#include "qvfbintegration.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QVFbWindowSurface::QVFbWindowSurface(//QVFbIntegration *graphicsSystem, + QVFbScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen) +{ +} + +QVFbWindowSurface::~QVFbWindowSurface() +{ +} + +QPaintDevice *QVFbWindowSurface::paintDevice() +{ + return mScreen->screenImage(); +} + +void QVFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(offset); + +// QRect rect = geometry(); +// QPoint topLeft = rect.topLeft(); + + mScreen->setDirty(region.boundingRect()); +} + +void QVFbWindowSurface::resize(const QSize&) +{ + +// any size you like as long as it's full-screen... + + QRect rect(mScreen->availableGeometry()); + QWindowSurface::resize(rect.size()); +} + + +QVFbWindow::QVFbWindow(QVFbScreen *screen, QWidget *window) + : QPlatformWindow(window), + mScreen(screen) +{ +} + + +void QVFbWindow::setGeometry(const QRect &) +{ + +// any size you like as long as it's full-screen... + + QRect rect(mScreen->availableGeometry()); + QWindowSystemInterface::handleGeometryChange(this->widget(), rect); + + QPlatformWindow::setGeometry(rect); +} + + + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/qvfb/qvfbwindowsurface.h b/src/plugins/platforms/qvfb/qvfbwindowsurface.h new file mode 100644 index 0000000..9228189 --- /dev/null +++ b/src/plugins/platforms/qvfb/qvfbwindowsurface.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_QVFB_H +#define QWINDOWSURFACE_QVFB_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QVFbIntegration; +class QVFbScreen; + +class QVFbWindowSurface : public QWindowSurface +{ +public: + QVFbWindowSurface(QVFbScreen *screen, QWidget *window); + ~QVFbWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void resize(const QSize &size); + +private: + QVFbScreen *mScreen; +}; + +class QVFbWindow : public QPlatformWindow +{ +public: + QVFbWindow(QVFbScreen *screen, QWidget *window); + void setGeometry(const QRect &rect); + +private: + QVFbScreen *mScreen; +}; + + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp deleted file mode 100644 index b46d9c0..0000000 --- a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qwindowsurface_qvfb.h" -#include "qvfbintegration.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QVFbWindowSurface::QVFbWindowSurface(//QVFbIntegration *graphicsSystem, - QVFbScreen *screen, QWidget *window) - : QWindowSurface(window), - mScreen(screen) -{ -} - -QVFbWindowSurface::~QVFbWindowSurface() -{ -} - -QPaintDevice *QVFbWindowSurface::paintDevice() -{ - return mScreen->screenImage(); -} - -void QVFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(offset); - -// QRect rect = geometry(); -// QPoint topLeft = rect.topLeft(); - - mScreen->setDirty(region.boundingRect()); -} - -void QVFbWindowSurface::resize(const QSize&) -{ - -// any size you like as long as it's full-screen... - - QRect rect(mScreen->availableGeometry()); - QWindowSurface::resize(rect.size()); -} - - -QVFbWindow::QVFbWindow(QVFbScreen *screen, QWidget *window) - : QPlatformWindow(window), - mScreen(screen) -{ -} - - -void QVFbWindow::setGeometry(const QRect &) -{ - -// any size you like as long as it's full-screen... - - QRect rect(mScreen->availableGeometry()); - QWindowSystemInterface::handleGeometryChange(this->widget(), rect); - - QPlatformWindow::setGeometry(rect); -} - - - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h deleted file mode 100644 index 9228189..0000000 --- a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_QVFB_H -#define QWINDOWSURFACE_QVFB_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QVFbIntegration; -class QVFbScreen; - -class QVFbWindowSurface : public QWindowSurface -{ -public: - QVFbWindowSurface(QVFbScreen *screen, QWidget *window); - ~QVFbWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void resize(const QSize &size); - -private: - QVFbScreen *mScreen; -}; - -class QVFbWindow : public QPlatformWindow -{ -public: - QVFbWindow(QVFbScreen *screen, QWidget *window); - void setGeometry(const QRect &rect); - -private: - QVFbScreen *mScreen; -}; - - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/testlite/main.cpp b/src/plugins/platforms/testlite/main.cpp index c1759ef..29bbcea 100644 --- a/src/plugins/platforms/testlite/main.cpp +++ b/src/plugins/platforms/testlite/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include -#include "qplatformintegration_testlite.h" +#include "qtestliteintegration.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp b/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp deleted file mode 100644 index cc77bc7..0000000 --- a/src/plugins/platforms/testlite/qplatformintegration_testlite.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - - -#include "qplatformintegration_testlite.h" -#include "qwindowsurface_testlite.h" -#include -#include - -#include - -#include "qtestlitewindow.h" - -#ifndef QT_NO_OPENGL -#include -#include "qglxglcontext.h" -#endif - -QT_BEGIN_NAMESPACE - -class MyCursor : QGraphicsSystemCursor -{ -public: - MyCursor(QPlatformScreen *screen) : QGraphicsSystemCursor(screen) {} - - void changeCursor(QCursor * cursor, QWidget * widget) { - QTestLiteWindow *w = 0; - if (widget) { - QWidget *window = widget->window(); - w = static_cast(window->platformWindow()); - } else { - // No X11 cursor control when there is no widget under the cursor - return; - } - - //qDebug() << "changeCursor" << widget << ws; - if (!w) - return; - - w->setCursor(cursor); - } -}; - - -QTestLiteIntegration::QTestLiteIntegration() -{ - - xd = new MyDisplay; - - mPrimaryScreen = new QTestLiteScreen(); - - mPrimaryScreen->mGeometry = QRect - (0, 0, xd->width, xd->height); - mPrimaryScreen->mDepth = 32; - mPrimaryScreen->mFormat = QImage::Format_RGB32; - mPrimaryScreen->mPhysicalSize = - QSize(xd->physicalWidth, xd->physicalHeight); - - mScreens.append(mPrimaryScreen); - - - (void)new MyCursor(mPrimaryScreen); - -} - -QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -QWindowSurface *QTestLiteIntegration::createWindowSurface(QWidget *widget, WId) const -{ - return new QTestLiteWindowSurface(mPrimaryScreen, widget); -} - - -QPlatformWindow *QTestLiteIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const -{ - return new QTestLiteWindow(this, mPrimaryScreen, widget); -} - - - -QPixmap QTestLiteIntegration::grabWindow(WId window, int x, int y, int width, int height) const -{ - QImage img = xd->grabWindow(window, x, y, width, height); - return QPixmap::fromImage(img); -} - -#ifndef QT_NO_OPENGL -bool QTestLiteIntegration::hasOpenGL() const -{ - return glXQueryExtension(xd->display, 0, 0) != 0; -} - -QPlatformGLContext * QTestLiteIntegration::createGLContext() -{ - return new QGLXGLContext(xd->display); -} - -#endif // QT_NO_OPENGL - - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qplatformintegration_testlite.h b/src/plugins/platforms/testlite/qplatformintegration_testlite.h deleted file mode 100644 index 4260faa..0000000 --- a/src/plugins/platforms/testlite/qplatformintegration_testlite.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_TESTLITE_H -#define QGRAPHICSSYSTEM_TESTLITE_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class MyDisplay; - -class QTestLiteScreen : public QPlatformScreen -{ -public: - QTestLiteScreen() - : mDepth(16), mFormat(QImage::Format_RGB16) {} - ~QTestLiteScreen() {} - - QRect geometry() const { return mGeometry; } - int depth() const { return mDepth; } - QImage::Format format() const { return mFormat; } - QSize physicalSize() const { return mPhysicalSize; } - -public: - QRect mGeometry; - int mDepth; - QImage::Format mFormat; - QSize mPhysicalSize; -}; - -class QTestLiteIntegration : public QPlatformIntegration -{ -public: - QTestLiteIntegration(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; - QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; - - QPixmap grabWindow(WId window, int x, int y, int width, int height) const; - - QList screens() const { return mScreens; } - -#ifndef QT_NO_OPENGL - bool hasOpenGL() const; - QPlatformGLContext * createGLContext(); -#endif - - MyDisplay *xd; - -private: - QTestLiteScreen *mPrimaryScreen; - QList mScreens; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/testlite/qtestliteintegration.cpp b/src/plugins/platforms/testlite/qtestliteintegration.cpp new file mode 100644 index 0000000..6c07349 --- /dev/null +++ b/src/plugins/platforms/testlite/qtestliteintegration.cpp @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "qtestliteintegration.h" +#include "qtestlitewindowsurface.h" +#include +#include + +#include + +#include "qtestlitewindow.h" + +#ifndef QT_NO_OPENGL +#include +#include "qglxglcontext.h" +#endif + +QT_BEGIN_NAMESPACE + +class MyCursor : QGraphicsSystemCursor +{ +public: + MyCursor(QPlatformScreen *screen) : QGraphicsSystemCursor(screen) {} + + void changeCursor(QCursor * cursor, QWidget * widget) { + QTestLiteWindow *w = 0; + if (widget) { + QWidget *window = widget->window(); + w = static_cast(window->platformWindow()); + } else { + // No X11 cursor control when there is no widget under the cursor + return; + } + + //qDebug() << "changeCursor" << widget << ws; + if (!w) + return; + + w->setCursor(cursor); + } +}; + + +QTestLiteIntegration::QTestLiteIntegration() +{ + + xd = new MyDisplay; + + mPrimaryScreen = new QTestLiteScreen(); + + mPrimaryScreen->mGeometry = QRect + (0, 0, xd->width, xd->height); + mPrimaryScreen->mDepth = 32; + mPrimaryScreen->mFormat = QImage::Format_RGB32; + mPrimaryScreen->mPhysicalSize = + QSize(xd->physicalWidth, xd->physicalHeight); + + mScreens.append(mPrimaryScreen); + + + (void)new MyCursor(mPrimaryScreen); + +} + +QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QTestLiteIntegration::createWindowSurface(QWidget *widget, WId) const +{ + return new QTestLiteWindowSurface(mPrimaryScreen, widget); +} + + +QPlatformWindow *QTestLiteIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const +{ + return new QTestLiteWindow(this, mPrimaryScreen, widget); +} + + + +QPixmap QTestLiteIntegration::grabWindow(WId window, int x, int y, int width, int height) const +{ + QImage img = xd->grabWindow(window, x, y, width, height); + return QPixmap::fromImage(img); +} + +#ifndef QT_NO_OPENGL +bool QTestLiteIntegration::hasOpenGL() const +{ + return glXQueryExtension(xd->display, 0, 0) != 0; +} + +QPlatformGLContext * QTestLiteIntegration::createGLContext() +{ + return new QGLXGLContext(xd->display); +} + +#endif // QT_NO_OPENGL + + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qtestliteintegration.h b/src/plugins/platforms/testlite/qtestliteintegration.h new file mode 100644 index 0000000..4260faa --- /dev/null +++ b/src/plugins/platforms/testlite/qtestliteintegration.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_TESTLITE_H +#define QGRAPHICSSYSTEM_TESTLITE_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class MyDisplay; + +class QTestLiteScreen : public QPlatformScreen +{ +public: + QTestLiteScreen() + : mDepth(16), mFormat(QImage::Format_RGB16) {} + ~QTestLiteScreen() {} + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; +}; + +class QTestLiteIntegration : public QPlatformIntegration +{ +public: + QTestLiteIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + + QPixmap grabWindow(WId window, int x, int y, int width, int height) const; + + QList screens() const { return mScreens; } + +#ifndef QT_NO_OPENGL + bool hasOpenGL() const; + QPlatformGLContext * createGLContext(); +#endif + + MyDisplay *xd; + +private: + QTestLiteScreen *mPrimaryScreen; + QList mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index 108f732..49b79ec 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "qwindowsurface_testlite.h" -#include "qplatformintegration_testlite.h" +#include "qtestlitewindowsurface.h" +#include "qtestliteintegration.h" #include #include "qtestlitewindow.h" diff --git a/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp b/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp new file mode 100644 index 0000000..3567118 --- /dev/null +++ b/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp @@ -0,0 +1,273 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtestlitewindowsurface.h" +#include "qtestliteintegration.h" + +#include +#include + +#include "qtestlitewindow.h" + +# include +# include +# include + +QT_BEGIN_NAMESPACE + + +struct MyShmImageInfo { + MyShmImageInfo(Display *xdisplay) : image(0), display(xdisplay) {} + ~MyShmImageInfo() { destroy(); } + + void destroy(); + + XShmSegmentInfo shminfo; + XImage *image; + Display *display; +}; + +//void QTestLiteWindowSurface::flush() + + +#ifndef DONT_USE_MIT_SHM +void MyShmImageInfo::destroy() +{ + XShmDetach (display, &shminfo); + XDestroyImage (image); + shmdt (shminfo.shmaddr); + shmctl (shminfo.shmid, IPC_RMID, 0); +} +#endif + +void QTestLiteWindowSurface::resizeShmImage(int width, int height) +{ + MyDisplay *xd = xw->xd; + +#ifdef DONT_USE_MIT_SHM + shm_img = QImage(width, height, QImage::Format_RGB32); +#else + if (image_info) + image_info->destroy(); + else + image_info = new MyShmImageInfo(xd->display); + + Visual *visual = DefaultVisual(xd->display, xd->screen); + + + XImage *image = XShmCreateImage (xd->display, visual, 24, ZPixmap, 0, + &image_info->shminfo, width, height); + + + image_info->shminfo.shmid = shmget (IPC_PRIVATE, + image->bytes_per_line * image->height, IPC_CREAT|0777); + + image_info->shminfo.shmaddr = image->data = (char*)shmat (image_info->shminfo.shmid, 0, 0); + image_info->shminfo.readOnly = False; + + image_info->image = image; + + Status shm_attach_status = XShmAttach(xd->display, &image_info->shminfo); + + Q_ASSERT(shm_attach_status == True); + + shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, QImage::Format_RGB32 ); +#endif + painted = false; +} + + +void QTestLiteWindowSurface::resizeBuffer(QSize s) +{ + if (shm_img.size() != s) + resizeShmImage(s.width(), s.height()); +} + +QSize QTestLiteWindowSurface::bufferSize() const +{ + return shm_img.size(); +} + +QTestLiteWindowSurface::QTestLiteWindowSurface (QTestLiteScreen */*screen*/, QWidget *window) + : QWindowSurface(window), + painted(false), image_info(0) +{ + xw = static_cast(window->platformWindow()); + xw->windowSurface = this; +// qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window; +} + +QTestLiteWindowSurface::~QTestLiteWindowSurface() +{ + delete image_info; +} + +QPaintDevice *QTestLiteWindowSurface::paintDevice() +{ + return &shm_img; +} + + +void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); + + // qDebug() << "QTestLiteWindowSurface::flush:" << (long)this; + + if (!painted) + return; + + MyDisplay *xd = xw->xd; + GC gc = xw->gc; + Window window = xw->x_window; +#ifdef DONT_USE_MIT_SHM + // just convert the image every time... + if (!shm_img.isNull()) { + Visual *visual = DefaultVisual(xd->display, xd->screen); + + QImage image = shm_img; + //img.convertToFormat( + XImage *xi = XCreateImage(xd->display, visual, 24, ZPixmap, + 0, (char *) image.scanLine(0), image.width(), image.height(), + 32, image.bytesPerLine()); + + int x = 0; + int y = 0; + + /*int r =*/ XPutImage(xd->display, window, gc, xi, 0, 0, x, y, image.width(), image.height()); + + xi->data = 0; // QImage owns these bits + XDestroyImage(xi); + } +#else + // Use MIT_SHM + if (image_info->image) { + //qDebug() << "Here we go" << image_info->image->width << image_info->image->height; + int x = 0; + int y = 0; + + // We could set send_event to true, and then use the ShmCompletion to synchronize, + // but let's do like Qt/11 and just use XSync + XShmPutImage (xd->display, window, gc, image_info->image, 0, 0, + x, y, image_info->image->width, image_info->image->height, + /*send_event*/ False); + + XSync(xd->display, False); + } +#endif +} + +//### scroll logic copied from QRasterWindowSurface, we should make better API for this + +void copied_qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) +{ + // make sure we don't detach + uchar *mem = const_cast(const_cast(img).bits()); + + int lineskip = img.bytesPerLine(); + int depth = img.depth() >> 3; + + const QRect imageRect(0, 0, img.width(), img.height()); + const QRect r = rect & imageRect & imageRect.translated(-offset); + const QPoint p = rect.topLeft() + offset; + + if (r.isEmpty()) + return; + + const uchar *src; + uchar *dest; + + if (r.top() < p.y()) { + src = mem + r.bottom() * lineskip + r.left() * depth; + dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth; + lineskip = -lineskip; + } else { + src = mem + r.top() * lineskip + r.left() * depth; + dest = mem + p.y() * lineskip + p.x() * depth; + } + + const int w = r.width(); + int h = r.height(); + const int bytes = w * depth; + + // overlapping segments? + if (offset.y() == 0 && qAbs(offset.x()) < w) { + do { + ::memmove(dest, src, bytes); + dest += lineskip; + src += lineskip; + } while (--h); + } else { + do { + ::memcpy(dest, src, bytes); + dest += lineskip; + src += lineskip; + } while (--h); + } +} + +bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + if (shm_img.isNull()) + return false; + + const QVector rects = area.rects(); + for (int i = 0; i < rects.size(); ++i) + copied_qt_scrollRectInImage(shm_img, rects.at(i), QPoint(dx, dy)); + + return true; +} + + +void QTestLiteWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); + resizeBuffer(size()); +} + +void QTestLiteWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); + painted = true; //there is content in the buffer +} +QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qtestlitewindowsurface.h b/src/plugins/platforms/testlite/qtestlitewindowsurface.h new file mode 100644 index 0000000..915e7fe --- /dev/null +++ b/src/plugins/platforms/testlite/qtestlitewindowsurface.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_TESTLITE_H +#define QWINDOWSURFACE_TESTLITE_H + +#include + + +QT_BEGIN_NAMESPACE + +class QTestLiteWindow; +class QTestLiteIntegration; +class QTestLiteScreen; +class MyShmImageInfo; + +class QTestLiteWindowSurface : public QWindowSurface +{ +public: + QTestLiteWindowSurface (QTestLiteScreen *screen, QWidget *window); + ~QTestLiteWindowSurface(); + + QPaintDevice *paintDevice(); +// void flush(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); +// void resize(const QSize &size); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + +private: + bool painted; + void resizeBuffer(QSize); + QSize bufferSize() const; + + + void resizeShmImage(int width, int height); + + QImage shm_img; + MyShmImageInfo *image_info; + + QTestLiteWindow *xw; + +}; + + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp b/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp deleted file mode 100644 index af10368..0000000 --- a/src/plugins/platforms/testlite/qwindowsurface_testlite.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindowsurface_testlite.h" -#include "qplatformintegration_testlite.h" - -#include -#include - -#include "qtestlitewindow.h" - -# include -# include -# include - -QT_BEGIN_NAMESPACE - - -struct MyShmImageInfo { - MyShmImageInfo(Display *xdisplay) : image(0), display(xdisplay) {} - ~MyShmImageInfo() { destroy(); } - - void destroy(); - - XShmSegmentInfo shminfo; - XImage *image; - Display *display; -}; - -//void QTestLiteWindowSurface::flush() - - -#ifndef DONT_USE_MIT_SHM -void MyShmImageInfo::destroy() -{ - XShmDetach (display, &shminfo); - XDestroyImage (image); - shmdt (shminfo.shmaddr); - shmctl (shminfo.shmid, IPC_RMID, 0); -} -#endif - -void QTestLiteWindowSurface::resizeShmImage(int width, int height) -{ - MyDisplay *xd = xw->xd; - -#ifdef DONT_USE_MIT_SHM - shm_img = QImage(width, height, QImage::Format_RGB32); -#else - if (image_info) - image_info->destroy(); - else - image_info = new MyShmImageInfo(xd->display); - - Visual *visual = DefaultVisual(xd->display, xd->screen); - - - XImage *image = XShmCreateImage (xd->display, visual, 24, ZPixmap, 0, - &image_info->shminfo, width, height); - - - image_info->shminfo.shmid = shmget (IPC_PRIVATE, - image->bytes_per_line * image->height, IPC_CREAT|0777); - - image_info->shminfo.shmaddr = image->data = (char*)shmat (image_info->shminfo.shmid, 0, 0); - image_info->shminfo.readOnly = False; - - image_info->image = image; - - Status shm_attach_status = XShmAttach(xd->display, &image_info->shminfo); - - Q_ASSERT(shm_attach_status == True); - - shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, QImage::Format_RGB32 ); -#endif - painted = false; -} - - -void QTestLiteWindowSurface::resizeBuffer(QSize s) -{ - if (shm_img.size() != s) - resizeShmImage(s.width(), s.height()); -} - -QSize QTestLiteWindowSurface::bufferSize() const -{ - return shm_img.size(); -} - -QTestLiteWindowSurface::QTestLiteWindowSurface (QTestLiteScreen */*screen*/, QWidget *window) - : QWindowSurface(window), - painted(false), image_info(0) -{ - xw = static_cast(window->platformWindow()); - xw->windowSurface = this; -// qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window; -} - -QTestLiteWindowSurface::~QTestLiteWindowSurface() -{ - delete image_info; -} - -QPaintDevice *QTestLiteWindowSurface::paintDevice() -{ - return &shm_img; -} - - -void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(region); - Q_UNUSED(offset); - - // qDebug() << "QTestLiteWindowSurface::flush:" << (long)this; - - if (!painted) - return; - - MyDisplay *xd = xw->xd; - GC gc = xw->gc; - Window window = xw->x_window; -#ifdef DONT_USE_MIT_SHM - // just convert the image every time... - if (!shm_img.isNull()) { - Visual *visual = DefaultVisual(xd->display, xd->screen); - - QImage image = shm_img; - //img.convertToFormat( - XImage *xi = XCreateImage(xd->display, visual, 24, ZPixmap, - 0, (char *) image.scanLine(0), image.width(), image.height(), - 32, image.bytesPerLine()); - - int x = 0; - int y = 0; - - /*int r =*/ XPutImage(xd->display, window, gc, xi, 0, 0, x, y, image.width(), image.height()); - - xi->data = 0; // QImage owns these bits - XDestroyImage(xi); - } -#else - // Use MIT_SHM - if (image_info->image) { - //qDebug() << "Here we go" << image_info->image->width << image_info->image->height; - int x = 0; - int y = 0; - - // We could set send_event to true, and then use the ShmCompletion to synchronize, - // but let's do like Qt/11 and just use XSync - XShmPutImage (xd->display, window, gc, image_info->image, 0, 0, - x, y, image_info->image->width, image_info->image->height, - /*send_event*/ False); - - XSync(xd->display, False); - } -#endif -} - -//### scroll logic copied from QRasterWindowSurface, we should make better API for this - -void copied_qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) -{ - // make sure we don't detach - uchar *mem = const_cast(const_cast(img).bits()); - - int lineskip = img.bytesPerLine(); - int depth = img.depth() >> 3; - - const QRect imageRect(0, 0, img.width(), img.height()); - const QRect r = rect & imageRect & imageRect.translated(-offset); - const QPoint p = rect.topLeft() + offset; - - if (r.isEmpty()) - return; - - const uchar *src; - uchar *dest; - - if (r.top() < p.y()) { - src = mem + r.bottom() * lineskip + r.left() * depth; - dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth; - lineskip = -lineskip; - } else { - src = mem + r.top() * lineskip + r.left() * depth; - dest = mem + p.y() * lineskip + p.x() * depth; - } - - const int w = r.width(); - int h = r.height(); - const int bytes = w * depth; - - // overlapping segments? - if (offset.y() == 0 && qAbs(offset.x()) < w) { - do { - ::memmove(dest, src, bytes); - dest += lineskip; - src += lineskip; - } while (--h); - } else { - do { - ::memcpy(dest, src, bytes); - dest += lineskip; - src += lineskip; - } while (--h); - } -} - -bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - if (shm_img.isNull()) - return false; - - const QVector rects = area.rects(); - for (int i = 0; i < rects.size(); ++i) - copied_qt_scrollRectInImage(shm_img, rects.at(i), QPoint(dx, dy)); - - return true; -} - - -void QTestLiteWindowSurface::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); - resizeBuffer(size()); -} - -void QTestLiteWindowSurface::endPaint(const QRegion ®ion) -{ - Q_UNUSED(region); - painted = true; //there is content in the buffer -} -QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qwindowsurface_testlite.h b/src/plugins/platforms/testlite/qwindowsurface_testlite.h deleted file mode 100644 index 915e7fe..0000000 --- a/src/plugins/platforms/testlite/qwindowsurface_testlite.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_TESTLITE_H -#define QWINDOWSURFACE_TESTLITE_H - -#include - - -QT_BEGIN_NAMESPACE - -class QTestLiteWindow; -class QTestLiteIntegration; -class QTestLiteScreen; -class MyShmImageInfo; - -class QTestLiteWindowSurface : public QWindowSurface -{ -public: - QTestLiteWindowSurface (QTestLiteScreen *screen, QWidget *window); - ~QTestLiteWindowSurface(); - - QPaintDevice *paintDevice(); -// void flush(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); -// void resize(const QSize &size); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - -private: - bool painted; - void resizeBuffer(QSize); - QSize bufferSize() const; - - - void resizeShmImage(int width, int height); - - QImage shm_img; - MyShmImageInfo *image_info; - - QTestLiteWindow *xw; - -}; - - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/testlite/testlite.pro b/src/plugins/platforms/testlite/testlite.pro index 8f108ae..454193d 100644 --- a/src/plugins/platforms/testlite/testlite.pro +++ b/src/plugins/platforms/testlite/testlite.pro @@ -3,8 +3,8 @@ include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms -SOURCES = main.cpp qplatformintegration_testlite.cpp qwindowsurface_testlite.cpp qtestlitewindow.cpp -HEADERS = qplatformintegration_testlite.h qwindowsurface_testlite.h qtestlitewindow.h +SOURCES = main.cpp qtestliteintegration.cpp qtestlitewindowsurface.cpp qtestlitewindow.cpp +HEADERS = qtestliteintegration.h qtestlitewindowsurface.h qtestlitewindow.h LIBS += -lX11 -lXext diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp index 23d78c1..775259b 100644 --- a/src/plugins/platforms/vnc/main.cpp +++ b/src/plugins/platforms/vnc/main.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qgraphicssystem_vnc.h" +#include "qvncintegration.h" #include #include diff --git a/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp b/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp deleted file mode 100644 index a872991..0000000 --- a/src/plugins/platforms/vnc/qgraphicssystem_vnc.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_vnc.h" -#include "../fb_base/fb_base.h" -#include -#include -#include - -#include -#include - -#include - - -QVNCScreen::QVNCScreen() - : QFbScreen::QFbScreen() -{ - int w = 800; - int h = 600; - int ew, eh; - const char *str; - if ((str=::getenv("QT_VNC_SIZE")) && sscanf(str,"%dx%d",&ew,&eh)==2) { - w = ew; - h = eh; - } - - setGeometry(QRect(0,0,w, h)); - setDepth(32); - setFormat(QImage::Format_RGB32); - setPhysicalSize((geometry().size()*254)/720); - - - d_ptr = new QVNCScreenPrivate(this); - - cursor = new QVNCCursor(d_ptr->vncServer, this); - d_ptr->vncServer->setCursor(static_cast(cursor)); -} - -QVNCDirtyMap *QVNCScreen::dirtyMap() -{ - return d_ptr->dirty; -} - -QRegion QVNCScreen::doRedraw() -{ - QRegion touched; - touched = QFbScreen::doRedraw(); - - QVector rects = touched.rects(); - for (int i = 0; i < rects.size(); i++) - d_ptr->setDirty(rects[i]); - return touched; -} - - -QVNCIntegration::QVNCIntegration() -{ - mPrimaryScreen = new QVNCScreen(); - - mScreens.append(mPrimaryScreen); -} - -QPixmapData *QVNCIntegration::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -// QWindowSurface *QVNCIntegration::createWindowSurface(QWidget *widget) const -// { -// if (widget->windowType() == Qt::Desktop) -// return 0; // Don't create an explicit window surface for the destkop. -// QFbWindowSurface * surface; -// surface = new QFbWindowSurface(mPrimaryScreen, widget); -// mPrimaryScreen->addWindowSurface(surface); -// return surface; -// } - -QWindowSurface *QVNCIntegration::createWindowSurface(QWidget *widget, WId) const -{ - QFbWindowSurface * surface; - surface = new QFbWindowSurface(mPrimaryScreen, widget); - return surface; -} - - -QPlatformWindow *QVNCIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const -{ - QFbWindow *w = new QFbWindow(mPrimaryScreen, widget); - mPrimaryScreen->addWindow(w); - return w; -} - diff --git a/src/plugins/platforms/vnc/qgraphicssystem_vnc.h b/src/plugins/platforms/vnc/qgraphicssystem_vnc.h deleted file mode 100644 index 524b888..0000000 --- a/src/plugins/platforms/vnc/qgraphicssystem_vnc.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_VNC_H -#define QGRAPHICSSYSTEM_VNC_H - -#include "qvnccursor.h" -#include "../fb_base/fb_base.h" -#include - -QT_BEGIN_NAMESPACE - -class QVNCServer; -class QVNCDirtyMap; - -class QVNCScreenPrivate; - -class QVNCScreen : public QFbScreen -{ -public: - QVNCScreen(); - - int linestep() const { return image() ? image()->bytesPerLine() : 0; } - uchar *base() const { return image() ? image()->bits() : 0; } - QVNCDirtyMap *dirtyMap(); - -public: - QVNCScreenPrivate *d_ptr; - -private: - QVNCServer *server; - QRegion doRedraw(); -}; - -class QVNCIntegrationPrivate; - - -class QVNCIntegration : public QPlatformIntegration -{ -public: - QVNCIntegration(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; - QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; - - QList screens() const { return mScreens; } - - -private: - QVNCScreen *mPrimaryScreen; - QList mScreens; -}; - - - -QT_END_NAMESPACE - -#endif //QGRAPHICSSYSTEM_VNC_H - diff --git a/src/plugins/platforms/vnc/qvnccursor.cpp b/src/plugins/platforms/vnc/qvnccursor.cpp index 78da53b..8da06aa 100644 --- a/src/plugins/platforms/vnc/qvnccursor.cpp +++ b/src/plugins/platforms/vnc/qvnccursor.cpp @@ -49,7 +49,7 @@ #include "qvnccursor.h" #include "qvncserver.h" -#include "qgraphicssystem_vnc.h" +#include "qvncintegration.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp new file mode 100644 index 0000000..7bdba35 --- /dev/null +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvncintegration.h" +#include "../fb_base/fb_base.h" +#include +#include +#include + +#include +#include + +#include + + +QVNCScreen::QVNCScreen() + : QFbScreen::QFbScreen() +{ + int w = 800; + int h = 600; + int ew, eh; + const char *str; + if ((str=::getenv("QT_VNC_SIZE")) && sscanf(str,"%dx%d",&ew,&eh)==2) { + w = ew; + h = eh; + } + + setGeometry(QRect(0,0,w, h)); + setDepth(32); + setFormat(QImage::Format_RGB32); + setPhysicalSize((geometry().size()*254)/720); + + + d_ptr = new QVNCScreenPrivate(this); + + cursor = new QVNCCursor(d_ptr->vncServer, this); + d_ptr->vncServer->setCursor(static_cast(cursor)); +} + +QVNCDirtyMap *QVNCScreen::dirtyMap() +{ + return d_ptr->dirty; +} + +QRegion QVNCScreen::doRedraw() +{ + QRegion touched; + touched = QFbScreen::doRedraw(); + + QVector rects = touched.rects(); + for (int i = 0; i < rects.size(); i++) + d_ptr->setDirty(rects[i]); + return touched; +} + + +QVNCIntegration::QVNCIntegration() +{ + mPrimaryScreen = new QVNCScreen(); + + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QVNCIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +// QWindowSurface *QVNCIntegration::createWindowSurface(QWidget *widget) const +// { +// if (widget->windowType() == Qt::Desktop) +// return 0; // Don't create an explicit window surface for the destkop. +// QFbWindowSurface * surface; +// surface = new QFbWindowSurface(mPrimaryScreen, widget); +// mPrimaryScreen->addWindowSurface(surface); +// return surface; +// } + +QWindowSurface *QVNCIntegration::createWindowSurface(QWidget *widget, WId) const +{ + QFbWindowSurface * surface; + surface = new QFbWindowSurface(mPrimaryScreen, widget); + return surface; +} + + +QPlatformWindow *QVNCIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const +{ + QFbWindow *w = new QFbWindow(mPrimaryScreen, widget); + mPrimaryScreen->addWindow(w); + return w; +} + diff --git a/src/plugins/platforms/vnc/qvncintegration.h b/src/plugins/platforms/vnc/qvncintegration.h new file mode 100644 index 0000000..524b888 --- /dev/null +++ b/src/plugins/platforms/vnc/qvncintegration.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_VNC_H +#define QGRAPHICSSYSTEM_VNC_H + +#include "qvnccursor.h" +#include "../fb_base/fb_base.h" +#include + +QT_BEGIN_NAMESPACE + +class QVNCServer; +class QVNCDirtyMap; + +class QVNCScreenPrivate; + +class QVNCScreen : public QFbScreen +{ +public: + QVNCScreen(); + + int linestep() const { return image() ? image()->bytesPerLine() : 0; } + uchar *base() const { return image() ? image()->bits() : 0; } + QVNCDirtyMap *dirtyMap(); + +public: + QVNCScreenPrivate *d_ptr; + +private: + QVNCServer *server; + QRegion doRedraw(); +}; + +class QVNCIntegrationPrivate; + + +class QVNCIntegration : public QPlatformIntegration +{ +public: + QVNCIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + + QList screens() const { return mScreens; } + + +private: + QVNCScreen *mPrimaryScreen; + QList mScreens; +}; + + + +QT_END_NAMESPACE + +#endif //QGRAPHICSSYSTEM_VNC_H + diff --git a/src/plugins/platforms/vnc/qvncserver.h b/src/plugins/platforms/vnc/qvncserver.h index 41cadab..b1a9797 100644 --- a/src/plugins/platforms/vnc/qvncserver.h +++ b/src/plugins/platforms/vnc/qvncserver.h @@ -53,7 +53,7 @@ // We mean it. // -#include "qgraphicssystem_vnc.h" +#include "qvncintegration.h" #include "qvnccursor.h" #define QT_NO_QWS_CURSOR diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro index b1da572..65824a2 100644 --- a/src/plugins/platforms/vnc/vnc.pro +++ b/src/plugins/platforms/vnc/vnc.pro @@ -3,8 +3,8 @@ include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms -SOURCES = main.cpp qgraphicssystem_vnc.cpp -HEADERS = qgraphicssystem_vnc.h +SOURCES = main.cpp qvncintegration.cpp +HEADERS = qvncintegration.h HEADERS += qvncserver.h SOURCES += qvncserver.cpp -- cgit v0.12 From 535161b217a9fb5117803cbff1ddcc97242c10f3 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 22 Apr 2010 15:16:32 +0200 Subject: Avoid copying code. --- src/gui/kernel/qapplication_lite.cpp | 2 +- src/gui/painting/qwindowsurface.cpp | 8 +++- .../platforms/testlite/qtestlitewindowsurface.cpp | 52 ++-------------------- 3 files changed, 11 insertions(+), 51 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 867c2dc..fae7663 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -627,7 +627,7 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent * //even if we're blocked by modality, we should deliver the mouse release event.. //### this code is not completely correct: multiple buttons can be pressed simultaneously if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) { - qDebug() << "modal blocked mouse event to" << tlw; + //qDebug() << "modal blocked mouse event to" << tlw; return; } } diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp index 7558cad..3b542bc 100644 --- a/src/gui/painting/qwindowsurface.cpp +++ b/src/gui/painting/qwindowsurface.cpp @@ -342,7 +342,13 @@ void QWindowSurface::setPartialUpdateSupport(bool enable) d_ptr->partialUpdateSupport = enable; } -void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) +#ifdef Q_WS_LITE +#define Q_EXPORT_SCROLLRECT Q_GUI_EXPORT +#else +#define Q_EXPORT_SCROLLRECT +#endif + +void Q_EXPORT_SCROLLRECT qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) { // make sure we don't detach uchar *mem = const_cast(const_cast(img).bits()); diff --git a/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp b/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp index 3567118..a14a50e 100644 --- a/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp @@ -197,54 +197,8 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const #endif } -//### scroll logic copied from QRasterWindowSurface, we should make better API for this - -void copied_qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) -{ - // make sure we don't detach - uchar *mem = const_cast(const_cast(img).bits()); - - int lineskip = img.bytesPerLine(); - int depth = img.depth() >> 3; - - const QRect imageRect(0, 0, img.width(), img.height()); - const QRect r = rect & imageRect & imageRect.translated(-offset); - const QPoint p = rect.topLeft() + offset; - - if (r.isEmpty()) - return; - - const uchar *src; - uchar *dest; - - if (r.top() < p.y()) { - src = mem + r.bottom() * lineskip + r.left() * depth; - dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth; - lineskip = -lineskip; - } else { - src = mem + r.top() * lineskip + r.left() * depth; - dest = mem + p.y() * lineskip + p.x() * depth; - } - - const int w = r.width(); - int h = r.height(); - const int bytes = w * depth; - - // overlapping segments? - if (offset.y() == 0 && qAbs(offset.x()) < w) { - do { - ::memmove(dest, src, bytes); - dest += lineskip; - src += lineskip; - } while (--h); - } else { - do { - ::memcpy(dest, src, bytes); - dest += lineskip; - src += lineskip; - } while (--h); - } -} +// 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) { @@ -253,7 +207,7 @@ bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) const QVector rects = area.rects(); for (int i = 0; i < rects.size(); ++i) - copied_qt_scrollRectInImage(shm_img, rects.at(i), QPoint(dx, dy)); + qt_scrollRectInImage(shm_img, rects.at(i), QPoint(dx, dy)); return true; } -- cgit v0.12 From e45139ea8ba05d25bc2ead99b6d3b495bc4f84ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 22 Apr 2010 15:26:12 +0200 Subject: Enable some faster text drawing for lighthouse when using raster --- src/gui/painting/qpaintengine_raster.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 03318de..d734deb 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -94,6 +94,8 @@ # include #elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) # include +#elif defined(Q_WS_LITE) +# include #endif #if defined(Q_WS_WIN64) @@ -3314,9 +3316,9 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte } #endif // Q_WS_QWS -#if (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) +#if (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) || defined(Q_WS_LITE)) && !defined(QT_NO_FREETYPE) -#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_QPF2) +#if (defined(Q_WS_QWS) || defined(Q_WS_LITE)) && !defined(QT_NO_QWS_QPF2) if (fontEngine->type() == QFontEngine::QPF2) { QFontEngine *renderingEngine = static_cast(fontEngine)->renderingEngine(); if (renderingEngine) -- cgit v0.12 From 9fd7d1dd2822a410588da6042d57ac84fb5da1c8 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 23 Apr 2010 10:19:39 +0200 Subject: Update QGLWindowSurface to reflect geometry -> size name change --- src/opengl/qwindowsurface_gl.cpp | 38 +++++++++++++++++++++++++++----------- src/opengl/qwindowsurface_gl_p.h | 6 ++++++ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index ca88de3..d9417d9 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -414,8 +414,13 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget(); Q_ASSERT(parent); +#if !defined(Q_WS_LITE) if (!geometry().isValid()) return; +#else + if (!size().isValid()) + return; +#endif // Needed to support native child-widgets... hijackWindow(parent); @@ -638,20 +643,31 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & } +#if !defined(Q_WS_LITE) void QGLWindowSurface::setGeometry(const QRect &rect) { QWindowSurface::setGeometry(rect); d_ptr->geometry_updated = true; } - +#else +void QGLWindowSurface::resize(const QSize &size) +{ + QWindowSurface::resize(size); + d_ptr->geometry_updated = true; +} +#endif void QGLWindowSurface::updateGeometry() { if (!d_ptr->geometry_updated) return; d_ptr->geometry_updated = false; +#ifdef Q_WS_LITE + QSize surfSize = size(); +#else + QSize surfSize = geometry().size(); +#endif - QRect rect = geometry(); hijackWindow(window()); QGLContext *ctx = reinterpret_cast(window()->d_func()->extraData()->glContext); @@ -661,19 +677,19 @@ void QGLWindowSurface::updateGeometry() { const GLenum target = GL_TEXTURE_2D; - if (rect.width() <= 0 || rect.height() <= 0) + if (surfSize.width() <= 0 || surfSize.height() <= 0) return; - if (d_ptr->size == rect.size()) + if (d_ptr->size == surfSize) return; - d_ptr->size = rect.size(); + d_ptr->size = surfSize; if (d_ptr->ctx) { #ifndef QT_OPENGL_ES_2 if (d_ptr->destructive_swap_buffers) { glBindTexture(target, d_ptr->tex_id); - glTexImage2D(target, 0, GL_RGBA, rect.width(), rect.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0); + glTexImage2D(target, 0, GL_RGBA, surfSize.width(), surfSize.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0); glBindTexture(target, 0); } #endif @@ -698,10 +714,10 @@ void QGLWindowSurface::updateGeometry() { if (QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit) format.setSamples(8); - d_ptr->fbo = new QGLFramebufferObject(rect.size(), format); + d_ptr->fbo = new QGLFramebufferObject(surfSize, format); if (d_ptr->fbo->isValid()) { - qDebug() << "Created Window Surface FBO" << rect.size() + qDebug() << "Created Window Surface FBO" << surfSize << "with samples" << d_ptr->fbo->format().samples(); return; } else { @@ -722,7 +738,7 @@ void QGLWindowSurface::updateGeometry() { delete d_ptr->pb; - d_ptr->pb = new QGLPixelBuffer(rect.width(), rect.height(), + d_ptr->pb = new QGLPixelBuffer(surfSize.width(), surfSize.height(), QGLFormat(QGL::SampleBuffers | QGL::StencilBuffer | QGL::DepthBuffer), qt_gl_share_widget()); @@ -732,7 +748,7 @@ void QGLWindowSurface::updateGeometry() { glGenTextures(1, &d_ptr->pb_tex_id); glBindTexture(target, d_ptr->pb_tex_id); - glTexImage2D(target, 0, GL_RGBA, rect.width(), rect.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + glTexImage2D(target, 0, GL_RGBA, surfSize.width(), surfSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -758,7 +774,7 @@ void QGLWindowSurface::updateGeometry() { if (d_ptr->destructive_swap_buffers) { glGenTextures(1, &d_ptr->tex_id); glBindTexture(target, d_ptr->tex_id); - glTexImage2D(target, 0, GL_RGBA, rect.width(), rect.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0); + glTexImage2D(target, 0, GL_RGBA, surfSize.width(), surfSize.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, 0); glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index 8ea714c..9d17514 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -86,7 +86,13 @@ public: QPaintDevice *paintDevice(); void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + +#if !defined(Q_WS_LITE) void setGeometry(const QRect &rect); +#else + virtual void resize(const QSize &size); +#endif + void updateGeometry(); bool scroll(const QRegion &area, int dx, int dy); -- cgit v0.12 From 69e54ffd1796312aca2db49f19b5de92e6dab3ae Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 23 Apr 2010 15:03:19 +0200 Subject: Crash fix Make sure double-linked list invariant is maintained --- src/plugins/platforms/testlite/qtestlitewindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index 49b79ec..545912e 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -1188,6 +1188,8 @@ void MyX11Cursors::timeout() lookupMap.take(id); MyX11CursorNode * tmp = node; node = node->post(); + if (node) + node->setAnte(0); delete tmp; XFreeCursor(display, c); } -- cgit v0.12 From 1acf354a1380586a754d2a0ed546e4dceb4296cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 27 Apr 2010 10:20:35 +0200 Subject: Compile fix qegl_lite.cpp --- src/gui/egl/qegl_lite.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gui/egl/qegl_lite.cpp b/src/gui/egl/qegl_lite.cpp index 2bbf22b..10caf46 100644 --- a/src/gui/egl/qegl_lite.cpp +++ b/src/gui/egl/qegl_lite.cpp @@ -64,6 +64,7 @@ EGLNativeWindowType QEgl::nativeWindow(QWidget* widget) EGLNativePixmapType QEgl::nativePixmap(QPixmap* pixmap) { + Q_UNUSED(pixmap); return 0; } @@ -72,13 +73,11 @@ EGLNativePixmapType QEgl::nativePixmap(QPixmap* pixmap) // return eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY)); //} -static QGraphicsSystemScreen *screenForDevice(QPaintDevice *device) +static QPlatformScreen *screenForDevice(QPaintDevice *device) { - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return 0; + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); - QList screens = gs->screens(); + QList screens = pi->screens(); int screenNumber; if (device && device->devType() == QInternal::Widget) @@ -97,7 +96,7 @@ void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev) return; // Find the QGLScreen for this paint device. - QGraphicsSystemScreen *screen = screenForDevice(dev); + QPlatformScreen *screen = screenForDevice(dev); if (!screen) return; int devType = dev->devType(); -- cgit v0.12 From 255371252bdad3cd370ccf95337c94baae7277a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 23 Apr 2010 08:38:44 +0200 Subject: Porting openkode platform plugin to new api --- src/plugins/platforms/openkode/frag.glslf | 8 - src/plugins/platforms/openkode/frag.h | 37 --- src/plugins/platforms/openkode/main.cpp | 16 +- src/plugins/platforms/openkode/openkode.pro | 22 +- .../openkode/qgraphicssystem_openkode.cpp | 236 ------------------ .../platforms/openkode/qgraphicssystem_openkode.h | 95 -------- .../platforms/openkode/qopenkodeintegration.cpp | 227 ++++++++++++++++++ .../platforms/openkode/qopenkodeintegration.h | 95 ++++++++ src/plugins/platforms/openkode/qopenkodewindow.cpp | 114 +++++++++ src/plugins/platforms/openkode/qopenkodewindow.h | 63 +++++ .../platforms/openkode/qopenkodewindowsurface.cpp | 187 +++++++++++++++ .../platforms/openkode/qopenkodewindowsurface.h | 75 ++++++ .../platforms/openkode/qwindowsurface_openkode.cpp | 265 --------------------- .../platforms/openkode/qwindowsurface_openkode.h | 79 ------ src/plugins/platforms/openkode/resources.qrc | 6 + src/plugins/platforms/openkode/shaders/frag.glslf | 8 + src/plugins/platforms/openkode/shaders/vert.glslv | 14 ++ src/plugins/platforms/openkode/vert.glslv | 14 -- src/plugins/platforms/openkode/vert.h | 63 ----- 19 files changed, 811 insertions(+), 813 deletions(-) delete mode 100644 src/plugins/platforms/openkode/frag.glslf delete mode 100644 src/plugins/platforms/openkode/frag.h delete mode 100644 src/plugins/platforms/openkode/qgraphicssystem_openkode.cpp delete mode 100644 src/plugins/platforms/openkode/qgraphicssystem_openkode.h create mode 100644 src/plugins/platforms/openkode/qopenkodeintegration.cpp create mode 100644 src/plugins/platforms/openkode/qopenkodeintegration.h create mode 100644 src/plugins/platforms/openkode/qopenkodewindow.cpp create mode 100644 src/plugins/platforms/openkode/qopenkodewindow.h create mode 100644 src/plugins/platforms/openkode/qopenkodewindowsurface.cpp create mode 100644 src/plugins/platforms/openkode/qopenkodewindowsurface.h delete mode 100644 src/plugins/platforms/openkode/qwindowsurface_openkode.cpp delete mode 100644 src/plugins/platforms/openkode/qwindowsurface_openkode.h create mode 100644 src/plugins/platforms/openkode/resources.qrc create mode 100644 src/plugins/platforms/openkode/shaders/frag.glslf create mode 100644 src/plugins/platforms/openkode/shaders/vert.glslv delete mode 100644 src/plugins/platforms/openkode/vert.glslv delete mode 100644 src/plugins/platforms/openkode/vert.h diff --git a/src/plugins/platforms/openkode/frag.glslf b/src/plugins/platforms/openkode/frag.glslf deleted file mode 100644 index a593434..0000000 --- a/src/plugins/platforms/openkode/frag.glslf +++ /dev/null @@ -1,8 +0,0 @@ -uniform sampler2D tex_samp; - -varying vec2 texcoord_var; - -void main() -{ - gl_FragColor = texture2D(tex_samp, texcoord_var); -} diff --git a/src/plugins/platforms/openkode/frag.h b/src/plugins/platforms/openkode/frag.h deleted file mode 100644 index 6575cb5..0000000 --- a/src/plugins/platforms/openkode/frag.h +++ /dev/null @@ -1,37 +0,0 @@ -0x4e,0x56,0x75,0x63,0x01,0x00,0x00,0x00,0x09,0x00,0x06,0x00,0x06,0x00,0x50,0x00, -0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x50,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x40,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x27,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x50,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0xe8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x70,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x11,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xb0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x12,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0xc0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x2b,0x00,0x00,0x00,0x7a,0x00,0x00,0x00,0xd0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x2c,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x68,0x69,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff, -0x00,0x00,0x00,0x80,0x04,0x00,0x00,0x90,0x00,0x02,0x01,0x82,0x04,0x02,0x02,0x82, -0x01,0x00,0x40,0xf6,0x85,0xc7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x3a,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x2a,0x00,0x06,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0x3b,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x49,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x04,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0x00,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x00,0x00,0x00,0x74,0x65,0x78,0x63, -0x6f,0x6f,0x72,0x64,0x5f,0x76,0x61,0x72,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/src/plugins/platforms/openkode/main.cpp b/src/plugins/platforms/openkode/main.cpp index e9c1083..bd2b5c7 100644 --- a/src/plugins/platforms/openkode/main.cpp +++ b/src/plugins/platforms/openkode/main.cpp @@ -39,33 +39,33 @@ ** ****************************************************************************/ -#include -#include "qgraphicssystem_openkode.h" +#include +#include "qopenkodeintegration.h" QT_BEGIN_NAMESPACE -class QOpenKODEGraphicsSystemPlugin : public QGraphicsSystemPlugin +class QOpenKODEPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QGraphicsSystem *create(const QString&); + QPlatformIntegration *create(const QString&); }; -QStringList QOpenKODEGraphicsSystemPlugin::keys() const +QStringList QOpenKODEPlugin::keys() const { QStringList list; list << "OpenKODE"; return list; } -QGraphicsSystem* QOpenKODEGraphicsSystemPlugin::create(const QString& system) +QPlatformIntegration * QOpenKODEPlugin::create(const QString& system) { if (system.toLower() == "openkode") - return new QOpenKODEGraphicsSystem; + return new QOpenKODEIntegration; return 0; } -Q_EXPORT_PLUGIN2(openkode, QOpenKODEGraphicsSystemPlugin) +Q_EXPORT_PLUGIN2(openkode, QOpenKODEPlugin) QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/openkode.pro b/src/plugins/platforms/openkode/openkode.pro index 055048d..042b74d 100644 --- a/src/plugins/platforms/openkode/openkode.pro +++ b/src/plugins/platforms/openkode/openkode.pro @@ -1,14 +1,20 @@ -TARGET = qopenkodegraphicssystem +TARGET = qopenkodeintegration include(../../qpluginbase.pri) -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms -SOURCES = main.cpp qgraphicssystem_openkode.cpp qwindowsurface_openkode.cpp -HEADERS = qgraphicssystem_openkode.h qwindowsurface_openkode.h +SOURCES = main.cpp \ + qopenkodeintegration.cpp \ + qopenkodewindowsurface.cpp \ + qopenkodewindow.cpp -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +HEADERS = qopenkodeintegration.h \ + qopenkodewindowsurface.h \ + qopenkodewindow.h + +RESOURCES = resources.qrc + +target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target -# openkode specific stuff -INCLUDEPATH += $(OPENKODE_DIR)/include -LIBS += $${QMAKE_RPATH}/$(OPENKODE_DIR)/lib-target -L$(OPENKODE_DIR)/lib-target -lKD -lEGL -lGLESv2 +LIBS += -lKD -lEGL -lGLESv2 diff --git a/src/plugins/platforms/openkode/qgraphicssystem_openkode.cpp b/src/plugins/platforms/openkode/qgraphicssystem_openkode.cpp deleted file mode 100644 index 7a07776..0000000 --- a/src/plugins/platforms/openkode/qgraphicssystem_openkode.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicssystem_openkode.h" -#include "qwindowsurface_openkode.h" -#include - -#include -#include - -#include -#include -#include - -#include "GLES2/gl2ext.h" - - -QT_BEGIN_NAMESPACE - -QOpenKODEGraphicsSystemScreen::QOpenKODEGraphicsSystemScreen() -{ - KDDesktopNV *kdDesktop = KD_NULL; - KDDisplayNV *kdDisplay = KD_NULL; - - qDebug() << "QOpenKODEGraphicsSystemScreen::QOpenKODEGraphicsSystemScreen()"; - - // Get the default desktop and display - kdDesktop = kdGetDesktopNV(KD_DEFAULT_DESKTOP_NV, KD_NULL); - if (!kdDesktop || kdDesktop == (void*)-1) { - qErrnoWarning(kdGetError(), "Could not obtain KDDesktopNV pointer"); - return; - } - - kdDisplay = kdGetDisplayNV(KD_DEFAULT_DISPLAY_NV, KD_NULL); - if (!kdDisplay || kdDisplay == (void*)-1) { - qErrnoWarning(kdGetError(), "Could not obtain KDDisplayNV pointer"); - kdReleaseDesktopNV(kdDesktop); - return; - } - - KDDisplayModeNV mode; - if (kdGetDisplayModeNV(kdDisplay, &mode)) { - qErrnoWarning(kdGetError(), "Could not get display mode"); - return; - } - - qDebug() << " - display mode " << mode.width << "x" << mode.height << " refresh " << mode.refresh; - - KDint desktopSize[] = { mode.width, mode.height }; - - if (kdSetDesktopPropertyivNV(kdDesktop, KD_DESKTOPPROPERTY_SIZE_NV, desktopSize)) { - qErrnoWarning(kdGetError(), "Could not set desktop size"); - return; - } - - // Once we've set up the desktop and display we don't need them anymore - kdReleaseDisplayNV(kdDisplay); - kdReleaseDesktopNV(kdDesktop); - - const int defaultDpi = 72; - mGeometry = QRect(0, 0, mode.width, mode.height); - mPhysicalSize = QSize(mode.width * 25.4 / defaultDpi, mode.height * 25.4 / defaultDpi); - - mDepth = 24; - mFormat = QImage::Format_RGB888; - - - QEglProperties properties; - properties.setPixelFormat(QImage::Format_RGB888); - properties.setValue(EGL_BUFFER_SIZE, EGL_DONT_CARE); - properties.setRenderableType(QEgl::OpenGL); - - if (!mContext.chooseConfig(properties, QEgl::BestPixelFormat)) { - qWarning("qEglContext: Unable to choose config!"); - return; - } - - if (!mContext.display()) { - qWarning("qEglContext: Unable to open display!"); - return; - } - - qDebug() << " - QEglContext::openDisplay OK"; -} - -static GLuint NvKdTestLoadShaders(const char *vertex_shader_binary, - const char *fragment_shader_binary, - GLuint vertex_shader_binary_size, - GLuint fragment_shader_binary_size) -{ - GLuint prog; - GLuint vertShader; - GLuint fragShader; - - // Create the program - prog = glCreateProgram(); - - // Create the GL shader objects - vertShader = glCreateShader(GL_VERTEX_SHADER); - fragShader = glCreateShader(GL_FRAGMENT_SHADER); - - // Load the binary data into the shader objects - glShaderBinary(1, &vertShader, - GL_NVIDIA_PLATFORM_BINARY_NV, vertex_shader_binary, vertex_shader_binary_size); - glShaderBinary(1, &fragShader, - GL_NVIDIA_PLATFORM_BINARY_NV, fragment_shader_binary, fragment_shader_binary_size); - - // Attach the shaders to the program - glAttachShader(prog, vertShader); - glAttachShader(prog, fragShader); - - // Delete the shaders - glDeleteShader(vertShader); - glDeleteShader(fragShader); - - // Link and validate the shader program - glLinkProgram(prog); - glValidateProgram(prog); - - return prog; -} - -class QOpenKODEEventLoopHelper : public QThread -{ -public: - QOpenKODEEventLoopHelper(QSemaphore *m) - : eventMutex(m) - { - m->acquire(); - } - -protected: - void run() - { - qDebug() << "initializing KD"; - kdInitializeNV(); - qDebug() << "done initializing KD"; - eventMutex->release(); - - const KDEvent *event; - while ((event = kdWaitEvent(-1)) != 0) { - qDebug() << "!!! received event!"; - kdDefaultEvent(event); - } - - qDebug() << "exiting event loop"; - } - -private: - QSemaphore *eventMutex; -}; - -QOpenKODEGraphicsSystem::QOpenKODEGraphicsSystem() - : eventMutex(1) -{ - QOpenKODEEventLoopHelper *loop = new QOpenKODEEventLoopHelper(&eventMutex); - loop->start(); - eventMutex.acquire(); // block until initialization done - - mPrimaryScreen = new QOpenKODEGraphicsSystemScreen(); - - mScreens.append(mPrimaryScreen); - -} - -QPixmapData *QOpenKODEGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - return new QRasterPixmapData(type); -} - -QWindowSurface *QOpenKODEGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - return new QOpenKODEWindowSurface(mPrimaryScreen, widget); -} - -GLuint QOpenKODEGraphicsSystem::blitterProgram() -{ - static GLuint shaderProgram = 0; - if (!shaderProgram) { - - const char vertShaderBinary[] = { -# include "vert.h" - }; - const char fragShaderBinary[] = { -# include "frag.h" - }; - - shaderProgram = NvKdTestLoadShaders(vertShaderBinary, fragShaderBinary, - sizeof(vertShaderBinary), sizeof(fragShaderBinary)); - - if (!shaderProgram) - qFatal("QOpenKodeGraphicsSystem(): Cannot load shaders!"); - } - return shaderProgram; -} - - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qgraphicssystem_openkode.h b/src/plugins/platforms/openkode/qgraphicssystem_openkode.h deleted file mode 100644 index 7d73ae0..0000000 --- a/src/plugins/platforms/openkode/qgraphicssystem_openkode.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSYSTEM_OPENKODE_H -#define QGRAPHICSSYSTEM_OPENKODE_H - -#include - -#include -#include - -# include - -QT_BEGIN_NAMESPACE - -struct KDDesktopNV; - -class QOpenKODEGraphicsSystemScreen : public QGraphicsSystemScreen -{ -public: - QOpenKODEGraphicsSystemScreen(); - ~QOpenKODEGraphicsSystemScreen() {} - - QRect geometry() const { return mGeometry; } - int depth() const { return mDepth; } - QImage::Format format() const { return mFormat; } - QSize physicalSize() const { return mPhysicalSize; } - -public: - QRect mGeometry; - int mDepth; - QImage::Format mFormat; - QSize mPhysicalSize; - QEglContext mContext; -}; - -class QOpenKODEGraphicsSystem : public QGraphicsSystem -{ -public: - QOpenKODEGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - - QList screens() const { return mScreens; } - - static GLuint blitterProgram(); - -private: - QOpenKODEGraphicsSystemScreen *mPrimaryScreen; - QList mScreens; - QSemaphore eventMutex; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp new file mode 100644 index 0000000..d9430c2 --- /dev/null +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -0,0 +1,227 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qopenkodeintegration.h" +#include "qopenkodewindowsurface.h" +#include "qopenkodewindow.h" + +#include + +#include +#include +#include + +#include +#include +#include + +#include "GLES2/gl2ext.h" + +#include + + +QT_BEGIN_NAMESPACE + +QOpenKODEScreen::QOpenKODEScreen() +{ + KDDesktopNV *kdDesktop = KD_NULL; + KDDisplayNV *kdDisplay = KD_NULL; + + qDebug() << "QOpenKODEScreen::QOpenKODEIntegrationScreen()"; + + // Get the default desktop and display + kdDesktop = kdGetDesktopNV(KD_DEFAULT_DESKTOP_NV, KD_NULL); + if (!kdDesktop || kdDesktop == (void*)-1) { + qErrnoWarning(kdGetError(), "Could not obtain KDDesktopNV pointer"); + return; + } + + kdDisplay = kdGetDisplayNV(KD_DEFAULT_DISPLAY_NV, KD_NULL); + if (!kdDisplay || kdDisplay == (void*)-1) { + qErrnoWarning(kdGetError(), "Could not obtain KDDisplayNV pointer"); + kdReleaseDesktopNV(kdDesktop); + return; + } + + KDDisplayModeNV mode; + if (kdGetDisplayModeNV(kdDisplay, &mode)) { + qErrnoWarning(kdGetError(), "Could not get display mode"); + return; + } + + qDebug() << " - display mode " << mode.width << "x" << mode.height << " refresh " << mode.refresh; + + KDint desktopSize[] = { mode.width, mode.height }; + + if (kdSetDesktopPropertyivNV(kdDesktop, KD_DESKTOPPROPERTY_SIZE_NV, desktopSize)) { + qErrnoWarning(kdGetError(), "Could not set desktop size"); + return; + } + + // Once we've set up the desktop and display we don't need them anymore + kdReleaseDisplayNV(kdDisplay); + kdReleaseDesktopNV(kdDesktop); + + const int defaultDpi = 72; + mGeometry = QRect(0, 0, mode.width, mode.height); + mPhysicalSize = QSize(mode.width * 25.4 / defaultDpi, mode.height * 25.4 / defaultDpi); + + mDepth = 24; + mFormat = QImage::Format_RGB32; +} + +static GLuint loadShaders(const QString &vertexShader, const QString &fragmentShader) +{ + GLuint prog = 0; + GLuint vertShader; + GLuint fragShader; + + // Create the program + prog = glCreateProgram(); + + // Create the GL shader objects + vertShader = glCreateShader(GL_VERTEX_SHADER); + fragShader = glCreateShader(GL_FRAGMENT_SHADER); + + // Load shader sources into GL and compile + QFile vertexFile(vertexShader); + vertexFile.open(QFile::ReadOnly); + QByteArray vertSource = vertexFile.readAll(); + const char *vertChar = vertSource.constData(); + int vertSize = vertSource.size(); + + QFile fragFile(fragmentShader); + fragFile.open(QFile::ReadOnly); + QByteArray fragSource = fragFile.readAll(); + const char *fragChar = fragSource.constData(); + int fragSize = fragSource.size(); + + glShaderSource(vertShader, 1, (const char**)&vertChar, &vertSize); + glCompileShader(vertShader); + + glShaderSource(fragShader, 1, (const char**)&fragChar, &fragSize); + glCompileShader(fragShader); + + // Attach the shaders to the program + glAttachShader(prog, vertShader); + glAttachShader(prog, fragShader); + + // Delete the shaders + glDeleteShader(vertShader); + glDeleteShader(fragShader); + + // Link and validate the shader program + glLinkProgram(prog); + glValidateProgram(prog); + + return prog; +} + +class QOpenKODEEventLoopHelper : public QThread +{ +public: + QOpenKODEEventLoopHelper(QSemaphore *m) + : eventMutex(m) + { + m->acquire(); + } + +protected: + void run() + { + if (kdInitializeNV() == KD_ENOTINITIALIZED) { + qFatal("Did not manage to initialize openkode"); + } + eventMutex->release(); + + const KDEvent *event; + while ((event = kdWaitEvent(-1)) != 0) { + qDebug() << "!!! received event!"; + kdDefaultEvent(event); + } + } + +private: + QSemaphore *eventMutex; +}; + +QOpenKODEIntegration::QOpenKODEIntegration() + : eventMutex(1) +{ + QOpenKODEEventLoopHelper *loop = new QOpenKODEEventLoopHelper(&eventMutex); + loop->start(); + eventMutex.acquire(); // block until initialization done + + QOpenKODEScreen *mPrimaryScreen = new QOpenKODEScreen(); + + mScreens.append(mPrimaryScreen); + +} + +QPixmapData *QOpenKODEIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QPlatformWindow *QOpenKODEIntegration::createPlatformWindow(QWidget *tlw, WId ) const +{ + return new QOpenKODEWindow(tlw); +} + +QWindowSurface *QOpenKODEIntegration::createWindowSurface(QWidget *widget, WId winId) const +{ + return new QOpenKODEWindowSurface(widget,winId); +} + +GLuint QOpenKODEIntegration::blitterProgram() +{ + static GLuint shaderProgram = 0; + if (!shaderProgram) { + + shaderProgram = loadShaders(":/shaders/vert.glslv",":/shaders/frag.glslf"); + if (!shaderProgram) + qFatal("QOpenKodeGraphicsSystem(): Cannot load shaders!"); + } + return shaderProgram; +} + + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h new file mode 100644 index 0000000..76ce219 --- /dev/null +++ b/src/plugins/platforms/openkode/qopenkodeintegration.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_OPENKODE_H +#define QGRAPHICSSYSTEM_OPENKODE_H + +#include + +#include +#include +#include + +# include + +QT_BEGIN_NAMESPACE + +struct KDDesktopNV; + +class QOpenKODEScreen : public QPlatformScreen +{ +public: + QOpenKODEScreen(); + ~QOpenKODEScreen() {} + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; +}; + +class QOpenKODEIntegration : public QPlatformIntegration +{ +public: + QOpenKODEIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + + virtual QList screens() const { return mScreens; } + + static GLuint blitterProgram(); + +private: + QList mScreens; + QSemaphore eventMutex; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp new file mode 100644 index 0000000..8e1527c --- /dev/null +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qopenkodewindow.h" + +#include + +#include +#include +#include + +QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) + : QPlatformWindow(tlw) +{ + /* Initialize EGL display */ + EGLBoolean rvbool = eglInitialize(QEgl::display(), KD_NULL, KD_NULL); + if (!rvbool) { + kdLogMessage("EGL failed to initialize display\n"); + } + + kdWindow = kdCreateWindow(QEgl::display(), + QEgl::defaultConfig(QInternal::Widget,QEgl::OpenGL,QEgl::Renderable), + KD_NULL); + if (!kdWindow) { + qErrnoWarning(kdGetError(), "Error creating native window"); + return; + } + + const KDint windowSize[2] = { tlw->width(), tlw->height() }; + if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { + qErrnoWarning(kdGetError(), "Could not set native window size"); + return; + } + +// const KDboolean windowExclusive[] = { false }; +// if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, windowExclusive)) { +// qErrnoWarning(kdGetError(), "Could not set exclusive bit"); +// //return; +// } +// +// const KDint windowPos[2] = { tlw->x(), tlw->y() }; +// if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { +// qErrnoWarning(kdGetError(), "Could not set native window position"); +// return; +// } + + if (kdRealizeWindow(kdWindow, &eglWindow)) { + qErrnoWarning(kdGetError(), "Could not realize native window"); + return; + } +} + +void QOpenKODEWindow::setGeometry(const QRect &rect) +{ + const QRect geo = geometry(); + if (geo.size() != rect.size()) { + const KDint windowSize[2] = { rect.width(), rect.height() }; + if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { + qErrnoWarning(kdGetError(), "Could not set native window size"); + //return; + } + } + +// if (geo.topLeft() != rect.topLeft()) { +// const KDint windowPos[2] = { rect.x(), rect.y() }; +// if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { +// qErrnoWarning(kdGetError(), "Could not set native window position"); +// //return; +// } +// } + +} + +void QOpenKODEWindow::setVisible(bool visible) +{ + +} diff --git a/src/plugins/platforms/openkode/qopenkodewindow.h b/src/plugins/platforms/openkode/qopenkodewindow.h new file mode 100644 index 0000000..b52f8e6 --- /dev/null +++ b/src/plugins/platforms/openkode/qopenkodewindow.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOPENKODEWINDOW_H +#define QOPENKODEWINDOW_H + +#include + +#include + +class QOpenKODEWindow : public QPlatformWindow +{ +public: + QOpenKODEWindow(QWidget *tlw); + + void setGeometry(const QRect &rect); + void setVisible(bool visible); + WId winId() const { return WId(eglWindow); } + +private: + struct KDWindow *kdWindow; + EGLNativeWindowType eglWindow; +}; + +#endif //QOPENKODEWINDOW_H diff --git a/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp b/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp new file mode 100644 index 0000000..5eb0d2d --- /dev/null +++ b/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp @@ -0,0 +1,187 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qopenkodewindowsurface.h" +#include "qopenkodeintegration.h" + +#include "qopenkodewindow.h" + +#include + +QT_BEGIN_NAMESPACE + +QOpenKODEWindowSurface::QOpenKODEWindowSurface + (QWidget *window, WId winId) + : QWindowSurface(window), + mSurface(EGL_NO_SURFACE), + mWin((EGLNativeWindowType) winId) +{ + EGLConfig config = QEgl::defaultConfig(QInternal::Widget,QEgl::OpenGL,QEgl::Renderable); + mContext.setConfig(config); + if (!mContext.createContext()) { + qWarning("QOpenKODEWindowSurface: Unable to create context"); + return; + } +} + +QOpenKODEWindowSurface::~QOpenKODEWindowSurface() +{ +} + +QPaintDevice *QOpenKODEWindowSurface::paintDevice() +{ + return &mImage; +} + +// ### TODO - this updates the entire toplevel, should only update the region +void QOpenKODEWindowSurface::flush(QWidget *, const QRegion ®ion, const QPoint &offset) +{ + mContext.makeCurrent(mSurface); + + if (!offset.isNull()) { + qWarning("Offset flushing not supported yet"); + return; + } + + if (!mContext.makeCurrent(mSurface)) { + qWarning("EGL couldn't make context/surface current: 0x%x", eglGetError()); + return; + } + + QRect boundingRect = region.boundingRect(); + + int x, y, w, h; + QImage blitImage; + if (true || boundingRect == mImage.rect()) { // TODO - check optimization + blitImage = mImage; + x = y = 0; + w = mImage.width(); + h = mImage.height(); + } else { + blitImage = mImage.copy(boundingRect); + w = boundingRect.width(); + h = boundingRect.height(); + x = boundingRect.x(); + y = boundingRect.y(); + } + +// qDebug() << "flush" << widget << offset << region.boundingRect() << mImage.format() << blitImage.format(); + + GLuint shaderProgram = QOpenKODEIntegration::blitterProgram(); + + glUseProgram(shaderProgram); + + GLuint index = glGetUniformLocation(shaderProgram, "window"); + glUniform2f(index, GLfloat(mImage.width()), GLfloat(mImage.height())); + + // attributes + GLuint posId = glGetAttribLocation(shaderProgram, "pos_attr"); + GLuint texcoordId = glGetAttribLocation(shaderProgram, "texcoord_attr"); + + // sampler + index = glGetUniformLocation(shaderProgram, "tex_samp"); + + glUniform1i(index, 0); + + glDisable(GL_DEPTH_TEST); + glActiveTexture(GL_TEXTURE0); + + GLuint texId; + GLfloat coords[8] = {x, y, x, y + h, x + w, y + h, x + w, y }; + GLfloat texcoords[8] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0 }; + + // Generate texture for checkered background + glGenTextures(1, &texId); + glBindTexture(GL_TEXTURE_2D, texId); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, blitImage.bits()); + + // Enable vertex attribute associated with vertex position + glEnableVertexAttribArray(posId); + glEnableVertexAttribArray(texcoordId); + + // Set the quad vertices + glVertexAttribPointer(posId, 2, GL_FLOAT, 0, 0, coords); + glVertexAttribPointer(texcoordId, 2, GL_FLOAT, 0, 0, texcoords); + + // Draw the quad + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + + // Cleanup + glDisableVertexAttribArray(posId); + glDisableVertexAttribArray(texcoordId); + + // Release all textures + glBindTexture(GL_TEXTURE_2D, 0); + if (texId) + glDeleteTextures(1, &texId); + + mContext.swapBuffers(mSurface); + mContext.doneCurrent(); +} + +void QOpenKODEWindowSurface::resize(const QSize &size) +{ + QWindowSurface::resize(size); + mContext.destroySurface(mSurface); + mSurface = EGL_NO_SURFACE; + mImage = QImage(); + +} +void QOpenKODEWindowSurface::beginPaint(const QRegion ®ion) +{ + if (mSurface == EGL_NO_SURFACE) { + EGLConfig config = QEgl::defaultConfig(QInternal::Widget,QEgl::OpenGL,QEgl::Renderable); + EGLint windowAttrs[] = { EGL_NONE }; + mSurface = eglCreateWindowSurface(QEgl::display(), config, mWin, windowAttrs); + mImage = QImage(size(),QImage::Format_RGB32); + } +} + +void QOpenKODEWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qopenkodewindowsurface.h b/src/plugins/platforms/openkode/qopenkodewindowsurface.h new file mode 100644 index 0000000..568dbc2 --- /dev/null +++ b/src/plugins/platforms/openkode/qopenkodewindowsurface.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_OPENKODE_H +#define QWINDOWSURFACE_OPENKODE_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QOpenKODEWindow; + +class QOpenKODEWindowSurface : public QWindowSurface +{ +public: + QOpenKODEWindowSurface + (QWidget *window, WId winId); + ~QOpenKODEWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void resize (const QSize &size); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + +private: + QImage mImage; + EGLSurface mSurface; + QEglContext mContext; + EGLNativeWindowType mWin; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/openkode/qwindowsurface_openkode.cpp b/src/plugins/platforms/openkode/qwindowsurface_openkode.cpp deleted file mode 100644 index b3f3965..0000000 --- a/src/plugins/platforms/openkode/qwindowsurface_openkode.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindowsurface_openkode.h" -#include "qgraphicssystem_openkode.h" -#include - -#include "KD/kd.h" -#include "KD/NV_display.h" - -QT_BEGIN_NAMESPACE - -QOpenKODEWindowSurface::QOpenKODEWindowSurface - (QOpenKODEGraphicsSystemScreen *screen, QWidget *window) - : QWindowSurface(window), - mScreen(screen), - mSurface(0) -{ - qDebug() << "QOpenKODEWindowSurface::QOpenKODEWindowSurface:" << window << window->width() << "x" << window->height() - << "pos" << window->x() << "x" << window->y(); - - if (!mContext.display()) { - qWarning("qEglContext: Unable to open display!"); - return; - } - - QEglProperties properties; - properties.setPixelFormat(QImage::Format_RGB888); - properties.setValue(EGL_BUFFER_SIZE, EGL_DONT_CARE); - properties.setRenderableType(QEgl::OpenGL); - - if (!mContext.chooseConfig(properties, QEgl::BestPixelFormat)) { - qWarning("qEglContext: Unable to choose config!"); - return; - } - - createWindow(window); -} - -void QOpenKODEWindowSurface::createWindow(QWidget *window) -{ - qDebug() << "createWindow"; - kdWindow = kdCreateWindow(mContext.display(), mContext.config(), KD_NULL); - - if (!kdWindow) { - qErrnoWarning(kdGetError(), "Error creating native window"); - return; - } - - const KDint windowSize[2] = { window->width(), window->height() }; - if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { - qErrnoWarning(kdGetError(), "Could not set native window size"); - return; - } - - //const KDboolean windowExclusive[] = { false }; - //if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, windowExclusive)) { - // qErrnoWarning(kdGetError(), "Could not set exclusive bit"); - // //return; - //} - - //const KDint windowPos[2] = { window->x(), window->y() }; - //if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { - // qErrnoWarning(kdGetError(), "Could not set native window position"); - // //return; - //} - - EGLNativeWindowType nativeWindow; - - if (kdRealizeWindow(kdWindow, &nativeWindow)) { - qErrnoWarning(kdGetError(), "Could not realize native window"); - return; - } - qDebug() << "kdRealizeWindow" << nativeWindow; - - // Create an EGL window surface for the native window - EGLint windowAttrs[3] = { EGL_NONE }; - qDebug() << "doing createwindowsurface"; - *mSurface = eglCreateWindowSurface(mContext.display(), - mContext.config(), - nativeWindow, - windowAttrs); - qDebug() << "create windowsurface"; - if (!mSurface) { - qWarning("EGL couldn't create window surface: 0x%x", eglGetError()); - return; - } - - qDebug() << "making context"; - if (!mContext.createContext()) { - qDebug() << "Unable to create context!"; - return; - } - - qDebug() << "about to make current"; - mContext.makeCurrent(mSurface); -} - -QOpenKODEWindowSurface::~QOpenKODEWindowSurface() -{ -} - -QPaintDevice *QOpenKODEWindowSurface::paintDevice() -{ - qDebug() << "QOpenKODEWindowSurface::paintDevice"; - return &mImage; -} - -// ### TODO - this updates the entire toplevel, should only update the region -void QOpenKODEWindowSurface::flush(QWidget *, const QRegion ®ion, const QPoint &offset) -{ - qDebug() << "in flush"; - if (!offset.isNull()) { - qWarning("Offset flushing not supported yet"); - return; - } - - if (!mContext.makeCurrent(mSurface)) { - qWarning("EGL couldn't make context/surface current: 0x%x", eglGetError()); - return; - } - - QRect boundingRect = region.boundingRect(); - - int x, y, w, h; - QImage blitImage; - if (true || boundingRect == mImage.rect()) { // TODO - check optimization - blitImage = mImage; - x = y = 0; - w = mImage.width(); - h = mImage.height(); - } else { - blitImage = mImage.copy(boundingRect); - w = boundingRect.width(); - h = boundingRect.height(); - x = boundingRect.x(); - y = boundingRect.y(); - } - -// qDebug() << "flush" << widget << offset << region.boundingRect() << mImage.format() << blitImage.format(); - - GLuint shaderProgram = QOpenKODEGraphicsSystem::blitterProgram(); - - glUseProgram(shaderProgram); - - GLuint index = glGetUniformLocation(shaderProgram, "window"); - glUniform2f(index, GLfloat(mImage.width()), GLfloat(mImage.height())); - - // attributes - GLuint posId = glGetAttribLocation(shaderProgram, "pos_attr"); - GLuint texcoordId = glGetAttribLocation(shaderProgram, "texcoord_attr"); - - // sampler - index = glGetUniformLocation(shaderProgram, "tex_samp"); - - glUniform1i(index, 0); - - glDisable(GL_DEPTH_TEST); - glActiveTexture(GL_TEXTURE0); - - GLuint texId; - GLfloat coords[8] = {x, y, x, y + h, x + w, y + h, x + w, y }; - GLfloat texcoords[8] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0 }; - - // Generate texture for checkered background - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glGenTextures(1, &texId); - glBindTexture(GL_TEXTURE_2D, texId); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, blitImage.bits()); - - // Enable vertex attribute associated with vertex position - glEnableVertexAttribArray(posId); - glEnableVertexAttribArray(texcoordId); - - // Set the quad vertices - glVertexAttribPointer(posId, 2, GL_FLOAT, 0, 0, coords); - glVertexAttribPointer(texcoordId, 2, GL_FLOAT, 0, 0, texcoords); - - // Draw the quad - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - // Cleanup - glDisableVertexAttribArray(posId); - glDisableVertexAttribArray(texcoordId); - - // Release all textures - glBindTexture(GL_TEXTURE_2D, 0); - if (texId) - glDeleteTextures(1, &texId); - - mContext.doneCurrent(); - mContext.swapBuffers(mSurface); -} - -void QOpenKODEWindowSurface::setGeometry(const QRect &rect) -{ - qDebug() << "QOpenKODEWindowSurface::setGeometry:" << rect; - QWindowSurface::setGeometry(rect); - if (mImage.size() != rect.size()) - mImage = QImage(rect.size(), mScreen->format()); - - mContext.destroySurface(mSurface); - kdDestroyWindow(kdWindow); - createWindow(window()); - qDebug() << "set geometry workded"; -} - -bool QOpenKODEWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - return QWindowSurface::scroll(area, dx, dy); -} - -void QOpenKODEWindowSurface::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -void QOpenKODEWindowSurface::endPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qwindowsurface_openkode.h b/src/plugins/platforms/openkode/qwindowsurface_openkode.h deleted file mode 100644 index bee94a5..0000000 --- a/src/plugins/platforms/openkode/qwindowsurface_openkode.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_OPENKODE_H -#define QWINDOWSURFACE_OPENKODE_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QOpenKODEGraphicsSystemScreen; - -class QOpenKODEWindowSurface : public QWindowSurface -{ -public: - QOpenKODEWindowSurface - (QOpenKODEGraphicsSystemScreen *screen, QWidget *window); - ~QOpenKODEWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - -private: - QOpenKODEGraphicsSystemScreen *mScreen; - QImage mImage; - struct KDWindow *kdWindow; - EGLSurface *mSurface; - QEglContext mContext; - - void createWindow(QWidget *window); -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/openkode/resources.qrc b/src/plugins/platforms/openkode/resources.qrc new file mode 100644 index 0000000..dbb3419 --- /dev/null +++ b/src/plugins/platforms/openkode/resources.qrc @@ -0,0 +1,6 @@ + + + shaders/vert.glslv + shaders/frag.glslf + + diff --git a/src/plugins/platforms/openkode/shaders/frag.glslf b/src/plugins/platforms/openkode/shaders/frag.glslf new file mode 100644 index 0000000..ed360fe --- /dev/null +++ b/src/plugins/platforms/openkode/shaders/frag.glslf @@ -0,0 +1,8 @@ +uniform sampler2D tex_samp; + +varying vec2 texcoord_var; + +void main(void) +{ + gl_FragColor = texture2D(tex_samp, texcoord_var); +} diff --git a/src/plugins/platforms/openkode/shaders/vert.glslv b/src/plugins/platforms/openkode/shaders/vert.glslv new file mode 100644 index 0000000..57b5866 --- /dev/null +++ b/src/plugins/platforms/openkode/shaders/vert.glslv @@ -0,0 +1,14 @@ +uniform vec2 window; // window size + +// Per-vertex attributes] +attribute vec2 pos_attr; +attribute vec2 texcoord_attr; + +// Output vertex color +varying vec2 texcoord_var; + +void main() +{ + gl_Position = vec4( (2.0 * pos_attr / window -1.0) * vec2(1.0, -1.0), 0.0, 1.0); + texcoord_var = texcoord_attr; +} diff --git a/src/plugins/platforms/openkode/vert.glslv b/src/plugins/platforms/openkode/vert.glslv deleted file mode 100644 index 57b5866..0000000 --- a/src/plugins/platforms/openkode/vert.glslv +++ /dev/null @@ -1,14 +0,0 @@ -uniform vec2 window; // window size - -// Per-vertex attributes] -attribute vec2 pos_attr; -attribute vec2 texcoord_attr; - -// Output vertex color -varying vec2 texcoord_var; - -void main() -{ - gl_Position = vec4( (2.0 * pos_attr / window -1.0) * vec2(1.0, -1.0), 0.0, 1.0); - texcoord_var = texcoord_attr; -} diff --git a/src/plugins/platforms/openkode/vert.h b/src/plugins/platforms/openkode/vert.h deleted file mode 100644 index bdf564d..0000000 --- a/src/plugins/platforms/openkode/vert.h +++ /dev/null @@ -1,63 +0,0 @@ -0x4e,0x56,0x75,0x63,0x01,0x00,0x00,0x00,0x0a,0x00,0x06,0x00,0x06,0x00,0x50,0x00, -0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0xf0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x60,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x24,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x70,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x26,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0xe8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x06,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0xb0,0x01,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x28,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x05,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x10,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x20,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x30,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x2b,0x00,0x00,0x00,0x39,0x01,0x00,0x00,0xb0,0x02,0x00,0x00,0x00,0x00,0x00,0x00, -0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x04,0x05,0x08,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x0f,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x01,0x02,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xff,0xff,0xff,0xff,0x04,0x05,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x80,0x3f,0x00,0x00,0x00,0x40,0x00,0x00,0x80,0xbf,0x00,0x00,0x00,0x00, -0x05,0x00,0x00,0x10,0x80,0xc7,0x00,0x24,0x05,0x02,0x00,0x10,0x80,0xc7,0x00,0x24, -0x01,0x02,0x81,0xc0,0x80,0x07,0x60,0x00,0x05,0x02,0x00,0x90,0x80,0x07,0x00,0x00, -0x09,0x00,0x01,0xe1,0x80,0x87,0x40,0x00,0x05,0x00,0x00,0x10,0x80,0xc7,0x00,0x24, -0x01,0x00,0x81,0xc0,0x80,0x07,0x60,0x00,0x09,0x04,0x00,0xa0,0x80,0x47,0x00,0xe4, -0x05,0x02,0x00,0x90,0x80,0x07,0x00,0x00,0x05,0x04,0x00,0x10,0x88,0xc7,0x03,0x04, -0x01,0x00,0x01,0xe1,0x88,0x87,0x40,0x00,0x09,0xf8,0x00,0x10,0x88,0xc7,0x03,0x04, -0x0d,0x00,0x00,0x10,0x88,0xc7,0x40,0x24,0x11,0x04,0x00,0x10,0x88,0xc7,0x23,0x04, -0x15,0x06,0x00,0x10,0x89,0xc7,0x23,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xa0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xa1,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0xad,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x28,0x00,0x02,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00, -0xb6,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xb7,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0xbe,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x05,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xbf,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0xc9,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x01,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xca,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xcb,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0xd9,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x01,0x00,0x00,0x00, -0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xda,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xdb,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0xe8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x26,0x00,0x02,0x00,0x00,0x00, -0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0x00,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x50,0x4f,0x53, -0x49,0x54,0x49,0x4f,0x4e,0x00,0x00,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x00,0x00, -0x70,0x6f,0x73,0x5f,0x61,0x74,0x74,0x72,0x00,0x00,0x00,0x74,0x65,0x78,0x63,0x6f, -0x6f,0x72,0x64,0x5f,0x61,0x74,0x74,0x72,0x00,0x00,0x00,0x74,0x65,0x78,0x63,0x6f, -0x6f,0x72,0x64,0x5f,0x76,0x61,0x72,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 -- cgit v0.12 From dbc2f9202688c56495b3f6d8cd3b977a9ae69a80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 29 Apr 2010 08:45:28 +0200 Subject: Compile with QT_NO_FSFILEENGINE. --- src/gui/dialogs/qfileinfogatherer_p.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/dialogs/qfileinfogatherer_p.h b/src/gui/dialogs/qfileinfogatherer_p.h index 5abcd94..4fe691e 100644 --- a/src/gui/dialogs/qfileinfogatherer_p.h +++ b/src/gui/dialogs/qfileinfogatherer_p.h @@ -84,10 +84,13 @@ public: && permissions() == fileInfo.permissions(); } +#ifndef QT_NO_FSFILEENGINE bool isCaseSensitive() const { QFSFileEngine fe(mFileInfo.absoluteFilePath()); return fe.caseSensitive(); } +#endif + QFile::Permissions permissions() const { return mFileInfo.permissions(); } -- cgit v0.12 From 4a7c8a2c12d5a1df34d1ae921e0ee709e2e0a904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 29 Apr 2010 08:49:03 +0200 Subject: Compile with QT_NO_CURSOR. --- src/gui/kernel/qwidget_lite.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index ee1a582..64fb6f7 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -686,6 +686,7 @@ void QWidgetPrivate::setModal_sys() { } +#ifndef QT_NO_CURSOR void qt_lite_set_cursor(QWidget * w, bool force) { static QPointer lastUnderMouse = 0; @@ -732,4 +733,6 @@ void qt_lite_set_cursor(QWidget * w, bool force) QCursor c = w->cursor(); cursor->changeCursor(&c, w); } +#endif //QT_NO_CURSOR + QT_END_NAMESPACE -- cgit v0.12 From d8a7d478681eaa6d92b70e3836eddc0fd52e79ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 29 Apr 2010 08:51:28 +0200 Subject: Compile with QT_NO_QWS_INPUTMETHODS --- src/gui/kernel/qapplication_lite.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index fae7663..f9e4242 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -447,6 +447,7 @@ static void init_plugins(const QList pluginList) } } +#ifndef QT_NO_QWS_INPUTMETHODS class QDummyInputContext : public QInputContext { public: @@ -459,6 +460,7 @@ public: bool isComposing() const { return false; } }; +#endif // QT_NO_QWS_INPUTMETHODS void qt_init(QApplicationPrivate *priv, int type) { -- cgit v0.12 From 385d2d14bc7994c3abb1de11dacf9a81eea01d4a Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 27 Apr 2010 15:59:50 +0200 Subject: Add QPlatformGLWidgetSurface to GL integrtation This class is a way to for the GL platform integration to track the movement and resizing of a QGLWidget with respect to the top-level. Most platform implementations will seperate the surface from the context anyway, so this is a natural abstraction. --- src/gui/kernel/qplatformintegration_lite.cpp | 2 +- src/gui/kernel/qplatformintegration_lite.h | 3 +- src/opengl/qgl.h | 9 ++ src/opengl/qgl_lite.cpp | 47 ++++--- src/opengl/qgl_p.h | 4 +- src/opengl/qglplatformintegration_lite.h | 26 ++-- src/plugins/platforms/testlite/qglxglcontext.cpp | 150 --------------------- src/plugins/platforms/testlite/qglxglcontext.h | 73 ---------- src/plugins/platforms/testlite/qglxintegration.cpp | 150 +++++++++++++++++++++ src/plugins/platforms/testlite/qglxintegration.h | 73 ++++++++++ 10 files changed, 283 insertions(+), 254 deletions(-) delete mode 100644 src/plugins/platforms/testlite/qglxglcontext.cpp delete mode 100644 src/plugins/platforms/testlite/qglxglcontext.h create mode 100644 src/plugins/platforms/testlite/qglxintegration.cpp create mode 100644 src/plugins/platforms/testlite/qglxintegration.h diff --git a/src/gui/kernel/qplatformintegration_lite.cpp b/src/gui/kernel/qplatformintegration_lite.cpp index 3fa874c..2d181f1 100644 --- a/src/gui/kernel/qplatformintegration_lite.cpp +++ b/src/gui/kernel/qplatformintegration_lite.cpp @@ -67,7 +67,7 @@ QPlatformGLContext * QPlatformIntegration::createGLContext() return 0; } -QPlatformGLWidgetSurface * QPlatformIntegration::createGLWidgetSurface(QGLWidget*) +QPlatformGLWidgetSurface * QPlatformIntegration::createGLWidgetSurface() { return 0; } diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h index 70bd0ce..a509b52 100644 --- a/src/gui/kernel/qplatformintegration_lite.h +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -54,7 +54,6 @@ QT_MODULE(Gui) #ifndef QT_NO_OPENGL class QPlatformGLContext; class QPlatformGLWidgetSurface; -class QGLWidget; #endif class Q_GUI_EXPORT QPlatformIntegration @@ -76,7 +75,7 @@ public: #ifndef QT_NO_OPENGL virtual bool hasOpenGL() const; virtual QPlatformGLContext * createGLContext(); - virtual QPlatformGLWidgetSurface * createGLWidgetSurface(QGLWidget*); + virtual QPlatformGLWidgetSurface * createGLWidgetSurface(); #endif }; diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index b1e2ede..e389e3f 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -128,6 +128,10 @@ class QGLOverlayWidget; class QGLWidgetPrivate; class QGLContextPrivate; +#ifdef Q_WS_LITE +class QPlatformGLWidgetSurface; +#endif + // Namespace class: namespace QGL { @@ -531,6 +535,11 @@ public: void drawTexture(const QPointF &point, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D); #endif +#ifdef Q_WS_LITE + // Used by the platform context to get at the surface which it created for the glwidget: + QPlatformGLWidgetSurface* platformSurface(); +#endif + public Q_SLOTS: virtual void updateGL(); virtual void updateOverlayGL(); diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp index 2a70545..fa1439c 100644 --- a/src/opengl/qgl_lite.cpp +++ b/src/opengl/qgl_lite.cpp @@ -60,7 +60,7 @@ QPlatformGLContext::~QPlatformGLContext() { } -QPlatformGLWidgetSurface::QPlatformGLWidgetSurface(QGLWidget*) +QPlatformGLWidgetSurface::QPlatformGLWidgetSurface() { } @@ -149,22 +149,30 @@ void QGLWidget::setContext(QGLContext *context, QGLContext* oldcx = d->glcx; d->glcx = context; - // If the application has set WA_TranslucentBackground and not explicitly set - // the alpha buffer size to zero, modify the format so it have an alpha channel - QGLFormat& fmt = d->glcx->d_func()->glFormat; - if (testAttribute(Qt::WA_TranslucentBackground) && fmt.alphaBufferSize() == -1) - fmt.setAlphaBufferSize(1); + if (!d->wsurf) { + // If the application has set WA_TranslucentBackground and not explicitly set + // the alpha buffer size to zero, modify the format so it have an alpha channel + QGLFormat format = d->glcx->d_func()->glFormat; + if (testAttribute(Qt::WA_TranslucentBackground) && format.alphaBufferSize() == -1) + format.setAlphaBufferSize(1); + + d->wsurf = QApplicationPrivate::platformIntegration()->createGLWidgetSurface(); + d->wsurf->create(this, format); + d->glcx->d_func()->glFormat = format; + } - bool success = false; if (!d->glcx->isValid()) - success = !d->glcx->create(shareContext ? shareContext : oldcx); + d->glcx->create(shareContext ? shareContext : oldcx); if (deleteOldContext) delete oldcx; } - - +QPlatformGLWidgetSurface* QGLWidget::platformSurface() +{ + Q_D(QGLWidget); + return d->wsurf; +} void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) { @@ -181,7 +189,7 @@ QColor QGLContext::overlayTransparentColor() const return QColor(); // Invalid color } -uint QGLContext::colorIndex(const QColor& c) const +uint QGLContext::colorIndex(const QColor&) const { return 0; } @@ -214,7 +222,7 @@ QGLTemporaryContext::~QGLTemporaryContext() } -bool QGLWidgetPrivate::renderCxPm(QPixmap* pm) +bool QGLWidgetPrivate::renderCxPm(QPixmap*) { return false; } @@ -234,7 +242,7 @@ void QGLWidget::setMouseTracking(bool enable) bool QGLWidget::event(QEvent *e) { - QWidget::event(e); + return QWidget::event(e); } void QGLWidget::resizeEvent(QResizeEvent *) @@ -242,10 +250,17 @@ void QGLWidget::resizeEvent(QResizeEvent *) Q_D(QGLWidget); if (!isValid()) return; + + if (!d->wsurf) { + qWarning("QGLWidget::resizeEvent() - widget does not have a platform surface"); + return; + } + d->wsurf->setGeometry(geometry()); //### What about moveEvent? + makeCurrent(); -// if (!d->glcx->initialized()) -// glInit(); -// resizeGL(width(), height()); + if (!d->glcx->initialized()) + glInit(); + resizeGL(width(), height()); } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index c7cd3fe..34cbdfc 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -165,7 +165,7 @@ class QGLWidgetPrivate : public QWidgetPrivate public: QGLWidgetPrivate() : QWidgetPrivate() , disable_clear_on_painter_begin(false) -#ifdef Q_WS_QWS +#if defined(Q_WS_QWS) || defined(Q_WS_LITE) , wsurf(0) #endif #if defined(Q_WS_X11) && !defined(QT_NO_EGL) @@ -207,6 +207,8 @@ public: void updatePaintDevice(); #elif defined(Q_WS_QWS) QWSGLWindowSurface *wsurf; +#elif defined (Q_WS_LITE) + QPlatformGLWidgetSurface* wsurf; #endif }; diff --git a/src/opengl/qglplatformintegration_lite.h b/src/opengl/qglplatformintegration_lite.h index d5bae45..94d4da0 100644 --- a/src/opengl/qglplatformintegration_lite.h +++ b/src/opengl/qglplatformintegration_lite.h @@ -48,13 +48,27 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +// QGLPlatformWidgetSurface does _not_ inherit from QWindowSurface +// - The backing store may be totally unaware of it's existance. +class Q_OPENGL_EXPORT QPlatformGLWidgetSurface +{ +public: + QPlatformGLWidgetSurface(); + virtual ~QPlatformGLWidgetSurface(); + + virtual bool create(QGLWidget*, QGLFormat&) = 0; + + virtual void setGeometry(const QRect&) = 0; +}; + + class Q_OPENGL_EXPORT QPlatformGLContext { public: QPlatformGLContext(); virtual ~QPlatformGLContext(); - virtual bool create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext) = 0; + virtual bool create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext) = 0; virtual void makeCurrent() = 0; virtual void doneCurrent() = 0; @@ -63,16 +77,6 @@ public: }; -// QGLPlatformWidgetSurface does _not_ inherit from QWindowSurface -// - The backing store may be totally unaware of it's existance. -class QPlatformGLWidgetSurface -{ -public: - QPlatformGLWidgetSurface(QGLWidget*); - virtual ~QPlatformGLWidgetSurface(); - - virtual void setGeometry(const QRect&) = 0; -}; QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qglxglcontext.cpp b/src/plugins/platforms/testlite/qglxglcontext.cpp deleted file mode 100644 index 6fdbb56..0000000 --- a/src/plugins/platforms/testlite/qglxglcontext.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "x11util.h" -#include "qglxglcontext.h" -#include - -#include - -#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) -#include -#endif - - -QT_BEGIN_NAMESPACE - -QGLXGLContext::QGLXGLContext(Display *xdpy) - : QPlatformGLContext() - , m_display(xdpy) - , m_context(0) - , m_widget(0) -{ -} - -QGLXGLContext::~QGLXGLContext() -{ - if (m_context) { - qDebug("Destroying GLX context 0x%x", m_context); - glXDestroyContext(m_display, m_context); - } -} - -bool QGLXGLContext::create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext) -{ - if (device->devType() != QInternal::Widget) { - qWarning("Creating a GL context is only supported on QWidgets"); - return false; - } - - m_widget = static_cast(device); - if (!m_widget->isTopLevel()) { - qWarning("Creating a GL context is only supported on top-level QWidgets"); - return false; - } - - // Get the XVisualInfo for the window: -// XWindowAttributes windowAttribs; -// XGetWindowAttributes(m_display, m_widget->winId(), &windowAttribs); - XVisualInfo visualInfoTemplate; - visualInfoTemplate.visualid = 33; //XVisualIDFromVisual(windowAttribs.visual); - XVisualInfo *visualInfo; - int matchingCount = 0; - visualInfo = XGetVisualInfo(m_display, VisualIDMask, &visualInfoTemplate, &matchingCount); - - m_context = glXCreateContext(m_display, visualInfo, 0, True); - - qDebug("Created GLX context 0x%x for visual ID %d", m_context, visualInfoTemplate.visualid); - - return true; -} - -void QGLXGLContext::makeCurrent() -{ - Window win = m_widget->winId(); - qDebug("QGLXGLContext::makeCurrent(window=0x%x, ctx=0x%x)", win, m_context); - - glXMakeCurrent(m_display, win, m_context); -} - -void QGLXGLContext::doneCurrent() -{ - glXMakeCurrent(m_display, 0, 0); -} - -void QGLXGLContext::swapBuffers() -{ - glXSwapBuffers(m_display, m_widget->winId()); -} - -void* QGLXGLContext::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 glxExt = QByteArray(glXGetClientString(m_display, GLX_EXTENSIONS)).split(' '); - if (glxExt.contains("GLX_ARB_get_proc_address")) { -#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) - void *handle = dlopen(NULL, RTLD_LAZY); - 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()); - glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB"); - } - } - resolved = true; - } - if (!glXGetProcAddressARB) - return 0; - return glXGetProcAddressARB(reinterpret_cast(procName.toLatin1().data())); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qglxglcontext.h b/src/plugins/platforms/testlite/qglxglcontext.h deleted file mode 100644 index ff8fe85..0000000 --- a/src/plugins/platforms/testlite/qglxglcontext.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef Q_GLX_CONTEXT_H -#define Q_GLX_CONTEXT_H - -#include -#include "x11util.h" -#include - -QT_BEGIN_NAMESPACE - -class QGLXGLContext : public QPlatformGLContext -{ -public: - QGLXGLContext(Display* xdpy); - ~QGLXGLContext(); - - bool create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext); - - void makeCurrent(); - void doneCurrent(); - void swapBuffers(); - void* getProcAddress(const QString& procName); - -private: - Display *m_display; - GLXContext m_context; - QWidget *m_widget; -}; - - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp new file mode 100644 index 0000000..6fdbb56 --- /dev/null +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "x11util.h" +#include "qglxglcontext.h" +#include + +#include + +#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) +#include +#endif + + +QT_BEGIN_NAMESPACE + +QGLXGLContext::QGLXGLContext(Display *xdpy) + : QPlatformGLContext() + , m_display(xdpy) + , m_context(0) + , m_widget(0) +{ +} + +QGLXGLContext::~QGLXGLContext() +{ + if (m_context) { + qDebug("Destroying GLX context 0x%x", m_context); + glXDestroyContext(m_display, m_context); + } +} + +bool QGLXGLContext::create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext) +{ + if (device->devType() != QInternal::Widget) { + qWarning("Creating a GL context is only supported on QWidgets"); + return false; + } + + m_widget = static_cast(device); + if (!m_widget->isTopLevel()) { + qWarning("Creating a GL context is only supported on top-level QWidgets"); + return false; + } + + // Get the XVisualInfo for the window: +// XWindowAttributes windowAttribs; +// XGetWindowAttributes(m_display, m_widget->winId(), &windowAttribs); + XVisualInfo visualInfoTemplate; + visualInfoTemplate.visualid = 33; //XVisualIDFromVisual(windowAttribs.visual); + XVisualInfo *visualInfo; + int matchingCount = 0; + visualInfo = XGetVisualInfo(m_display, VisualIDMask, &visualInfoTemplate, &matchingCount); + + m_context = glXCreateContext(m_display, visualInfo, 0, True); + + qDebug("Created GLX context 0x%x for visual ID %d", m_context, visualInfoTemplate.visualid); + + return true; +} + +void QGLXGLContext::makeCurrent() +{ + Window win = m_widget->winId(); + qDebug("QGLXGLContext::makeCurrent(window=0x%x, ctx=0x%x)", win, m_context); + + glXMakeCurrent(m_display, win, m_context); +} + +void QGLXGLContext::doneCurrent() +{ + glXMakeCurrent(m_display, 0, 0); +} + +void QGLXGLContext::swapBuffers() +{ + glXSwapBuffers(m_display, m_widget->winId()); +} + +void* QGLXGLContext::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 glxExt = QByteArray(glXGetClientString(m_display, GLX_EXTENSIONS)).split(' '); + if (glxExt.contains("GLX_ARB_get_proc_address")) { +#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) + void *handle = dlopen(NULL, RTLD_LAZY); + 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()); + glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB"); + } + } + resolved = true; + } + if (!glXGetProcAddressARB) + return 0; + return glXGetProcAddressARB(reinterpret_cast(procName.toLatin1().data())); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h new file mode 100644 index 0000000..ff8fe85 --- /dev/null +++ b/src/plugins/platforms/testlite/qglxintegration.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef Q_GLX_CONTEXT_H +#define Q_GLX_CONTEXT_H + +#include +#include "x11util.h" +#include + +QT_BEGIN_NAMESPACE + +class QGLXGLContext : public QPlatformGLContext +{ +public: + QGLXGLContext(Display* xdpy); + ~QGLXGLContext(); + + bool create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString& procName); + +private: + Display *m_display; + GLXContext m_context; + QWidget *m_widget; +}; + + +QT_END_NAMESPACE + +#endif -- cgit v0.12 From 35fb88fcd035d43684dfd78b64b04645826d4fac Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 29 Apr 2010 10:58:54 +0200 Subject: Update testlite to use new GL integration API --- src/plugins/platforms/testlite/qglxintegration.cpp | 190 ++++++++++++++++++--- src/plugins/platforms/testlite/qglxintegration.h | 41 +++-- .../platforms/testlite/qtestliteintegration.cpp | 11 +- .../platforms/testlite/qtestliteintegration.h | 1 + src/plugins/platforms/testlite/testlite.pro | 4 +- 5 files changed, 206 insertions(+), 41 deletions(-) diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index 6fdbb56..9e83f85 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -39,12 +39,17 @@ ** ****************************************************************************/ -#include "x11util.h" -#include "qglxglcontext.h" -#include +#include +#include +#include "qtestlitewindow.h" + +#include +#include #include +#include "qglxintegration.h" + #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) #include #endif @@ -52,11 +57,124 @@ QT_BEGIN_NAMESPACE -QGLXGLContext::QGLXGLContext(Display *xdpy) +GLXFBConfig qt_glx_integration_choose_config(MyDisplay* xd, QGLFormat& format, int drawableType) +{ + int configAttribs[] = { + GLX_DRAWABLE_TYPE, drawableType, + GLX_LEVEL, format.plane(), + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_DOUBLEBUFFER, format.doubleBuffer() ? True : False, + GLX_STEREO, format.stereo() ? True : False, + + GLX_DEPTH_SIZE, (format.depthBufferSize() == -1) ? 0 : format.depthBufferSize(), + GLX_STENCIL_SIZE, (format.stencilBufferSize() == -1) ? 0 : format.stencilBufferSize(), + GLX_SAMPLE_BUFFERS_ARB, (format.samples() == -1) ? 0 : format.samples(), + + GLX_RED_SIZE, (format.redBufferSize() == -1) ? 1 : format.redBufferSize(), + GLX_GREEN_SIZE, (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize(), + GLX_BLUE_SIZE, (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize(), + GLX_ALPHA_SIZE, (format.alphaBufferSize() == -1) ? 0 : format.alphaBufferSize(), + + GLX_ACCUM_RED_SIZE, (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(), + GLX_ACCUM_GREEN_SIZE, (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(), + GLX_ACCUM_BLUE_SIZE, (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(), + GLX_ACCUM_ALPHA_SIZE, (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(), + XNone + }; + + GLXFBConfig *configs; + int configCount = 0; + configs = glXChooseFBConfig(xd->display, xd->screen, configAttribs, &configCount); + + if (!configs) + return 0; + + GLXFBConfig chosenConfig = 0; + for (int i = 0; i < configCount; ++i) { + chosenConfig = configs[i]; + + // Make sure we try to get an ARGB visual if the format asked for an alpha: + if (format.alpha()) { + XVisualInfo* vi; + vi = glXGetVisualFromFBConfig(xd->display, configs[i]); + if (!vi) + continue; + + XRenderPictFormat *pictFormat = XRenderFindVisualFormat(xd->display, vi->visual); + XFree(vi); + + if (pictFormat && (pictFormat->type == PictTypeDirect) && pictFormat->direct.alphaMask) { + // The pict format for the visual matching the FBConfig indicates ARGB + break; + } + } else + break; // Just choose the first in the list if there's no alpha requested + } + + // TODO: Populate the QGLFormat with the values of the GLXFBConfig + + XFree(configs); + return chosenConfig; +} + + +QGLXGLWidgetSurface::QGLXGLWidgetSurface(MyDisplay* xd) + : QPlatformGLWidgetSurface() + , m_xd(xd) + , m_config(0) + , m_winId(0) +{ +} + +QGLXGLWidgetSurface::~QGLXGLWidgetSurface() +{ +} + +static Colormap qt_glx_integration_colormap = 0; + + +bool QGLXGLWidgetSurface::create(QGLWidget *widget, QGLFormat& format) +{ + m_config = qt_glx_integration_choose_config(m_xd, format, GLX_WINDOW_BIT); + + Window parentWindow = widget->window()->winId(); + + XVisualInfo* visualInfo; + visualInfo = glXGetVisualFromFBConfig(m_xd->display, m_config); + + if (!qt_glx_integration_colormap) { + qt_glx_integration_colormap = XCreateColormap(m_xd->display, parentWindow, + visualInfo->visual, AllocNone); + } + + XSetWindowAttributes windowAttribs; + windowAttribs.background_pixel = m_xd->whitePixel(); + windowAttribs.border_pixel = m_xd->blackPixel(); + windowAttribs.colormap = qt_glx_integration_colormap; + + m_winId = XCreateWindow(m_xd->display, parentWindow, + widget->x(), widget->y(), widget->width(), widget->height(), + 0, visualInfo->depth, InputOutput, visualInfo->visual, + CWBackPixel|CWBorderPixel|CWColormap, &windowAttribs); + + XMapWindow(m_xd->display, m_winId); + + XFree(visualInfo); + return true; +} + +void QGLXGLWidgetSurface::setGeometry(const QRect& rect) +{ + XMoveResizeWindow(m_xd->display, m_winId, rect.x(), rect.y(), rect.width(), rect.height()); +} + + +QGLXGLContext::QGLXGLContext(MyDisplay *xd) : QPlatformGLContext() - , m_display(xdpy) + , m_xd(xd) + , m_drawable(0) + , m_config(0) , m_context(0) - , m_widget(0) { } @@ -64,55 +182,75 @@ QGLXGLContext::~QGLXGLContext() { if (m_context) { qDebug("Destroying GLX context 0x%x", m_context); - glXDestroyContext(m_display, m_context); + glXDestroyContext(m_xd->display, m_context); } } -bool QGLXGLContext::create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext) +bool QGLXGLContext::create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext) { + Q_UNUSED(format); + if (device->devType() != QInternal::Widget) { qWarning("Creating a GL context is only supported on QWidgets"); return false; } - m_widget = static_cast(device); - if (!m_widget->isTopLevel()) { - qWarning("Creating a GL context is only supported on top-level QWidgets"); - return false; + GLXContext shareGlxContext = 0; + if (shareContext) + shareGlxContext = static_cast(shareContext)->glxContext(); + + + QWidget* widget = static_cast(device); + QGLWidget* glWidget = qobject_cast(widget); + if (glWidget) { + // Take the config from the QGLWidget's glx surface: + QGLXGLWidgetSurface* surface = static_cast(glWidget->platformSurface()); + m_config = surface->config(); + m_drawable = (Drawable)surface->winId(); + } + else { + if (!widget->isTopLevel()) { + qWarning("Creating a GL context is only supported on top-level QWidgets"); + return false; + } + m_drawable = (Drawable)widget->platformWindow()->winId(); + + // ### This might choose a config with a visual that isn't compatable with the native window: + m_config = qt_glx_integration_choose_config(m_xd, format, GLX_WINDOW_BIT); } + m_context = glXCreateNewContext(m_xd->display, m_config, GLX_RGBA_TYPE, shareGlxContext, True); + // Get the XVisualInfo for the window: // XWindowAttributes windowAttribs; // XGetWindowAttributes(m_display, m_widget->winId(), &windowAttribs); - XVisualInfo visualInfoTemplate; - visualInfoTemplate.visualid = 33; //XVisualIDFromVisual(windowAttribs.visual); - XVisualInfo *visualInfo; - int matchingCount = 0; - visualInfo = XGetVisualInfo(m_display, VisualIDMask, &visualInfoTemplate, &matchingCount); +// XVisualInfo visualInfoTemplate; +// visualInfoTemplate.visualid = 33; //XVisualIDFromVisual(windowAttribs.visual); +// XVisualInfo *visualInfo; +// int matchingCount = 0; +// visualInfo = XGetVisualInfo(m_xd->display, VisualIDMask, &visualInfoTemplate, &matchingCount); - m_context = glXCreateContext(m_display, visualInfo, 0, True); +// m_context = glXCreateContext(m_xd->display, visualInfo, 0, True); - qDebug("Created GLX context 0x%x for visual ID %d", m_context, visualInfoTemplate.visualid); +// qDebug("Created GLX context 0x%x for visual ID %d", m_context, visualInfoTemplate.visualid); return true; } void QGLXGLContext::makeCurrent() { - Window win = m_widget->winId(); - qDebug("QGLXGLContext::makeCurrent(window=0x%x, ctx=0x%x)", win, m_context); - - glXMakeCurrent(m_display, win, m_context); + qDebug("QGLXGLContext::makeCurrent(window=0x%x, ctx=0x%x)", m_drawable, m_context); + glXMakeCurrent(m_xd->display, m_drawable, m_context); } void QGLXGLContext::doneCurrent() { - glXMakeCurrent(m_display, 0, 0); + glXMakeCurrent(m_xd->display, 0, 0); } void QGLXGLContext::swapBuffers() { - glXSwapBuffers(m_display, m_widget->winId()); + glXSwapBuffers(m_xd->display, m_drawable); } void* QGLXGLContext::getProcAddress(const QString& procName) @@ -124,7 +262,7 @@ void* QGLXGLContext::getProcAddress(const QString& procName) if (resolved && !glXGetProcAddressARB) return 0; if (!glXGetProcAddressARB) { - QList glxExt = QByteArray(glXGetClientString(m_display, GLX_EXTENSIONS)).split(' '); + QList glxExt = QByteArray(glXGetClientString(m_xd->display, GLX_EXTENSIONS)).split(' '); if (glxExt.contains("GLX_ARB_get_proc_address")) { #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) void *handle = dlopen(NULL, RTLD_LAZY); diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h index ff8fe85..c7cdc91 100644 --- a/src/plugins/platforms/testlite/qglxintegration.h +++ b/src/plugins/platforms/testlite/qglxintegration.h @@ -43,31 +43,52 @@ #define Q_GLX_CONTEXT_H #include -#include "x11util.h" #include QT_BEGIN_NAMESPACE +class MyDisplay; + +class QGLXGLWidgetSurface : public QPlatformGLWidgetSurface +{ +public: + QGLXGLWidgetSurface(MyDisplay* xd); + virtual ~QGLXGLWidgetSurface(); + + virtual bool create(QGLWidget*, QGLFormat&); + virtual void setGeometry(const QRect&); + + GLXFBConfig config() {return m_config;} + Window winId() {return m_winId;} + +private: + MyDisplay *m_xd; + GLXFBConfig m_config; + Window m_winId; +}; + class QGLXGLContext : public QPlatformGLContext { public: - QGLXGLContext(Display* xdpy); + QGLXGLContext(MyDisplay* xd); ~QGLXGLContext(); - bool create(QPaintDevice* device, const QGLFormat& format, QPlatformGLContext* shareContext); - - void makeCurrent(); - void doneCurrent(); - void swapBuffers(); - void* getProcAddress(const QString& procName); + virtual bool create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext); + virtual void makeCurrent(); + virtual void doneCurrent(); + virtual void swapBuffers(); + virtual void* getProcAddress(const QString& procName); + GLXContext glxContext() {return m_context;} private: - Display *m_display; + MyDisplay *m_xd; + Drawable m_drawable; + GLXFBConfig m_config; GLXContext m_context; - QWidget *m_widget; }; + QT_END_NAMESPACE #endif diff --git a/src/plugins/platforms/testlite/qtestliteintegration.cpp b/src/plugins/platforms/testlite/qtestliteintegration.cpp index 6c07349..32562dd 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.cpp +++ b/src/plugins/platforms/testlite/qtestliteintegration.cpp @@ -52,7 +52,7 @@ #ifndef QT_NO_OPENGL #include -#include "qglxglcontext.h" +#include "qglxintegration.h" #endif QT_BEGIN_NAMESPACE @@ -132,9 +132,14 @@ bool QTestLiteIntegration::hasOpenGL() const return glXQueryExtension(xd->display, 0, 0) != 0; } -QPlatformGLContext * QTestLiteIntegration::createGLContext() +QPlatformGLContext *QTestLiteIntegration::createGLContext() { - return new QGLXGLContext(xd->display); + return new QGLXGLContext(xd); +} + +QPlatformGLWidgetSurface *QTestLiteIntegration::createGLWidgetSurface() +{ + return new QGLXGLWidgetSurface(xd); } #endif // QT_NO_OPENGL diff --git a/src/plugins/platforms/testlite/qtestliteintegration.h b/src/plugins/platforms/testlite/qtestliteintegration.h index 4260faa..69dad93 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.h +++ b/src/plugins/platforms/testlite/qtestliteintegration.h @@ -84,6 +84,7 @@ public: #ifndef QT_NO_OPENGL bool hasOpenGL() const; QPlatformGLContext * createGLContext(); + QPlatformGLWidgetSurface * createGLWidgetSurface(); #endif MyDisplay *xd; diff --git a/src/plugins/platforms/testlite/testlite.pro b/src/plugins/platforms/testlite/testlite.pro index 454193d..0a5ebb2 100644 --- a/src/plugins/platforms/testlite/testlite.pro +++ b/src/plugins/platforms/testlite/testlite.pro @@ -10,8 +10,8 @@ LIBS += -lX11 -lXext contains(QT_CONFIG, opengl) { QT += opengl - HEADERS += qglxglcontext.h - SOURCES += qglxglcontext.cpp + HEADERS += qglxintegration.h + SOURCES += qglxintegration.cpp } target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -- cgit v0.12 From 702c0546d7d0c39b436bc4a3ec00e24ef454a9b9 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 29 Apr 2010 16:39:06 +0200 Subject: Add QPlatformGLWidgetSurface::filterEvent This allows platform integrations to do something special when the QGLWidget recieves an event. Of particular interest is the ParentAboutToChange and ParentChange events. --- src/opengl/qgl_lite.cpp | 14 ++++++++++++++ src/opengl/qglplatformintegration_lite.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp index fa1439c..0ffda5f 100644 --- a/src/opengl/qgl_lite.cpp +++ b/src/opengl/qgl_lite.cpp @@ -68,6 +68,12 @@ QPlatformGLWidgetSurface::~QPlatformGLWidgetSurface() { } +bool QPlatformGLWidgetSurface::filterEvent(QEvent*) +{ + // By default, return false to allow the event to pass through + return false; +} + bool QGLFormat::hasOpenGL() { @@ -242,6 +248,14 @@ void QGLWidget::setMouseTracking(bool enable) bool QGLWidget::event(QEvent *e) { + Q_D(QGLWidget); + + if (d->wsurf) { + bool eventFiltered = d->wsurf->filterEvent(e); + if (eventFiltered) + return true; + } + return QWidget::event(e); } diff --git a/src/opengl/qglplatformintegration_lite.h b/src/opengl/qglplatformintegration_lite.h index 94d4da0..bec920c 100644 --- a/src/opengl/qglplatformintegration_lite.h +++ b/src/opengl/qglplatformintegration_lite.h @@ -59,6 +59,7 @@ public: virtual bool create(QGLWidget*, QGLFormat&) = 0; virtual void setGeometry(const QRect&) = 0; + virtual bool filterEvent(QEvent*); }; -- cgit v0.12 From c5d7513159feeda384d1c3f97906f7086cb38db8 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 29 Apr 2010 16:42:19 +0200 Subject: Fix re-parenting of QGLWidgets in testlite --- src/plugins/platforms/testlite/qglxintegration.cpp | 22 ++++++++++++++++++++++ src/plugins/platforms/testlite/qglxintegration.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index 9e83f85..c21c3aa 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -123,6 +123,7 @@ QGLXGLWidgetSurface::QGLXGLWidgetSurface(MyDisplay* xd) , m_xd(xd) , m_config(0) , m_winId(0) + , m_widget(0) { } @@ -135,6 +136,8 @@ static Colormap qt_glx_integration_colormap = 0; bool QGLXGLWidgetSurface::create(QGLWidget *widget, QGLFormat& format) { + m_widget = widget; + m_config = qt_glx_integration_choose_config(m_xd, format, GLX_WINDOW_BIT); Window parentWindow = widget->window()->winId(); @@ -168,6 +171,25 @@ void QGLXGLWidgetSurface::setGeometry(const QRect& rect) XMoveResizeWindow(m_xd->display, m_winId, rect.x(), rect.y(), rect.width(), rect.height()); } +bool QGLXGLWidgetSurface::filterEvent(QEvent *e) +{ + if (e->type() == QEvent::ParentAboutToChange) { + // We temporarily hide the window and re-parent it with the root window + // as it's quite likely that the parent window is about to be deleted, + // which would otherwise destroy our window along with it. + XUnmapWindow(m_xd->display, m_winId); + XReparentWindow(m_xd->display, m_winId, m_xd->rootWindow(), 0, 0); + } + + if (e->type() == QEvent::ParentChange) { + // Once we've got a new parent, we need to reparent the window and show it again: + XReparentWindow(m_xd->display, m_winId, m_widget->window()->winId(), m_widget->x(), m_widget->y()); + XMapWindow(m_xd->display, m_winId); + } + + return false; // Allow the event to pass through to QGLWidget +} + QGLXGLContext::QGLXGLContext(MyDisplay *xd) : QPlatformGLContext() diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h index c7cdc91..0302950 100644 --- a/src/plugins/platforms/testlite/qglxintegration.h +++ b/src/plugins/platforms/testlite/qglxintegration.h @@ -57,6 +57,7 @@ public: virtual bool create(QGLWidget*, QGLFormat&); virtual void setGeometry(const QRect&); + virtual bool filterEvent(QEvent*); GLXFBConfig config() {return m_config;} Window winId() {return m_winId;} @@ -65,6 +66,7 @@ private: MyDisplay *m_xd; GLXFBConfig m_config; Window m_winId; + QGLWidget* m_widget; }; class QGLXGLContext : public QPlatformGLContext -- cgit v0.12 From 327f7c9b055bd6c0131eb92fc7bed58698cb83b0 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 30 Apr 2010 13:43:42 +0200 Subject: Remove windowSurface member from QTestLiteWindow This makes QTestLiteWindow independent of the window surface, so window surfaces other than QTestLiteWindowSurface can be used too. Reviewed-By: Paul --- src/plugins/platforms/testlite/qtestlitewindow.cpp | 4 +--- src/plugins/platforms/testlite/qtestlitewindow.h | 3 --- src/plugins/platforms/testlite/qtestlitewindowsurface.cpp | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index 545912e..242f335 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include "qtestlitewindowsurface.h" #include "qtestliteintegration.h" #include @@ -184,7 +183,6 @@ QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration setWindowTitle(QLatin1String("Qt Lighthouse")); currentCursor = -1; - windowSurface = 0; setWindowFlags(window->windowFlags()); //##### This should not be the plugin's responsibility @@ -678,7 +676,7 @@ void QTestLiteWindow::paintEvent() qDebug() << "QTestLiteWindow::paintEvent" << shm_img.size() << painted; #endif - windowSurface->flush(windowSurface->window(), QRect(xpos,ypos,width, height), QPoint()); + widget()->windowSurface()->flush(widget(), QRect(xpos,ypos,width, height), QPoint()); } diff --git a/src/plugins/platforms/testlite/qtestlitewindow.h b/src/plugins/platforms/testlite/qtestlitewindow.h index 3624854..28e49be 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.h +++ b/src/plugins/platforms/testlite/qtestlitewindow.h @@ -94,8 +94,6 @@ public: //### struct MyShmImageInfo; -class QWindowSurface; - class QTestLiteWindow : public QPlatformWindow { public: @@ -140,7 +138,6 @@ private: int currentCursor; - QWindowSurface *windowSurface; MyDisplay *xd; QTestLiteScreen *mScreen; diff --git a/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp b/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp index a14a50e..53f4791 100644 --- a/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp @@ -131,7 +131,6 @@ QTestLiteWindowSurface::QTestLiteWindowSurface (QTestLiteScreen */*screen*/, QWi painted(false), image_info(0) { xw = static_cast(window->platformWindow()); - xw->windowSurface = this; // qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window; } -- cgit v0.12 From 468af8f1dd1c9bc98919e8f407c9676e880249f9 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 30 Apr 2010 13:50:10 +0200 Subject: Export QGLWindowSurface so it can be used by Lighthouse plugins --- src/opengl/qwindowsurface_gl_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index 9d17514..6bff109 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -77,7 +77,7 @@ public: QGLWindowSurfacePrivate* d; }; -class QGLWindowSurface : public QObject, public QWindowSurface // , public QPaintDevice +class Q_OPENGL_EXPORT QGLWindowSurface : public QObject, public QWindowSurface // , public QPaintDevice { Q_OBJECT public: -- cgit v0.12 From d279e5d3ee808f4faeb5408dc66740b7fffab84f Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 30 Apr 2010 13:55:06 +0200 Subject: Fix GL extention function pointer lookups in testlite For some reason, if the application doesn't link against QtOpenGL then the qt_gl_library_name() symbol will be missing. For now just hard-code the library name to "GL". --- src/plugins/platforms/testlite/qglxintegration.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index c21c3aa..d4383ef 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -296,7 +296,8 @@ void* QGLXGLContext::getProcAddress(const QString& procName) #endif { extern const QString qt_gl_library_name(); - QLibrary lib(qt_gl_library_name()); +// QLibrary lib(qt_gl_library_name()); + QLibrary lib(QLatin1String("GL")); glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB"); } } -- cgit v0.12 From a24c7ee4da84d3ac8e52cafda200f07c48d0bc98 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 30 Apr 2010 14:38:01 +0200 Subject: Add support for using OpenGL for window surfaces to testlite To use OpenGL for regular widget rendering, pass testlitegl as the argument to -platform. QGLWindowSurface works by creating a QGLContext on the top-level widget. As testlite's GL integration allows this, QGLWindowSurface can be used without modification. --- src/plugins/platforms/testlite/main.cpp | 7 +++++++ src/plugins/platforms/testlite/qtestliteintegration.cpp | 11 ++++++++++- src/plugins/platforms/testlite/qtestliteintegration.h | 5 ++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/testlite/main.cpp b/src/plugins/platforms/testlite/main.cpp index 29bbcea..5f631f0 100644 --- a/src/plugins/platforms/testlite/main.cpp +++ b/src/plugins/platforms/testlite/main.cpp @@ -55,6 +55,9 @@ QStringList QTestLiteIntegrationPlugin::keys() const { QStringList list; list << "TestLite"; +#ifndef QT_NO_OPENGL + list << "TestLiteGL"; +#endif return list; } @@ -62,6 +65,10 @@ QPlatformIntegration* QTestLiteIntegrationPlugin::create(const QString& system) { if (system.toLower() == "testlite") return new QTestLiteIntegration; +#ifndef QT_NO_OPENGL + if (system.toLower() == "testlitegl") + return new QTestLiteIntegration(true); +#endif return 0; } diff --git a/src/plugins/platforms/testlite/qtestliteintegration.cpp b/src/plugins/platforms/testlite/qtestliteintegration.cpp index 32562dd..f3c3688 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.cpp +++ b/src/plugins/platforms/testlite/qtestliteintegration.cpp @@ -53,6 +53,7 @@ #ifndef QT_NO_OPENGL #include #include "qglxintegration.h" +#include #endif QT_BEGIN_NAMESPACE @@ -81,7 +82,10 @@ public: }; -QTestLiteIntegration::QTestLiteIntegration() +QTestLiteIntegration::QTestLiteIntegration(bool useOpenGL) +#ifndef QT_NO_OPENGL + : mUseOpenGL(useOpenGL) +#endif { xd = new MyDisplay; @@ -109,6 +113,11 @@ QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type) QWindowSurface *QTestLiteIntegration::createWindowSurface(QWidget *widget, WId) const { +#ifndef QT_NO_OPENGL + if (mUseOpenGL) + return new QGLWindowSurface(widget); +#endif + return new QTestLiteWindowSurface(mPrimaryScreen, widget); } diff --git a/src/plugins/platforms/testlite/qtestliteintegration.h b/src/plugins/platforms/testlite/qtestliteintegration.h index 69dad93..8289a5c 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.h +++ b/src/plugins/platforms/testlite/qtestliteintegration.h @@ -71,7 +71,7 @@ public: class QTestLiteIntegration : public QPlatformIntegration { public: - QTestLiteIntegration(); + QTestLiteIntegration(bool useOpenGL = false); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; @@ -90,6 +90,9 @@ public: MyDisplay *xd; private: +#ifndef QT_NO_OPENGL + bool mUseOpenGL; +#endif QTestLiteScreen *mPrimaryScreen; QList mScreens; }; -- cgit v0.12 From 7286bc3c88c632a3e081e8df40e0f94438da1911 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 30 Apr 2010 15:55:47 +0200 Subject: Use QGLPixmapData for testlite when in OpenGL mode --- src/opengl/qpixmapdata_gl_p.h | 2 +- src/plugins/platforms/testlite/qtestliteintegration.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h index c239bcb..736a28e 100644 --- a/src/opengl/qpixmapdata_gl_p.h +++ b/src/opengl/qpixmapdata_gl_p.h @@ -96,7 +96,7 @@ private: }; -class QGLPixmapData : public QPixmapData +class Q_OPENGL_EXPORT QGLPixmapData : public QPixmapData { public: QGLPixmapData(PixelType type); diff --git a/src/plugins/platforms/testlite/qtestliteintegration.cpp b/src/plugins/platforms/testlite/qtestliteintegration.cpp index f3c3688..3fa3495 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.cpp +++ b/src/plugins/platforms/testlite/qtestliteintegration.cpp @@ -54,6 +54,7 @@ #include #include "qglxintegration.h" #include +#include #endif QT_BEGIN_NAMESPACE @@ -108,6 +109,10 @@ QTestLiteIntegration::QTestLiteIntegration(bool useOpenGL) QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type) const { +#ifndef QT_NO_OPENGL + if (mUseOpenGL) + return new QGLPixmapData(type); +#endif return new QRasterPixmapData(type); } -- cgit v0.12 From 8a37bad57ef1fddc08c78f6ddc6fbcf0d3879676 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 30 Apr 2010 15:57:25 +0200 Subject: Fix selecting GLXFBConfigs with depth/stencil/sample buffers This has the unfortunate side effect that different GLXFBConfigs now get selected, which in turn have different visuals. It seems each different visual requires its own colormap (even though they are all TrueColor). To get round this, we allocate a new colormap for each widget. --- src/plugins/platforms/testlite/qglxintegration.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index d4383ef..88764f3 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -59,6 +59,17 @@ QT_BEGIN_NAMESPACE GLXFBConfig qt_glx_integration_choose_config(MyDisplay* xd, QGLFormat& format, int drawableType) { + int depthSize = 0; + int stencilSize = 0; + int sampleSize = 0; + + if (format.depth()) + depthSize = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize(); + if (format.stencil()) + stencilSize = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize(); + if (format.sampleBuffers()) + sampleSize = (format.samples() == -1) ? 1 : format.samples(); + int configAttribs[] = { GLX_DRAWABLE_TYPE, drawableType, GLX_LEVEL, format.plane(), @@ -66,9 +77,9 @@ GLXFBConfig qt_glx_integration_choose_config(MyDisplay* xd, QGLFormat& format, i GLX_DOUBLEBUFFER, format.doubleBuffer() ? True : False, GLX_STEREO, format.stereo() ? True : False, - GLX_DEPTH_SIZE, (format.depthBufferSize() == -1) ? 0 : format.depthBufferSize(), - GLX_STENCIL_SIZE, (format.stencilBufferSize() == -1) ? 0 : format.stencilBufferSize(), - GLX_SAMPLE_BUFFERS_ARB, (format.samples() == -1) ? 0 : format.samples(), + GLX_DEPTH_SIZE, depthSize, + GLX_STENCIL_SIZE, stencilSize, + GLX_SAMPLE_BUFFERS_ARB, sampleSize, GLX_RED_SIZE, (format.redBufferSize() == -1) ? 1 : format.redBufferSize(), GLX_GREEN_SIZE, (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize(), @@ -145,10 +156,11 @@ bool QGLXGLWidgetSurface::create(QGLWidget *widget, QGLFormat& format) XVisualInfo* visualInfo; visualInfo = glXGetVisualFromFBConfig(m_xd->display, m_config); - if (!qt_glx_integration_colormap) { + // ### This will leak the colormap, but we need a colormap for each visual +// if (!qt_glx_integration_colormap) { qt_glx_integration_colormap = XCreateColormap(m_xd->display, parentWindow, visualInfo->visual, AllocNone); - } +// } XSetWindowAttributes windowAttribs; windowAttribs.background_pixel = m_xd->whitePixel(); -- cgit v0.12 From b30a58d71d2608b033c1e9fcfa68cc69c14d31c7 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 3 May 2010 17:03:16 +0200 Subject: some cursor documentation fixes, reduce public access to class internals --- src/gui/painting/qgraphicssystemcursor_lite.cpp | 28 +++++++++++++++++-------- src/gui/painting/qgraphicssystemcursor_lite.h | 7 +++++-- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/gui/painting/qgraphicssystemcursor_lite.cpp b/src/gui/painting/qgraphicssystemcursor_lite.cpp index fdb026c..4c97948 100644 --- a/src/gui/painting/qgraphicssystemcursor_lite.cpp +++ b/src/gui/painting/qgraphicssystemcursor_lite.cpp @@ -66,7 +66,7 @@ QPointer QGraphicsSystemCursor::instance = 0; */ /*! - \fn virtual void pointerEvent(const QMouseEvent & event) + \fn virtual void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & event) This method is called by Qt whenever a QMouseEvent is generated by the underlying pointer input. \a event is a reference to the QMouseEvent in @@ -76,7 +76,7 @@ QPointer QGraphicsSystemCursor::instance = 0; */ /*! - \fn virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) + \fn virtual void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) \brief This method is called by Qt whenever the cursor graphic should be changed. @@ -91,8 +91,9 @@ QPointer QGraphicsSystemCursor::instance = 0; */ /*! - Constructs a QGraphicsSystemCursor + \fn QGraphicsSystemCursor::QGraphicsSystemCursor() + \brief Constructs a QGraphicsSystemCursor */ QGraphicsSystemCursor::QGraphicsSystemCursor(QPlatformScreen *scr ) : screen(scr) @@ -104,6 +105,15 @@ QGraphicsSystemCursor::QGraphicsSystemCursor(QPlatformScreen *scr ) // Beginning of built-in cursor graphics // from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp +/*! + \class QGraphicsSystemCursorImage + + \brief The QGraphicsSystemCursorImage class provides a set of graphics + intended to be used as cursors. + + \sa QGraphicsSystemCursor +*/ + static QGraphicsSystemCursorImage *systemCursorTable[Qt::LastCursor+1]; static bool systemCursorTableInit = false; @@ -496,7 +506,7 @@ void QGraphicsSystemCursorImage::createSystemCursor(int id) } /*! - \fn void set(Qt::CursorShape id) + \fn void QGraphicsSystemCursorImage::set(Qt::CursorShape id) \brief Calling this method sets the cursor image to the specified shape @@ -525,7 +535,7 @@ void QGraphicsSystemCursorImage::set(Qt::CursorShape id) } /*! - \fn void set(const QImage * image, int hx, int hy) + \fn void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy) @@ -544,7 +554,7 @@ void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) } /*! - \fn set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) + \fn void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) \brief set the cursor image to the graphic represented by the combination of data, mask, width, and height @@ -619,7 +629,7 @@ void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, } /*! - \fn QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + \fn QGraphicsSystemCursorImage::QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) \brief set the cursor image to the graphic represented by the combination of data, mask, width, and height @@ -640,13 +650,13 @@ void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, */ /*! - \fn QImage *image() + \fn QImage *QGraphicsSystemCursorImage::image() \brief Return the cursor graphic as a pointer to a QImage */ /*! - \fn QPoint hotspot + \fn QPoint QGraphicsSystemCursorImage::hotspot() \brief Return the cursor's hotspot */ diff --git a/src/gui/painting/qgraphicssystemcursor_lite.h b/src/gui/painting/qgraphicssystemcursor_lite.h index 5288b83..1f4cfd6 100644 --- a/src/gui/painting/qgraphicssystemcursor_lite.h +++ b/src/gui/painting/qgraphicssystemcursor_lite.h @@ -78,9 +78,12 @@ public: static QPointer getInstance() { return instance; } protected: - static QPointer instance; // limit 1 cursor at a time - QPlatformScreen* screen; // Where to request an update + +private: + static QPointer instance; // limit 1 cursor at a time + friend void qt_lite_set_cursor(QWidget * w, bool force); + friend class QApplicationPrivate; }; QT_END_NAMESPACE -- cgit v0.12 From c6fd02d70e22d497658153abbd9fcf3176b550ca Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 4 May 2010 14:26:43 +0200 Subject: add parameter support for platform integration plugins --- src/gui/kernel/qplatformintegrationfactory_lite.cpp | 5 +++-- src/gui/kernel/qplatformintegrationplugin_lite.h | 4 ++-- src/plugins/platforms/directfb/main.cpp | 5 +++-- src/plugins/platforms/linuxfb/main.cpp | 5 +++-- src/plugins/platforms/minimal/main.cpp | 5 +++-- src/plugins/platforms/qvfb/main.cpp | 5 +++-- src/plugins/platforms/testlite/main.cpp | 5 +++-- src/plugins/platforms/vnc/main.cpp | 5 +++-- 8 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/gui/kernel/qplatformintegrationfactory_lite.cpp b/src/gui/kernel/qplatformintegrationfactory_lite.cpp index 7f650e9..9a00dea 100644 --- a/src/gui/kernel/qplatformintegrationfactory_lite.cpp +++ b/src/gui/kernel/qplatformintegrationfactory_lite.cpp @@ -57,12 +57,13 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key) { QPlatformIntegration *ret = 0; - QString platform = key.toLower(); + QStringList paramList = key.split(QLatin1Char(':')); + QString platform = paramList.takeFirst().toLower(); qDebug() << loader()->keys(); #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) if (QPlatformIntegrationFactoryInterface *factory = qobject_cast(loader()->instance(platform))) - ret = factory->create(platform); + ret = factory->create(platform, paramList); #endif return ret; diff --git a/src/gui/kernel/qplatformintegrationplugin_lite.h b/src/gui/kernel/qplatformintegrationplugin_lite.h index 0e116f2..9c37cf7 100644 --- a/src/gui/kernel/qplatformintegrationplugin_lite.h +++ b/src/gui/kernel/qplatformintegrationplugin_lite.h @@ -66,7 +66,7 @@ class QPlatformIntegration; struct QPlatformIntegrationFactoryInterface : public QFactoryInterface { - virtual QPlatformIntegration *create(const QString &key) = 0; + virtual QPlatformIntegration *create(const QString &key, const QStringList ¶mList) = 0; }; #define QPlatformIntegrationFactoryInterface_iid "com.nokia.Qt.QPlatformIntegrationFactoryInterface" @@ -82,7 +82,7 @@ public: ~QPlatformIntegrationPlugin(); virtual QStringList keys() const = 0; - virtual QPlatformIntegration *create(const QString &key) = 0; + virtual QPlatformIntegration *create(const QString &key, const QStringList ¶mList) = 0; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/directfb/main.cpp b/src/plugins/platforms/directfb/main.cpp index 9c7bcf6..f4ece32 100644 --- a/src/plugins/platforms/directfb/main.cpp +++ b/src/plugins/platforms/directfb/main.cpp @@ -48,7 +48,7 @@ class QDirectFbIntegrationPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QPlatformIntegration *create(const QString&); + QPlatformIntegration *create(const QString&, const QStringList&); }; QStringList QDirectFbIntegrationPlugin::keys() const @@ -58,8 +58,9 @@ QStringList QDirectFbIntegrationPlugin::keys() const return list; } -QPlatformIntegration * QDirectFbIntegrationPlugin::create(const QString& system) +QPlatformIntegration * QDirectFbIntegrationPlugin::create(const QString& system, const QStringList& paramList) { + Q_UNUSED(paramList); if (system.toLower() == "directfb") return new QDirectFbIntegration; diff --git a/src/plugins/platforms/linuxfb/main.cpp b/src/plugins/platforms/linuxfb/main.cpp index 65569ac..c5f7fe0 100644 --- a/src/plugins/platforms/linuxfb/main.cpp +++ b/src/plugins/platforms/linuxfb/main.cpp @@ -48,7 +48,7 @@ class QLinuxFbIntegrationPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QPlatformIntegration *create(const QString&); + QPlatformIntegration *create(const QString&, const QStringList&); }; QStringList QLinuxFbIntegrationPlugin::keys() const @@ -58,8 +58,9 @@ QStringList QLinuxFbIntegrationPlugin::keys() const return list; } -QPlatformIntegration* QLinuxFbIntegrationPlugin::create(const QString& system) +QPlatformIntegration* QLinuxFbIntegrationPlugin::create(const QString& system, const QStringList& paramList) { + Q_UNUSED(paramList); if (system.toLower() == "linuxfb") return new QLinuxFbIntegration; diff --git a/src/plugins/platforms/minimal/main.cpp b/src/plugins/platforms/minimal/main.cpp index 4958468..a4d646d 100644 --- a/src/plugins/platforms/minimal/main.cpp +++ b/src/plugins/platforms/minimal/main.cpp @@ -48,7 +48,7 @@ class QMinimalIntegrationPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QPlatformIntegration *create(const QString&); + QPlatformIntegration *create(const QString&, const QStringList&); }; QStringList QMinimalIntegrationPlugin::keys() const @@ -58,8 +58,9 @@ QStringList QMinimalIntegrationPlugin::keys() const return list; } -QPlatformIntegration *QMinimalIntegrationPlugin::create(const QString& system) +QPlatformIntegration *QMinimalIntegrationPlugin::create(const QString& system, const QStringList& paramList) { + Q_UNUSED(paramList); if (system.toLower() == "minimal") return new QMinimalIntegration; diff --git a/src/plugins/platforms/qvfb/main.cpp b/src/plugins/platforms/qvfb/main.cpp index 409f11c..206ece8 100644 --- a/src/plugins/platforms/qvfb/main.cpp +++ b/src/plugins/platforms/qvfb/main.cpp @@ -49,7 +49,7 @@ class QVFbIntegrationPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QPlatformIntegration *create(const QString&); + QPlatformIntegration *create(const QString&, const QStringList&); }; QStringList QVFbIntegrationPlugin::keys() const @@ -59,8 +59,9 @@ QStringList QVFbIntegrationPlugin::keys() const return list; } -QPlatformIntegration* QVFbIntegrationPlugin::create(const QString& system) +QPlatformIntegration* QVFbIntegrationPlugin::create(const QString& system, const QStringList& paramList) { + Q_UNUSED(paramList); if (system.toLower() == "qvfb") return new QVFbIntegration; diff --git a/src/plugins/platforms/testlite/main.cpp b/src/plugins/platforms/testlite/main.cpp index 5f631f0..2f6aa8b 100644 --- a/src/plugins/platforms/testlite/main.cpp +++ b/src/plugins/platforms/testlite/main.cpp @@ -48,7 +48,7 @@ class QTestLiteIntegrationPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QPlatformIntegration *create(const QString&); + QPlatformIntegration *create(const QString&, const QStringList&); }; QStringList QTestLiteIntegrationPlugin::keys() const @@ -61,8 +61,9 @@ QStringList QTestLiteIntegrationPlugin::keys() const return list; } -QPlatformIntegration* QTestLiteIntegrationPlugin::create(const QString& system) +QPlatformIntegration* QTestLiteIntegrationPlugin::create(const QString& system, const QStringList& paramList) { + Q_UNUSED(paramList); if (system.toLower() == "testlite") return new QTestLiteIntegration; #ifndef QT_NO_OPENGL diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp index 775259b..c66029c 100644 --- a/src/plugins/platforms/vnc/main.cpp +++ b/src/plugins/platforms/vnc/main.cpp @@ -49,7 +49,7 @@ class QVNCIntegrationPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QPlatformIntegration *create(const QString&); + QPlatformIntegration *create(const QString&, const QStringList &); }; QStringList QVNCIntegrationPlugin::keys() const @@ -59,8 +59,9 @@ QStringList QVNCIntegrationPlugin::keys() const return list; } -QPlatformIntegration* QVNCIntegrationPlugin::create(const QString& system) +QPlatformIntegration* QVNCIntegrationPlugin::create(const QString& system, const QStringList& paramList) { + Q_UNUSED(paramList); if (system.toLower() == "vnc") return new QVNCIntegration; -- cgit v0.12 From 47f886467b04ce712b4dcd90f0201720d614ff28 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 4 May 2010 14:59:04 +0200 Subject: VNC parameters for size and display id --- src/plugins/platforms/vnc/main.cpp | 2 +- src/plugins/platforms/vnc/qvncintegration.cpp | 54 ++++++++++++++++++++------- src/plugins/platforms/vnc/qvncintegration.h | 4 +- src/plugins/platforms/vnc/qvncserver.cpp | 4 +- src/plugins/platforms/vnc/qvncserver.h | 2 +- 5 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp index c66029c..e051e2d 100644 --- a/src/plugins/platforms/vnc/main.cpp +++ b/src/plugins/platforms/vnc/main.cpp @@ -63,7 +63,7 @@ QPlatformIntegration* QVNCIntegrationPlugin::create(const QString& system, const { Q_UNUSED(paramList); if (system.toLower() == "vnc") - return new QVNCIntegration; + return new QVNCIntegration(paramList); return 0; } diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp index 7bdba35..69aea79 100644 --- a/src/plugins/platforms/vnc/qvncintegration.cpp +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -51,25 +51,16 @@ #include -QVNCScreen::QVNCScreen() +QVNCScreen::QVNCScreen(QRect screenSize, int screenId) : QFbScreen::QFbScreen() { - int w = 800; - int h = 600; - int ew, eh; - const char *str; - if ((str=::getenv("QT_VNC_SIZE")) && sscanf(str,"%dx%d",&ew,&eh)==2) { - w = ew; - h = eh; - } - - setGeometry(QRect(0,0,w, h)); + setGeometry(screenSize); setDepth(32); setFormat(QImage::Format_RGB32); setPhysicalSize((geometry().size()*254)/720); - d_ptr = new QVNCScreenPrivate(this); + d_ptr = new QVNCScreenPrivate(this, screenId); cursor = new QVNCCursor(d_ptr->vncServer, this); d_ptr->vncServer->setCursor(static_cast(cursor)); @@ -91,10 +82,45 @@ QRegion QVNCScreen::doRedraw() return touched; } +static inline int defaultWidth() { return 800; } +static inline int defaultHeight() { return 600; } +static inline int defaultDisplay() { return 0; } + +static void usage() +{ + qWarning() << "VNC Platform Integration options:"; + qWarning() << " size=x - set the display width and height"; + qWarning() << " defaults to" << defaultWidth() << "x" << defaultHeight(); + qWarning() << " display= - set the VNC display port to ID + 5900"; + qWarning() << " defaults to" << defaultDisplay(); +} -QVNCIntegration::QVNCIntegration() +QVNCIntegration::QVNCIntegration(const QStringList& paramList) { - mPrimaryScreen = new QVNCScreen(); + int sizeX = defaultWidth(); + int sizeY = defaultHeight(); + int display = defaultDisplay(); + bool showUsage = false; + + foreach(QString confString, paramList) { + if (confString.startsWith(QLatin1String("size="))) { + QString val = confString.section(QLatin1Char('='), 1, 1); + sizeX = val.section(QLatin1Char('x'), 0, 0).toInt(); + sizeY = val.section(QLatin1Char('x'), 1, 1).toInt(); + } + else if (confString.startsWith(QLatin1String("display="))) { + display = confString.section(QLatin1Char('='), 1, 1).toInt(); + } + else { + qWarning() << "Unknown VNC option:" << confString; + showUsage = true; + } + } + + if (showUsage) + usage(); + + mPrimaryScreen = new QVNCScreen(QRect(0, 0, sizeX, sizeY), display); mScreens.append(mPrimaryScreen); } diff --git a/src/plugins/platforms/vnc/qvncintegration.h b/src/plugins/platforms/vnc/qvncintegration.h index 524b888..dcb5419 100644 --- a/src/plugins/platforms/vnc/qvncintegration.h +++ b/src/plugins/platforms/vnc/qvncintegration.h @@ -56,7 +56,7 @@ class QVNCScreenPrivate; class QVNCScreen : public QFbScreen { public: - QVNCScreen(); + QVNCScreen(QRect screenSize, int screenId); int linestep() const { return image() ? image()->bytesPerLine() : 0; } uchar *base() const { return image() ? image()->bits() : 0; } @@ -76,7 +76,7 @@ class QVNCIntegrationPrivate; class QVNCIntegration : public QPlatformIntegration { public: - QVNCIntegration(); + QVNCIntegration(const QStringList& paramList); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp index ab0a2f3..bd4d6ab 100644 --- a/src/plugins/platforms/vnc/qvncserver.cpp +++ b/src/plugins/platforms/vnc/qvncserver.cpp @@ -1885,7 +1885,7 @@ void QVNCServer::discardClient() -QVNCScreenPrivate::QVNCScreenPrivate(QVNCScreen *parent) +QVNCScreenPrivate::QVNCScreenPrivate(QVNCScreen *parent, int screenId) : dpiX(72), dpiY(72), doOnScreenSurface(false), refreshRate(25), vncServer(0), q_ptr(parent) { @@ -1893,7 +1893,7 @@ QVNCScreenPrivate::QVNCScreenPrivate(QVNCScreen *parent) QWSSignalHandler::instance()->addObject(this); #endif - vncServer = new QVNCServer(q_ptr); + vncServer = new QVNCServer(q_ptr, screenId); vncServer->setRefreshRate(refreshRate); diff --git a/src/plugins/platforms/vnc/qvncserver.h b/src/plugins/platforms/vnc/qvncserver.h index b1a9797..837f1f4 100644 --- a/src/plugins/platforms/vnc/qvncserver.h +++ b/src/plugins/platforms/vnc/qvncserver.h @@ -249,7 +249,7 @@ public: class QVNCScreenPrivate : public QObject { public: - QVNCScreenPrivate(QVNCScreen *parent); + QVNCScreenPrivate(QVNCScreen *parent, int screenId); ~QVNCScreenPrivate(); void setDirty(const QRect &rect, bool force = false); -- cgit v0.12 From 208e207925f9073fdca55f5824ce4d0051c86c6c Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 5 May 2010 13:40:19 +0200 Subject: allow multiple cursors --- src/gui/kernel/qapplication_lite.cpp | 8 +-- src/gui/kernel/qwidget_lite.cpp | 67 +++++++++++++------------ src/gui/painting/qgraphicssystemcursor_lite.cpp | 4 +- src/gui/painting/qgraphicssystemcursor_lite.h | 9 ++-- src/plugins/platforms/fb_base/fb_base.h | 1 + 5 files changed, 48 insertions(+), 41 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index f9e4242..31db7d0 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -691,9 +691,11 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent * QMouseEvent ev(type, localPoint, globalPoint, button, buttons, modifiers); - QPointer cursor = QGraphicsSystemCursor::getInstance(); - if (cursor) - cursor->pointerEvent(ev); + QList > cursors = QGraphicsSystemCursor::getInstances(); + foreach (QWeakPointer cursor, cursors) { + if (cursor) + cursor.data()->pointerEvent(ev); + } QApplication::sendSpontaneousEvent(mouseWidget, &ev); } diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 64fb6f7..ed731c0 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -689,6 +689,7 @@ void QWidgetPrivate::setModal_sys() #ifndef QT_NO_CURSOR void qt_lite_set_cursor(QWidget * w, bool force) { + static QCursor arrowCursor(Qt::ArrowCursor); static QPointer lastUnderMouse = 0; QCursor * override = QApplication::overrideCursor(); @@ -696,42 +697,46 @@ void qt_lite_set_cursor(QWidget * w, bool force) if (override && w != 0) return; - QPointer cursor = QGraphicsSystemCursor::getInstance(); - if (!cursor) - return; + QWidget *cursorWidget; + QCursor cursorCursor; - if (w == 0) { - if (override) { - cursor->changeCursor(override, QApplication::topLevelAt(QCursor::pos())); - return; + do { + if (w == 0) { + if (override) { + cursorCursor = *override; + cursorWidget = QApplication::topLevelAt(QCursor::pos()); + break; + } + w = QApplication::widgetAt(QCursor::pos()); + if (w == 0) // clear the override cursor while over empty space + w = QApplication::desktop(); + } else if (force) { + lastUnderMouse = w; + } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse + && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) { + w = lastUnderMouse; + } + if (w == QApplication::desktop() && !override) { + cursorCursor = arrowCursor; + cursorWidget = w; + break; } - w = QApplication::widgetAt(QCursor::pos()); - if (w == 0) // clear the override cursor while over empty space - w = QApplication::desktop(); - } else if (force) { - lastUnderMouse = w; - } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse - && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) { - w = lastUnderMouse; - } - - if (w == QApplication::desktop() && !override) { - QCursor c(Qt::ArrowCursor); - cursor->changeCursor(&c, w); - return; - } - QWidget * curWin = QApplication::activeWindow(); - if (!curWin && w && w->internalWinId()) - return; - QWidget* cW = w && !w->internalWinId() ? w : curWin; + QWidget * curWin = QApplication::activeWindow(); + if (!curWin && w && w->internalWinId()) + return; + QWidget* cW = w && !w->internalWinId() ? w : curWin; - if (!cW || cW->window() != w->window() || - !cW->isVisible() || !cW->underMouse() || override) - return; + if (!cW || cW->window() != w->window() || + !cW->isVisible() || !cW->underMouse() || override) + return; - QCursor c = w->cursor(); - cursor->changeCursor(&c, w); + cursorCursor = w->cursor(); + cursorWidget = w; + } while (0); + foreach (QWeakPointer cursor, QGraphicsSystemCursor::getInstances()) + if (cursor) + cursor.data()->changeCursor(&cursorCursor, cursorWidget); } #endif //QT_NO_CURSOR diff --git a/src/gui/painting/qgraphicssystemcursor_lite.cpp b/src/gui/painting/qgraphicssystemcursor_lite.cpp index 4c97948..623a75a 100644 --- a/src/gui/painting/qgraphicssystemcursor_lite.cpp +++ b/src/gui/painting/qgraphicssystemcursor_lite.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE -QPointer QGraphicsSystemCursor::instance = 0; +QList > QGraphicsSystemCursor::instances; /*! \class QGraphicsSystemCursor @@ -98,7 +98,7 @@ QPointer QGraphicsSystemCursor::instance = 0; QGraphicsSystemCursor::QGraphicsSystemCursor(QPlatformScreen *scr ) : screen(scr) { - instance = this; + instances.append(this); } // End of display and pointer event handling code diff --git a/src/gui/painting/qgraphicssystemcursor_lite.h b/src/gui/painting/qgraphicssystemcursor_lite.h index 1f4cfd6..a8a574e 100644 --- a/src/gui/painting/qgraphicssystemcursor_lite.h +++ b/src/gui/painting/qgraphicssystemcursor_lite.h @@ -44,10 +44,10 @@ #include #include #include -#include +#include #include -#include "qgraphicssystem_p.h" #include +#include QT_BEGIN_NAMESPACE @@ -75,13 +75,12 @@ public: virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0; - static QPointer getInstance() { return instance; } - protected: QPlatformScreen* screen; // Where to request an update private: - static QPointer instance; // limit 1 cursor at a time + static QList > getInstances() { return instances; } + static QList > instances; friend void qt_lite_set_cursor(QWidget * w, bool force); friend class QApplicationPrivate; }; diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index 2b32209..13638a0 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -8,6 +8,7 @@ #include #include #include +#include class QMouseEvent; class QSize; -- cgit v0.12 From 810cadc8430556dae9d18299a98c8c92608676b1 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 5 May 2010 14:21:18 +0200 Subject: move cursor details into a private class --- src/gui/kernel/qapplication_lite.cpp | 2 +- src/gui/kernel/qwidget_lite.cpp | 2 +- src/gui/painting/qgraphicssystemcursor_lite.cpp | 4 ++-- src/gui/painting/qgraphicssystemcursor_lite.h | 11 +++++++++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 31db7d0..5fc56a8 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -691,7 +691,7 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent * QMouseEvent ev(type, localPoint, globalPoint, button, buttons, modifiers); - QList > cursors = QGraphicsSystemCursor::getInstances(); + QList > cursors = QGraphicsSystemCursorPrivate::getInstances(); foreach (QWeakPointer cursor, cursors) { if (cursor) cursor.data()->pointerEvent(ev); diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index ed731c0..eae83f9 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -734,7 +734,7 @@ void qt_lite_set_cursor(QWidget * w, bool force) cursorCursor = w->cursor(); cursorWidget = w; } while (0); - foreach (QWeakPointer cursor, QGraphicsSystemCursor::getInstances()) + foreach (QWeakPointer cursor, QGraphicsSystemCursorPrivate::getInstances()) if (cursor) cursor.data()->changeCursor(&cursorCursor, cursorWidget); } diff --git a/src/gui/painting/qgraphicssystemcursor_lite.cpp b/src/gui/painting/qgraphicssystemcursor_lite.cpp index 623a75a..752b406 100644 --- a/src/gui/painting/qgraphicssystemcursor_lite.cpp +++ b/src/gui/painting/qgraphicssystemcursor_lite.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE -QList > QGraphicsSystemCursor::instances; +QList > QGraphicsSystemCursorPrivate::instances; /*! \class QGraphicsSystemCursor @@ -98,7 +98,7 @@ QList > QGraphicsSystemCursor::instances; QGraphicsSystemCursor::QGraphicsSystemCursor(QPlatformScreen *scr ) : screen(scr) { - instances.append(this); + QGraphicsSystemCursorPrivate::instances.append(this); } // End of display and pointer event handling code diff --git a/src/gui/painting/qgraphicssystemcursor_lite.h b/src/gui/painting/qgraphicssystemcursor_lite.h index a8a574e..9c65f7f 100644 --- a/src/gui/painting/qgraphicssystemcursor_lite.h +++ b/src/gui/painting/qgraphicssystemcursor_lite.h @@ -67,6 +67,14 @@ private: QPoint hot; }; +class QGraphicsSystemCursor; + +class QGraphicsSystemCursorPrivate { +public: + static QList > getInstances() { return instances; } + static QList > instances; +}; + class Q_GUI_EXPORT QGraphicsSystemCursor : public QObject { public: QGraphicsSystemCursor(QPlatformScreen *); @@ -79,8 +87,7 @@ protected: QPlatformScreen* screen; // Where to request an update private: - static QList > getInstances() { return instances; } - static QList > instances; + Q_DECLARE_PRIVATE(QGraphicsSystemCursor); friend void qt_lite_set_cursor(QWidget * w, bool force); friend class QApplicationPrivate; }; -- cgit v0.12 From e5cf17ca04005909dfeca938606041dfa3a1b2ad Mon Sep 17 00:00:00 2001 From: tsenyk Date: Wed, 5 May 2010 14:27:01 +0200 Subject: ifdef fix for egl on ws_lite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit reviewed by: Jørgen --- src/opengl/qgl.cpp | 3 +- src/opengl/qgl_lite.cpp | 103 ++++++++++++++++++++++++++++++++++++++++++ src/opengl/qgl_p.h | 9 ++-- src/opengl/qglpixelbuffer_p.h | 3 +- 4 files changed, 112 insertions(+), 6 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 580f3d0..26eb1e7 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1588,7 +1588,8 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) #endif #if defined(Q_WS_LITE) platformContext = 0; -#elif !defined(QT_NO_EGL) +#endif +#if !defined(QT_NO_EGL) ownsEglContext = false; eglContext = 0; eglSurface = EGL_NO_SURFACE; diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp index 0ffda5f..426683b 100644 --- a/src/opengl/qgl_lite.cpp +++ b/src/opengl/qgl_lite.cpp @@ -49,6 +49,109 @@ #include "qgl_p.h" #include "qglplatformintegration_lite.h" +#ifndef QT_NO_EGL +#include "qgl_egl_p.h" + +void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLFormat& glFormat) +{ + int redSize = glFormat.redBufferSize(); + int greenSize = glFormat.greenBufferSize(); + int blueSize = glFormat.blueBufferSize(); + int alphaSize = glFormat.alphaBufferSize(); + int depthSize = glFormat.depthBufferSize(); + int stencilSize = glFormat.stencilBufferSize(); + int sampleCount = glFormat.samples(); + + // QGLFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that + // type has been requested. So we must check QGLFormat's booleans too if size is -1: + if (glFormat.alpha() && alphaSize <= 0) + alphaSize = 1; + if (glFormat.depth() && depthSize <= 0) + depthSize = 1; + if (glFormat.stencil() && stencilSize <= 0) + stencilSize = 1; + if (glFormat.sampleBuffers() && sampleCount <= 0) + sampleCount = 1; + + // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide + // the best performance. The EGL config selection algorithm is a bit stange in this regard: + // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard + // 32-bit configs completely from the selection. So it then comes to the sorting algorithm. + // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort + // order is special and described as "by larger _total_ number of color bits.". So EGL will + // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on + // to say "If the requested number of bits in attrib_list for a particular component is 0, + // then the number of bits for that component is not considered". This part of the spec also + // seems to imply that setting the red/green/blue bits to zero means none of the components + // are considered and EGL disregards the entire sorting rule. It then looks to the next + // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being + // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are + // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit, + // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that + // if the application sets the red/green/blue size to 5/6/5 on the QGLFormat, they will + // probably get a 32-bit config, even when there's an RGB565 config avaliable. Oh well. + + // Now normalize the values so -1 becomes 0 + redSize = redSize > 0 ? redSize : 0; + greenSize = greenSize > 0 ? greenSize : 0; + blueSize = blueSize > 0 ? blueSize : 0; + alphaSize = alphaSize > 0 ? alphaSize : 0; + depthSize = depthSize > 0 ? depthSize : 0; + stencilSize = stencilSize > 0 ? stencilSize : 0; + sampleCount = sampleCount > 0 ? sampleCount : 0; + + eglProperties.setValue(EGL_RED_SIZE, redSize); + eglProperties.setValue(EGL_GREEN_SIZE, greenSize); + eglProperties.setValue(EGL_BLUE_SIZE, blueSize); + eglProperties.setValue(EGL_ALPHA_SIZE, alphaSize); + eglProperties.setValue(EGL_DEPTH_SIZE, depthSize); + eglProperties.setValue(EGL_STENCIL_SIZE, stencilSize); + eglProperties.setValue(EGL_SAMPLES, sampleCount); + eglProperties.setValue(EGL_SAMPLE_BUFFERS, sampleCount ? 1 : 0); +} + +// Updates "format" with the parameters of the selected configuration. +void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config) +{ + EGLint redSize = 0; + EGLint greenSize = 0; + EGLint blueSize = 0; + EGLint alphaSize = 0; + EGLint depthSize = 0; + EGLint stencilSize = 0; + EGLint sampleCount = 0; + EGLint level = 0; + + EGLDisplay display = QEgl::display(); + eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize); + eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize); + eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize); + eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize); + eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize); + eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize); + eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount); + eglGetConfigAttrib(display, config, EGL_LEVEL, &level); + + format.setRedBufferSize(redSize); + format.setGreenBufferSize(greenSize); + format.setBlueBufferSize(blueSize); + format.setAlphaBufferSize(alphaSize); + format.setDepthBufferSize(depthSize); + format.setStencilBufferSize(stencilSize); + format.setSamples(sampleCount); + format.setPlane(level + 1); // EGL calls level 0 "normal" whereas Qt calls 1 "normal" + format.setDirectRendering(true); // All EGL contexts are direct-rendered + format.setRgba(true); // EGL doesn't support colour index rendering + format.setStereo(false); // EGL doesn't support stereo buffers + format.setAccumBufferSize(0); // EGL doesn't support accululation buffers + + // Clear the EGL error state because some of the above may + // have errored out because the attribute is not applicable + // to the surface type. Such errors don't matter. + eglGetError(); +} +#endif + QT_BEGIN_NAMESPACE diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 34cbdfc..a2445b7 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -350,14 +350,17 @@ public: HBITMAP hbitmap; HDC hbitmap_hdc; #endif -#if defined(Q_WS_LITE) - QPlatformGLContext *platformContext; -#elif !defined(QT_NO_EGL) + +#if !defined(QT_NO_EGL) bool ownsEglContext; QEglContext *eglContext; EGLSurface eglSurface; void destroyEglSurfaceForDevice(); EGLSurface eglSurfaceForDevice() const; +#endif + +#if defined(Q_WS_LITE) + QPlatformGLContext *platformContext; #elif defined(Q_WS_X11) || defined(Q_WS_MAC) void* cx; #endif diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h index de890c9..a7f4159 100644 --- a/src/opengl/qglpixelbuffer_p.h +++ b/src/opengl/qglpixelbuffer_p.h @@ -197,8 +197,7 @@ public: EGLSurface pbuf; QEglContext *ctx; int textureFormat; -#endif -#if defined(Q_WS_LITE) +#elif defined(Q_WS_LITE) // Stubs int pbuf; int ctx; -- cgit v0.12 From 6f39ecdabdae9b2132729a2a9940e5febaa420d2 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 5 May 2010 13:50:16 +0200 Subject: Small GL related fixes --- src/plugins/platforms/testlite/qglxintegration.cpp | 30 ++++++++++++++++++++-- src/plugins/platforms/testlite/qtestlitewindow.cpp | 13 +++++++--- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index 88764f3..79596f5 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include #include #include @@ -54,7 +55,6 @@ #include #endif - QT_BEGIN_NAMESPACE GLXFBConfig qt_glx_integration_choose_config(MyDisplay* xd, QGLFormat& format, int drawableType) @@ -171,7 +171,11 @@ bool QGLXGLWidgetSurface::create(QGLWidget *widget, QGLFormat& format) widget->x(), widget->y(), widget->width(), widget->height(), 0, visualInfo->depth, InputOutput, visualInfo->visual, CWBackPixel|CWBorderPixel|CWColormap, &windowAttribs); +#ifdef MYX11_DEBUG + qDebug() << "QGLXGLWidgetSurface::create" << hex << "parent" << parentWindow << "win:" << m_winId << widget; +#endif + XSetWindowBackgroundPixmap(m_xd->display, m_winId, XNone); XMapWindow(m_xd->display, m_winId); XFree(visualInfo); @@ -180,7 +184,15 @@ bool QGLXGLWidgetSurface::create(QGLWidget *widget, QGLFormat& format) void QGLXGLWidgetSurface::setGeometry(const QRect& rect) { - XMoveResizeWindow(m_xd->display, m_winId, rect.x(), rect.y(), rect.width(), rect.height()); +#ifdef MYX11_DEBUG + qDebug() << "QGLXGLWidgetSurface::setGeometry" << rect << hex << m_xd->display << m_winId << "toplevel?" << m_widget->isWindow(); +#endif + //### toplevel QGLWidgets do have a separate X window owned by the surface, but it has a + // local geometry + if (m_widget->isWindow()) + XMoveResizeWindow(m_xd->display, m_winId, 0, 0, rect.width(), rect.height()); + else + XMoveResizeWindow(m_xd->display, m_winId, rect.x(), rect.y(), rect.width(), rect.height()); } bool QGLXGLWidgetSurface::filterEvent(QEvent *e) @@ -191,12 +203,18 @@ bool QGLXGLWidgetSurface::filterEvent(QEvent *e) // which would otherwise destroy our window along with it. XUnmapWindow(m_xd->display, m_winId); XReparentWindow(m_xd->display, m_winId, m_xd->rootWindow(), 0, 0); +#ifdef MYX11_DEBUG + qDebug() << "filterEvent unmap" << hex << m_winId; +#endif } if (e->type() == QEvent::ParentChange) { // Once we've got a new parent, we need to reparent the window and show it again: XReparentWindow(m_xd->display, m_winId, m_widget->window()->winId(), m_widget->x(), m_widget->y()); XMapWindow(m_xd->display, m_winId); +#ifdef MYX11_DEBUG + qDebug() << "filterEvent reparent" << hex << m_winId << "to:" << m_widget->window()->winId(); +#endif } return false; // Allow the event to pass through to QGLWidget @@ -241,6 +259,9 @@ bool QGLXGLContext::create(QPaintDevice* device, QGLFormat& format, QPlatformGLC QGLXGLWidgetSurface* surface = static_cast(glWidget->platformSurface()); m_config = surface->config(); m_drawable = (Drawable)surface->winId(); +#ifdef MYX11_DEBUG + qDebug() << "QGLXGLContext::create" << hex << m_config << m_drawable; +#endif } else { if (!widget->isTopLevel()) { @@ -254,6 +275,9 @@ bool QGLXGLContext::create(QPaintDevice* device, QGLFormat& format, QPlatformGLC } m_context = glXCreateNewContext(m_xd->display, m_config, GLX_RGBA_TYPE, shareGlxContext, True); +#ifdef MYX11_DEBUG + qDebug() << "QGLXGLContext::create context" << m_context; +#endif // Get the XVisualInfo for the window: // XWindowAttributes windowAttribs; @@ -273,7 +297,9 @@ bool QGLXGLContext::create(QPaintDevice* device, QGLFormat& format, QPlatformGLC void QGLXGLContext::makeCurrent() { +#ifdef MYX11_DEBUG qDebug("QGLXGLContext::makeCurrent(window=0x%x, ctx=0x%x)", m_drawable, m_context); +#endif glXMakeCurrent(m_xd->display, m_drawable, m_context); } diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index 242f335..b5ae4fc 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -69,6 +69,8 @@ #undef ATOM #undef X11 +//#define MYX11_DEBUG + QT_BEGIN_NAMESPACE static int (*original_x_errhandler)(Display *dpy, XErrorEvent *); @@ -158,6 +160,9 @@ QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration x, y, w, h, 0 /*border_width*/, xd->blackPixel(), xd->whitePixel()); +#ifdef MYX11_DEBUG + qDebug() << "QTestLiteWindow::QTestLiteWindow creating" << hex << x_window << window; +#endif } width = -1; @@ -673,7 +678,7 @@ GC QTestLiteWindow::createGC() void QTestLiteWindow::paintEvent() { #ifdef MYX11_DEBUG - qDebug() << "QTestLiteWindow::paintEvent" << shm_img.size() << painted; +// qDebug() << "QTestLiteWindow::paintEvent" << shm_img.size() << painted; #endif widget()->windowSurface()->flush(widget(), QRect(xpos,ypos,width, height), QPoint()); @@ -694,7 +699,7 @@ void QTestLiteWindow::resizeEvent(XConfigureEvent *e) height = e->height; #ifdef MYX11_DEBUG - qDebug() << hex << window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height << "img:" << shm_img.size(); + qDebug() << hex << x_window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height; #endif QWindowSystemInterface::handleGeometryChange(widget(), QRect(xpos, ypos, width, height)); @@ -833,7 +838,7 @@ Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags) } #ifdef MYX11_DEBUG - qDebug() << "QTestLiteWindow::setWindowFlags" << hex << window << "flags" << flags; + qDebug() << "QTestLiteWindow::setWindowFlags" << hex << x_window << "flags" << flags; #endif Qt::WindowType type = static_cast(int(flags & Qt::WindowType_Mask)); @@ -963,7 +968,7 @@ Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags) void QTestLiteWindow::setVisible(bool visible) { #ifdef MYX11_DEBUG - qDebug() << "QTestLiteWindow::setVisible" << visible << hex << window; + qDebug() << "QTestLiteWindow::setVisible" << visible << hex << x_window; #endif if (visible) XMapWindow(xd->display, x_window); -- cgit v0.12 From 9b33f9c47cf5346404c54196b72d0b3b80f32454 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 10 May 2010 15:15:06 +0200 Subject: Build fix for Lighthouse --- src/plugins/mediaservices/gstreamer/gstreamer.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/mediaservices/gstreamer/gstreamer.pro b/src/plugins/mediaservices/gstreamer/gstreamer.pro index 6e05120..15c4b09 100644 --- a/src/plugins/mediaservices/gstreamer/gstreamer.pro +++ b/src/plugins/mediaservices/gstreamer/gstreamer.pro @@ -36,7 +36,7 @@ SOURCES += \ qvideosurfacegstsink.cpp -!win32:!embedded:!mac:!symbian { +!win32:!embedded:!mac:!symbian:!embedded_lite { LIBS += -lXv HEADERS += \ -- cgit v0.12 From b2e80f7525546b494543c902dbf8efb8b8609fc5 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 10 May 2010 15:40:28 +0200 Subject: adjust mouse movement for the screen's offset --- src/plugins/platforms/vnc/qvncserver.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp index bd4d6ab..6424083 100644 --- a/src/plugins/platforms/vnc/qvncserver.cpp +++ b/src/plugins/platforms/vnc/qvncserver.cpp @@ -836,7 +836,8 @@ void QVNCServer::pointerEvent() // const QPoint offset = qvnc_screen->offset(); // QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons); - + QPoint eventPoint(ev.x, ev.y); + eventPoint += screen()->geometry().topLeft(); //qDebug() << "pointerEvent" << ev.x << ev.y << hex << ev.buttons; if (ev.wheelDirection == ev.WheelNone) { QEvent::Type type = QEvent::MouseMove; @@ -844,7 +845,7 @@ void QVNCServer::pointerEvent() bool isPress; if (buttonChange(buttons, ev.buttons, &button, &isPress)) type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - QWindowSystemInterface::handleMouseEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), ev.buttons); + QWindowSystemInterface::handleMouseEvent(0, eventPoint, eventPoint, ev.buttons); } else { // No buttons or motion reported at the same time as wheel events Qt::Orientation orientation; @@ -853,7 +854,7 @@ void QVNCServer::pointerEvent() else orientation = Qt::Vertical; int delta = 120 * ((ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelUp) ? 1 : -1); - QWindowSystemInterface::handleWheelEvent(0, QPoint(ev.x, ev.y), QPoint(ev.x, ev.y), delta, orientation); + QWindowSystemInterface::handleWheelEvent(0, eventPoint, eventPoint, delta, orientation); } handleMsg = false; } -- cgit v0.12 From 075e96eba50013c583234b787562e09bb7535dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 29 Apr 2010 14:47:35 +0200 Subject: Say hello to Qt for Native Client. This commits adds build system to support for the native client compiler (x86-only for now), sets up global defines, and adds compile fixes for QtCore and QtGui. Details: * Add mkspecs for linux-nacl-g++ and macx-nacl-c++ * Add nacl configure option * Add qconfig-minimal-system-dependencies.h * Define Q_OS_NACL in qglobal.h * Add qnacalunimplemented.h/cpp with POSIX stubs. * .pro file changes for cross-compiling on Mac --- configure | 77 ++++- mkspecs/qws/linux-nacl-g++/qmake.conf | 74 ++++ mkspecs/qws/linux-nacl-g++/qplatformdefs.h | 175 ++++++++++ mkspecs/qws/macx-generic-g++/qmake.conf | 6 +- mkspecs/qws/macx-nacl-g++/qmake.conf | 95 ++++++ mkspecs/qws/macx-nacl-g++/qplatformdefs.h | 175 ++++++++++ src/corelib/arch/qatomic_arch.h | 2 + src/corelib/corelib.pro | 2 +- src/corelib/global/global.pri | 4 + .../global/qconfig-minimal-system-dependencies.h | 371 +++++++++++++++++++++ src/corelib/global/qglobal.h | 6 + src/corelib/global/qnaclunimplemented.cpp | 156 +++++++++ src/corelib/global/qnaclunimplemented.h | 85 +++++ src/corelib/io/io.pri | 10 +- src/corelib/io/qresource.cpp | 2 +- src/corelib/kernel/kernel.pri | 4 +- src/corelib/kernel/qcore_unix.cpp | 3 +- src/corelib/kernel/qeventdispatcher_unix.cpp | 14 +- src/corelib/kernel/qeventdispatcher_unix_p.h | 2 +- src/corelib/thread/qthread_unix.cpp | 2 + src/corelib/tools/tools.pri | 2 +- src/gui/kernel/mac.pri | 2 +- .../kernel/qplatformintegrationfactory_lite.cpp | 2 +- src/gui/text/qfontdatabase_qws.cpp | 2 + src/src.pro | 2 + 25 files changed, 1254 insertions(+), 21 deletions(-) create mode 100644 mkspecs/qws/linux-nacl-g++/qmake.conf create mode 100644 mkspecs/qws/linux-nacl-g++/qplatformdefs.h create mode 100644 mkspecs/qws/macx-nacl-g++/qmake.conf create mode 100644 mkspecs/qws/macx-nacl-g++/qplatformdefs.h create mode 100644 src/corelib/global/qconfig-minimal-system-dependencies.h create mode 100644 src/corelib/global/qnaclunimplemented.cpp create mode 100644 src/corelib/global/qnaclunimplemented.h diff --git a/configure b/configure index 69df540..da34fb5 100755 --- a/configure +++ b/configure @@ -296,6 +296,12 @@ earlyArgParse() VAL=$1 fi ;; + -nacl) + shift; + VAR=nacl + VAL=$1 + ;; + -h|help|--help|-help) if [ "$VAL" = "yes" ]; then OPT_HELP="$VAL" @@ -353,6 +359,15 @@ earlyArgParse() CFG_EMBEDDED=no fi ;; + nacl) + echo "Using NaCl at $VAL." + PLATFORM_X11=no + PLATFORM_MAC=no + PLATFORM_QWS=no + CFG_NACL_PATH=$VAL + CFG_EMBEDDED=nacl + ;; + developer-build) CFG_DEV="yes" ;; @@ -928,6 +943,44 @@ if [ -d "$relpath/src/plugins/gfxdrivers" ]; then fi #------------------------------------------------------------------------------- +# Set Default NaCl options +#------------------------------------------------------------------------------- +if [ "$CFG_EMBEDDED" = "nacl" ]; then + echo "Setting NaCl options:" + echo "-static" + CFG_SHARED=no + echo "-embedded-lite nacl" + PLATFORM_EMBLITE=yes + echo "-fast" + OPT_FAST=yes + echo "-release" + CFG_DEBUG=no + echo "-qconfig minimal-system-dependencies" + CFG_QCONFIG=minimal-system-dependencies + + if [ `uname` = "Linux" ]; then + I_FLAGS="$I_FLAGS -I${CFG_NACL_PATH}/toolchain/linux_x86/sdk/nacl-sdk/include" + L_FLAGS="$L_FLAGS -I${CFG_NACL_PATH}/toolchain/linux_x86/sdk/nacl-sdk/lib" + else + I_FLAGS="$I_FLAGS -I${CFG_NACL_PATH}/toolchain/mac_x86/sdk/nacl-sdk/include" + L_FLAGS="$L_FLAGS -I${CFG_NACL_PATH}/toolchain/mac_x86/sdk/nacl-sdk/lib" + fi + + echo "-no-multimedia -no-webkit -no-phonon -no-nultimedia -no-mediaservices -no-xmlpatterns -no-script -no-sql-sqlite -nomake tests" + CFG_MULTIMEDIA=no + CFG_WEBKIT=no + CFG_PHONON=no + CFG_MULTIMEDIA=no + CFG_MEDIASERVICES=no + CFG_XMLPATTERNS=no + CFG_SCRIPT=no + CFG_SQLITE=no + CFG_SQL_sqlite=no + CFG_NOBUILD_PARTS="$CFG_NOBUILD_PARTS tests" + QT_CONFIG="$QT_CONFIG nacl" +fi + +#------------------------------------------------------------------------------- # parse command line arguments #------------------------------------------------------------------------------- @@ -1024,6 +1077,10 @@ while [ "$#" -gt 0 ]; do VAL=$1 fi ;; + -nacl) + VAR=nacl + shift; + ;; -opengl) VAR=opengl # this option may or may not be followed by an argument @@ -1262,6 +1319,8 @@ while [ "$#" -gt 0 ]; do CFG_EMBEDDED=no fi ;; + nacl) + ;; sse) if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then CFG_SSE="$VAL" @@ -3114,6 +3173,10 @@ if [ -z "$TEST_COMPILER" ]; then exit 1 fi +if [ "$CFG_EMBEDDED" = "nacl" ]; then + TEST_COMPILER="nacl-gcc" +fi + # auto-detect precompiled header support if [ "$CFG_PRECOMPILE" = "auto" ]; then if [ `echo "$CFG_MAC_ARCHS" | wc -w` -gt 1 ]; then @@ -6599,6 +6662,13 @@ if [ "$PLATFORM_EMBLITE" = "yes" ]; then QT_CONFIG="$QT_CONFIG embedded_lite" rm -f "src/.moc/$QMAKE_OUTDIR/allmoc.cpp" # needs remaking if config changes fi + +if [ "$CFG_EMBEDDED" = "nacl" ]; then + QMAKE_CONFIG="$QMAKE_CONFIG nacl pepper" + QT_CONFIG="$QT_CONFIG nacl pepper" + rm -f "src/.moc/$QMAKE_OUTDIR/allmoc.cpp" # needs remaking if config changes +fi + QMakeVar set PRECOMPILED_DIR ".pch/$QMAKE_OUTDIR" QMakeVar set OBJECTS_DIR ".obj/$QMAKE_OUTDIR" QMakeVar set MOC_DIR ".moc/$QMAKE_OUTDIR" @@ -7802,10 +7872,11 @@ QMAKE_LIBDIR_QT = \$\$QT_BUILD_TREE/lib EOF # Ensure we can link to uninistalled libraries -if linkerSupportsFlag -rpath-link "$outpath/lib"; then - echo "QMAKE_LFLAGS += -Wl,-rpath-link,\$\$QT_BUILD_TREE/lib" >> "$CACHEFILE.tmp" +if [ "$CFG_EMBEDDED" != "nacl" ]; then + if linkerSupportsFlag -rpath-link "$outpath/lib"; then + echo "QMAKE_LFLAGS += -Wl,-rpath-link,\$\$QT_BUILD_TREE/lib" >> "$CACHEFILE.tmp" + fi fi - if [ -n "$QT_CFLAGS_PSQL" ]; then echo "QT_CFLAGS_PSQL = $QT_CFLAGS_PSQL" >> "$CACHEFILE.tmp" fi diff --git a/mkspecs/qws/linux-nacl-g++/qmake.conf b/mkspecs/qws/linux-nacl-g++/qmake.conf new file mode 100644 index 0000000..83ce65b --- /dev/null +++ b/mkspecs/qws/linux-nacl-g++/qmake.conf @@ -0,0 +1,74 @@ +# +# qmake configuration for building with nacl-g++ +# + +include(../../common/unix.conf) +include(../../common/qws.conf) + +QT = core gui + +# copy of ../../common/g++.conf, with modifications: + +QMAKE_CC = nacl-gcc +QMAKE_CXX = nacl-g++ +QMAKE_LINK = nacl-g++ +QMAKE_LINK_SHLIB = nacl-g++ + +#QMAKE_CC = gcc +QMAKE_CFLAGS += -pipe -DXP_UNIX -DNACL_STANDALONE=1 +QMAKE_CFLAGS_DEPS += -M +QMAKE_CFLAGS_WARN_ON += -Wall -W +QMAKE_CFLAGS_WARN_OFF += -w +QMAKE_CFLAGS_RELEASE += -O2 +QMAKE_CFLAGS_DEBUG += -g +QMAKE_CFLAGS_SHLIB += -fPIC +#QMAKE_CFLAGS_STATIC_LIB += -fPIC +QMAKE_CFLAGS_YACC += -Wno-unused -Wno-parentheses +QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden +QMAKE_CFLAGS_PRECOMPILE += -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_CFLAGS_USE_PRECOMPILE += -include ${QMAKE_PCH_OUTPUT_BASE} + +#QMAKE_CXX = g++ +QMAKE_CXXFLAGS += $$QMAKE_CFLAGS +QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS +QMAKE_CXXFLAGS_WARN_ON += $$QMAKE_CFLAGS_WARN_ON +QMAKE_CXXFLAGS_WARN_OFF += $$QMAKE_CFLAGS_WARN_OFF +QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE +QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_DEBUG +QMAKE_CXXFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB +QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB +QMAKE_CXXFLAGS_YACC += $$QMAKE_CFLAGS_YACC +QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden +QMAKE_CXXFLAGS_PRECOMPILE += -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} +QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE + +#QMAKE_LINK = g++ +#QMAKE_LINK_SHLIB = g++ +QMAKE_LINK_C = gcc +QMAKE_LINK_C_SHLIB = gcc +QMAKE_LFLAGS += +QMAKE_LFLAGS_RELEASE += -Wl,-O1 +QMAKE_LFLAGS_DEBUG += +QMAKE_LFLAGS_APP += +QMAKE_LFLAGS_SHLIB += -shared +QMAKE_LFLAGS_PLUGIN += $$QMAKE_LFLAGS_SHLIB +QMAKE_LFLAGS_SONAME += -Wl,-soname, +QMAKE_LFLAGS_THREAD += +QMAKE_LFLAGS_NOUNDEF += -Wl,--no-undefined +QMAKE_LFLAGS_RPATH = -Wl,-rpath, + +QMAKE_LIBS = -lgoogle_nacl_imc -lgoogle_nacl_npruntime -lgoogle_nacl_pgl -lgoogle_nacl_gpu -lpthread -lsrpc + +QMAKE_PCH_OUTPUT_EXT = .gch + +# -Bsymbolic-functions (ld) support +QMAKE_LFLAGS_BSYMBOLIC_FUNC = -Wl,-Bsymbolic-functions +QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list, + +# modifications to linux.conf +QMAKE_AR = nacl-ar q +QMAKE_OBJCOPY = nacl-objcopy +QMAKE_STRIP = nacl-strip +QMAKE_LIBS_DYNLOAD = + +load(qt_config) diff --git a/mkspecs/qws/linux-nacl-g++/qplatformdefs.h b/mkspecs/qws/linux-nacl-g++/qplatformdefs.h new file mode 100644 index 0000000..a670ee5 --- /dev/null +++ b/mkspecs/qws/linux-nacl-g++/qplatformdefs.h @@ -0,0 +1,175 @@ +/**************************************************************************** + ** + ** 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 QtCore 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 QPLATFORMDEFS_H +#define QPLATFORMDEFS_H + +// Get Qt defines/settings + +#define _POSIX_TIMERS + +#include "qglobal.h" + + +#define _POSIX_TIMERS +// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs + +// 1) need to reset default environment if _BSD_SOURCE is defined +// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0 +// 3) it seems older glibc need this to include the X/Open stuff +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif + +#include + + +// We are hot - unistd.h should have turned on the specific APIs we requested + +#include +#include +#include +#include +#include +#include +#include +//#include + +#include +//#include +//#include + +#include +//#include +//#include +#include +#include +//#include +#ifndef QT_NO_IPV6IFNAME +#include +#endif + +// extra disabling. +#ifdef __native_client__ +#define QT_NO_FSFILEENGINE +#define QT_NO_TRANSLATION +#endif + +#ifdef QT_LARGEFILE_SUPPORT +#define QT_STATBUF struct stat64 +#define QT_STATBUF4TSTAT struct stat64 +#define QT_STAT ::stat64 +#define QT_FSTAT ::fstat64 +#define QT_LSTAT ::lstat64 +#define QT_OPEN ::open64 +#define QT_TRUNCATE ::truncate64 +#define QT_FTRUNCATE ::ftruncate64 +#define QT_LSEEK ::lseek64 +#else +#define QT_STATBUF struct stat +#define QT_STATBUF4TSTAT struct stat +#define QT_STAT ::stat +#define QT_FSTAT ::fstat +#define QT_LSTAT ::lstat +#define QT_OPEN ::open +#define QT_TRUNCATE ::truncate +#define QT_FTRUNCATE ::ftruncate +#define QT_LSEEK ::lseek +#endif + +#ifdef QT_LARGEFILE_SUPPORT +#define QT_FOPEN ::fopen64 +#define QT_FSEEK ::fseeko64 +#define QT_FTELL ::ftello64 +#define QT_FGETPOS ::fgetpos64 +#define QT_FSETPOS ::fsetpos64 +#define QT_FPOS_T fpos64_t +#define QT_OFF_T off64_t +#else +#define QT_FOPEN ::fopen +#define QT_FSEEK ::fseek +#define QT_FTELL ::ftell +#define QT_FGETPOS ::fgetpos +#define QT_FSETPOS ::fsetpos +#define QT_FPOS_T fpos_t +#define QT_OFF_T long +#endif + +#define QT_STAT_REG S_IFREG +#define QT_STAT_DIR S_IFDIR +#define QT_STAT_MASK S_IFMT +#define QT_STAT_LNK S_IFLNK +#define QT_SOCKET_CONNECT ::connect +#define QT_SOCKET_BIND ::bind +#define QT_FILENO fileno +#define QT_CLOSE ::close +#define QT_READ ::read +#define QT_WRITE ::write +#define QT_ACCESS ::access +#define QT_GETCWD ::getcwd +#define QT_CHDIR ::chdir +#define QT_MKDIR ::mkdir +#define QT_RMDIR ::rmdir +#define QT_OPEN_LARGEFILE O_LARGEFILE +#define QT_OPEN_RDONLY O_RDONLY +#define QT_OPEN_WRONLY O_WRONLY +#define QT_OPEN_RDWR O_RDWR +#define QT_OPEN_CREAT O_CREAT +#define QT_OPEN_TRUNC O_TRUNC +#define QT_OPEN_APPEND O_APPEND + +#define QT_SIGNAL_RETTYPE void +#define QT_SIGNAL_ARGS int +#define QT_SIGNAL_IGNORE SIG_IGN + +#if defined(__GLIBC__) && (__GLIBC__ >= 2) +#define QT_SOCKLEN_T socklen_t +#else +#define QT_SOCKLEN_T int +#endif + +#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) +#define QT_SNPRINTF ::snprintf +#define QT_VSNPRINTF ::vsnprintf +#endif + + +#endif // QPLATFORMDEFS_H diff --git a/mkspecs/qws/macx-generic-g++/qmake.conf b/mkspecs/qws/macx-generic-g++/qmake.conf index 9096712..63bfc57 100644 --- a/mkspecs/qws/macx-generic-g++/qmake.conf +++ b/mkspecs/qws/macx-generic-g++/qmake.conf @@ -2,6 +2,8 @@ # qmake configuration for macx-g++ with Qtopia Core # +include(../../common/unix.conf) + MAKEFILE_GENERATOR = UNIX TARGET_PLATFORM = macx TEMPLATE = app @@ -18,7 +20,7 @@ QMAKE_YACCFLAGS = -d QMAKE_CFLAGS = -pipe QMAKE_CFLAGS_WARN_ON = -Wall -W QMAKE_CFLAGS_WARN_OFF = -QMAKE_CFLAGS_RELEASE = -O2 -fno-default-inline +QMAKE_CFLAGS_RELEASE = -O2 QMAKE_CFLAGS_DEBUG = -g QMAKE_CFLAGS_SHLIB = -fPIC QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses @@ -29,7 +31,7 @@ QMAKE_CXX = $(TB)c++ QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -DQT_NO_QWS_TRANSFORMED QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE +QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -fno-default-inline QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC diff --git a/mkspecs/qws/macx-nacl-g++/qmake.conf b/mkspecs/qws/macx-nacl-g++/qmake.conf new file mode 100644 index 0000000..0a54b4b --- /dev/null +++ b/mkspecs/qws/macx-nacl-g++/qmake.conf @@ -0,0 +1,95 @@ +# +# qmake configuration for macx-nacl-g++ with embedded-lite +# + +include(../../common/unix.conf) + +MAKEFILE_GENERATOR = UNIX +TEMPLATE = app +CONFIG += qt warn_on release link_prl +QT += core gui +QMAKE_INCREMENTAL_STYLE = sublib +QMAKE_EXTENSION_SHLIB = dylib + + +QMAKE_CC = nacl-gcc +QMAKE_CXX = nacl-g++ +QMAKE_LINK = nacl-g++ +QMAKE_LINK_SHLIB = nacl-g++ + +#QMAKE_CC = $(TB)cc +QMAKE_LEX = flex +QMAKE_LEXFLAGS = +QMAKE_YACC = yacc +QMAKE_YACCFLAGS = -d +QMAKE_CFLAGS = -pipe -DXP_UNIX -DNACL_STANDALONE=1 +QMAKE_CFLAGS_WARN_ON = -Wall -W +QMAKE_CFLAGS_WARN_OFF = +QMAKE_CFLAGS_RELEASE = -O2 +QMAKE_CFLAGS_DEBUG = -g +QMAKE_CFLAGS_SHLIB = -fPIC +QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses +QMAKE_CFLAGS_THREAD = -D_REENTRANT +QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden + +#QMAKE_CXX = $(TB)c++ +QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -DQT_NO_QWS_TRANSFORMED +QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON +QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF +QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -fno-default-inline +QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG +QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB +QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC +QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD +QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden + +QMAKE_INCDIR = +QMAKE_LIBDIR = +QMAKE_INCDIR_X11 = +QMAKE_LIBDIR_X11 = +QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] +QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] +QMAKE_INCDIR_OPENGL = +QMAKE_LIBDIR_OPENGL = +QMAKE_INCDIR_QTOPIA = $(QPEDIR)/include +QMAKE_LIBDIR_QTOPIA = $(QPEDIR)/lib + +#QMAKE_LINK = $$QMAKE_CXX +#QMAKE_LINK_SHLIB = $$QMAKE_CXX +QMAKE_LFLAGS = +QMAKE_LFLAGS_RELEASE = +QMAKE_LFLAGS_DEBUG = +QMAKE_LFLAGS_SHLIB = -dynamiclib +QMAKE_LFLAGS_INCREMENTAL = -undefined suppress -flat_namespace +QMAKE_LFLAGS_PLUGIN = -bundle +QMAKE_LFLAGS_SONAME = +QMAKE_LFLAGS_THREAD = + +QMAKE_LIBS = -lgoogle_nacl_imc -lgoogle_nacl_npruntime -lgoogle_nacl_pgl -lgoogle_nacl_gpu -lpthread -lsrpc +QMAKE_LIBS_X11 = +QMAKE_LIBS_X11SM = +QMAKE_LIBS_QT = -lqte +QMAKE_LIBS_QT_THREAD = -lqte-mt +QMAKE_LIBS_QT_OPENGL = -lqgl +QMAKE_LIBS_QTOPIA = -lqpe -lqtopia +QMAKE_LIBS_THREAD = +QMAKE_LIBS_OPENGL = + +QMAKE_MOC = $$[QT_INSTALL_BINS]/moc +QMAKE_UIC = $$[QT_INSTALL_BINS]/uic + +QMAKE_AR = nacl-ar q +QMAKE_OBJCOPY = nacl-objcopy +QMAKE_STRIP = nacl-strip +QMAKE_RANLIB = + +QMAKE_TAR = tar -cf +QMAKE_GZIP = gzip -9f + +QMAKE_COPY = cp -f +QMAKE_MOVE = mv -f +QMAKE_DEL_FILE = rm -f +QMAKE_DEL_DIR = rmdir +QMAKE_CHK_DIR_EXISTS = test -d +QMAKE_MKDIR = mkdir -p +load(qt_config) diff --git a/mkspecs/qws/macx-nacl-g++/qplatformdefs.h b/mkspecs/qws/macx-nacl-g++/qplatformdefs.h new file mode 100644 index 0000000..a670ee5 --- /dev/null +++ b/mkspecs/qws/macx-nacl-g++/qplatformdefs.h @@ -0,0 +1,175 @@ +/**************************************************************************** + ** + ** 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 QtCore 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 QPLATFORMDEFS_H +#define QPLATFORMDEFS_H + +// Get Qt defines/settings + +#define _POSIX_TIMERS + +#include "qglobal.h" + + +#define _POSIX_TIMERS +// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs + +// 1) need to reset default environment if _BSD_SOURCE is defined +// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0 +// 3) it seems older glibc need this to include the X/Open stuff +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif + +#include + + +// We are hot - unistd.h should have turned on the specific APIs we requested + +#include +#include +#include +#include +#include +#include +#include +//#include + +#include +//#include +//#include + +#include +//#include +//#include +#include +#include +//#include +#ifndef QT_NO_IPV6IFNAME +#include +#endif + +// extra disabling. +#ifdef __native_client__ +#define QT_NO_FSFILEENGINE +#define QT_NO_TRANSLATION +#endif + +#ifdef QT_LARGEFILE_SUPPORT +#define QT_STATBUF struct stat64 +#define QT_STATBUF4TSTAT struct stat64 +#define QT_STAT ::stat64 +#define QT_FSTAT ::fstat64 +#define QT_LSTAT ::lstat64 +#define QT_OPEN ::open64 +#define QT_TRUNCATE ::truncate64 +#define QT_FTRUNCATE ::ftruncate64 +#define QT_LSEEK ::lseek64 +#else +#define QT_STATBUF struct stat +#define QT_STATBUF4TSTAT struct stat +#define QT_STAT ::stat +#define QT_FSTAT ::fstat +#define QT_LSTAT ::lstat +#define QT_OPEN ::open +#define QT_TRUNCATE ::truncate +#define QT_FTRUNCATE ::ftruncate +#define QT_LSEEK ::lseek +#endif + +#ifdef QT_LARGEFILE_SUPPORT +#define QT_FOPEN ::fopen64 +#define QT_FSEEK ::fseeko64 +#define QT_FTELL ::ftello64 +#define QT_FGETPOS ::fgetpos64 +#define QT_FSETPOS ::fsetpos64 +#define QT_FPOS_T fpos64_t +#define QT_OFF_T off64_t +#else +#define QT_FOPEN ::fopen +#define QT_FSEEK ::fseek +#define QT_FTELL ::ftell +#define QT_FGETPOS ::fgetpos +#define QT_FSETPOS ::fsetpos +#define QT_FPOS_T fpos_t +#define QT_OFF_T long +#endif + +#define QT_STAT_REG S_IFREG +#define QT_STAT_DIR S_IFDIR +#define QT_STAT_MASK S_IFMT +#define QT_STAT_LNK S_IFLNK +#define QT_SOCKET_CONNECT ::connect +#define QT_SOCKET_BIND ::bind +#define QT_FILENO fileno +#define QT_CLOSE ::close +#define QT_READ ::read +#define QT_WRITE ::write +#define QT_ACCESS ::access +#define QT_GETCWD ::getcwd +#define QT_CHDIR ::chdir +#define QT_MKDIR ::mkdir +#define QT_RMDIR ::rmdir +#define QT_OPEN_LARGEFILE O_LARGEFILE +#define QT_OPEN_RDONLY O_RDONLY +#define QT_OPEN_WRONLY O_WRONLY +#define QT_OPEN_RDWR O_RDWR +#define QT_OPEN_CREAT O_CREAT +#define QT_OPEN_TRUNC O_TRUNC +#define QT_OPEN_APPEND O_APPEND + +#define QT_SIGNAL_RETTYPE void +#define QT_SIGNAL_ARGS int +#define QT_SIGNAL_IGNORE SIG_IGN + +#if defined(__GLIBC__) && (__GLIBC__ >= 2) +#define QT_SOCKLEN_T socklen_t +#else +#define QT_SOCKLEN_T int +#endif + +#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) +#define QT_SNPRINTF ::snprintf +#define QT_VSNPRINTF ::vsnprintf +#endif + + +#endif // QPLATFORMDEFS_H diff --git a/src/corelib/arch/qatomic_arch.h b/src/corelib/arch/qatomic_arch.h index 00b288b..5106d29 100644 --- a/src/corelib/arch/qatomic_arch.h +++ b/src/corelib/arch/qatomic_arch.h @@ -88,6 +88,8 @@ QT_BEGIN_HEADER # include "QtCore/qatomic_sh.h" #elif defined(QT_ARCH_SH4A) # include "QtCore/qatomic_sh4a.h" +#elif defined(QT_ARCH_NACL) +# include "QtCore/qatomic_generic.h" #else # error "Qt has not been ported to this architecture" #endif diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 83fa044..5a810b1 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -18,7 +18,7 @@ include(codecs/codecs.pri) include(statemachine/statemachine.pri) include(xml/xml.pri) -mac|darwin:LIBS_PRIVATE += -framework ApplicationServices +!nacl:mac|darwin:LIBS_PRIVATE += -framework ApplicationServices 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 b916b4d..758c5ee 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -13,6 +13,10 @@ 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-minimal-system-dependencies.h new file mode 100644 index 0000000..c7e3633 --- /dev/null +++ b/src/corelib/global/qconfig-minimal-system-dependencies.h @@ -0,0 +1,371 @@ +/**************************************************************************** + ** + ** 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 QtCore 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$ + ** + ****************************************************************************/ + +#define QT_FONTS_ARE_RESOURCES + +/* Data structures */ +#ifndef QT_NO_QUUID_STRING +# define QT_NO_QUUID_STRING +#endif +#ifndef QT_NO_STL +# define QT_NO_STL +#endif +#ifndef QT_NO_TEXTDATE +# define QT_NO_TEXTDATE +#endif +#ifndef QT_NO_DATESTRING +# define QT_NO_DATESTRING +#endif + +/* Dialogs */ +#ifndef QT_NO_FILEDIALOG +# define QT_NO_FILEDIALOG +#endif +#ifndef QT_NO_PRINTDIALOG +# define QT_NO_PRINTDIALOG +#endif +#ifndef QT_NO_PRINTPREVIEWDIALOG +# define QT_NO_PRINTPREVIEWDIALOG +#endif + + +/* File I/O */ +#ifndef QT_NO_DOM +# define QT_NO_DOM +#endif +#ifndef QT_NO_FILESYSTEMWATCHER +# define QT_NO_FILESYSTEMWATCHER +#endif +#ifndef QT_NO_FSFILEENGINE +# define QT_NO_FSFILEENGINE +#endif +#ifndef QT_NO_FILESYSTEMMODEL +# define QT_NO_FILESYSTEMMODEL +#endif +#ifndef QT_NO_FILESYSTEMMODEL +# define QT_NO_FILESYSTEMMODEL +#endif +#ifndef QT_NO_PROCESS +# define QT_NO_PROCESS +#endif +#ifndef QT_NO_TEMPORARYFILE +# define QT_NO_TEMPORARYFILE +#endif +#ifndef QT_NO_SETTINGS +# define QT_NO_SETTINGS +#endif +#ifndef QT_NO_LIBRARY +# define QT_NO_LIBRARY +#endif + +/* Fonts */ +#ifndef QT_NO_QWS_QPF2 +# define QT_NO_QWS_QPF2 +#endif + +/* Images */ +#ifndef QT_NO_IMAGEFORMATPLUGIN +# define QT_NO_IMAGEFORMATPLUGIN +#endif +#ifndef QT_NO_IMAGE_HEURISTIC_MASK +# define QT_NO_IMAGE_HEURISTIC_MASK +#endif +#ifndef QT_NO_IMAGE_TEXT +# define QT_NO_IMAGE_TEXT +#endif +#ifndef QT_NO_MOVIE +# define QT_NO_MOVIE +#endif + +/* Internationalization */ +#ifndef QT_NO_BIG_CODECS +# define QT_NO_BIG_CODECS +#endif +#ifndef QT_NO_QWS_INPUTMETHODS +# define QT_NO_QWS_INPUTMETHODS +#endif +#ifndef QT_NO_TEXTCODEC +# define QT_NO_TEXTCODEC +#endif +#ifndef QT_NO_CODECS +# define QT_NO_CODECS +#endif +#ifndef QT_NO_TEXTCODECPLUGIN +# define QT_NO_TEXTCODECPLUGIN +#endif +#ifndef QT_NO_TRANSLATION +# define QT_NO_TRANSLATION +#endif +#ifndef QT_NO_TRANSLATION_UTF8 +# define QT_NO_TRANSLATION_UTF8 +#endif + +/* ItemViews */ + +#ifndef QT_NO_DIRMODEL +# define QT_NO_DIRMODEL +#endif + +/* Kernel */ +#ifndef QT_NO_CLIPBOARD +# define QT_NO_CLIPBOARD +#endif +#ifndef QT_NO_CSSPARSER +# define QT_NO_CSSPARSER +#endif +#ifndef QT_NO_CURSOR +# define QT_NO_CURSOR +#endif +#ifndef QT_NO_DRAGANDDROP +# define QT_NO_DRAGANDDROP +#endif +#ifndef QT_NO_EFFECTS +# define QT_NO_EFFECTS +#endif +#ifndef QT_NO_SESSIONMANAGER +# define QT_NO_SESSIONMANAGER +#endif +#ifndef QT_NO_SHAREDMEMORY +# define QT_NO_SHAREDMEMORY +#endif +#ifndef QT_NO_SOUND +# define QT_NO_SOUND +#endif +#ifndef QT_NO_SYSTEMLOCALE +# define QT_NO_SYSTEMSEMAPHORE +#endif +#ifndef QT_NO_SYSTEMSEMAPHORE +# define QT_NO_SYSTEMSEMAPHORE +#endif +#ifndef QT_NO_TABLETEVENT +# define QT_NO_TABLETEVENT +#endif +#ifndef QT_NO_CRASHHANDLER +# define QT_NO_CRASHHANDLER +#endif +#ifndef QT_NO_CONCURRENT +# define QT_NO_CONCURRENT +#endif +#ifndef QT_NO_XMLSTREAM +# define QT_NO_XMLSTREAM +#endif +#ifndef QT_NO_XMLSTREAMREADER +# define QT_NO_XMLSTREAMREADER +#endif +#ifndef QT_NO_XMLSTREAMWRITER +# define QT_NO_XMLSTREAMWRITER +#endif + +/* Networking */ +#ifndef QT_NO_COP +# define QT_NO_COP +#endif +#ifndef QT_NO_HOSTINFO +# define QT_NO_HOSTINFO +#endif +#ifndef QT_NO_HTTP +# define QT_NO_HTTP +#endif +#ifndef QT_NO_NETWORKPROXY +# define QT_NO_NETWORKPROXY +#endif +#ifndef QT_NO_SOCKS5 +# define QT_NO_SOCKS5 +#endif +#ifndef QT_NO_UDPSOCKET +# define QT_NO_UDPSOCKET +#endif +#ifndef QT_NO_URLINFO +# define QT_NO_URLINFO +#endif +#ifndef QT_NO_FTP +# define QT_NO_FTP +#endif + +/* Painting */ +#ifndef QT_NO_COLORNAMES +# define QT_NO_COLORNAMES +#endif +#ifndef QT_NO_DIRECTPAINTER +# define QT_NO_DIRECTPAINTER +#endif +#ifndef QT_NO_PAINTONSCREEN +# define QT_NO_PAINTONSCREEN +#endif +#ifndef QT_NO_PAINT_DEBUG +# define QT_NO_PAINT_DEBUG +#endif +#ifndef QT_NO_PICTURE +# define QT_NO_PICTURE +#endif +#ifndef QT_NO_PRINTER +# define QT_NO_PRINTER +#endif +#ifndef QT_NO_CUPS +# define QT_NO_CUPS +#endif + +/* Qt for Embedded Linux */ +#ifndef QT_NO_QWSEMBEDWIDGET +# define QT_NO_QWSEMBEDWIDGET +#endif +#ifndef QT_NO_QWS_ALPHA_CURSOR +# define QT_NO_QWS_ALPHA_CURSOR +#endif +#ifndef QT_NO_QWS_CURSOR +# define QT_NO_QWS_CURSOR +#endif +#ifndef QT_NO_QWS_DECORATION_DEFAULT +# define QT_NO_QWS_DECORATION_DEFAULT +#endif +#ifndef QT_NO_QWS_DECORATION_STYLED +# define QT_NO_QWS_DECORATION_STYLED +#endif +#ifndef QT_NO_QWS_DECORATION_WINDOWS +# define QT_NO_QWS_DECORATION_WINDOWS +#endif +#ifndef QT_NO_QWS_MANAGER +# define QT_NO_QWS_MANAGER +#endif +#ifndef QT_NO_QWS_KEYBOARD +# define QT_NO_QWS_KEYBOARD +#endif +#ifndef QT_NO_QWS_MOUSE +# define QT_NO_QWS_MOUSE +#endif +#ifndef QT_NO_QWS_MOUSE_AUTO +# define QT_NO_QWS_MOUSE_AUTO +#endif +#ifndef QT_NO_QWS_MOUSE_MANUAL +# define QT_NO_QWS_MOUSE_MANUAL +#endif +#ifndef QT_NO_QWS_MULTIPROCESS +# define QT_NO_QWS_MULTIPROCESS +#endif +#ifndef QT_NO_QWS_SOUNDSERVER +# define QT_NO_QWS_SOUNDSERVER +#endif +#ifndef QT_NO_SXE +# define QT_NO_SXE +#endif +#ifndef QT_NO_QWS_PROPERTIES +# define QT_NO_QWS_PROPERTIES +#endif +#ifndef QT_NO_QWS_PROXYSCREEN +# define QT_NO_QWS_PROXYSCREEN +#endif +#ifndef QT_NO_QWS_DYNAMICSCREENTRANSFORMATION +# define QT_NO_QWS_DYNAMICSCREENTRANSFORMATION +#endif +#ifndef QT_NO_QWS_LINUXFB +# define QT_NO_QWS_LINUXFB +#endif +#ifndef QT_NO_QWS_MOUSE_PC +# define QT_NO_QWS_MOUSE_PC +#endif +#ifndef QT_NO_QWS_MOUSE_LINUXTP +# define QT_NO_QWS_MOUSE_LINUXTP +#endif +#ifndef QT_NO_QWS_QPF +# define QT_NO_QWS_QPF +#endif + +/* SVG */ +#ifndef QT_NO_SVG +# define QT_NO_SVG +#endif +#ifndef QT_NO_GRAPHICSSVGITEM +# define QT_NO_GRAPHICSSVGITEM +#endif +#ifndef QT_NO_SVGGENERATOR +# define QT_NO_SVGGENERATOR +#endif +#ifndef QT_NO_SVGRENDERER +# define QT_NO_SVGRENDERER +#endif +#ifndef QT_NO_SVGWIDGET +# define QT_NO_SVGWIDGET +#endif + +/* Styles */ +#ifndef QT_NO_STYLE_MOTIF +# define QT_NO_STYLE_MOTIF +#endif +#ifndef QT_NO_STYLE_CDE +# define QT_NO_STYLE_CDE +#endif +#ifndef QT_NO_STYLE_STYLESHEET +# define QT_NO_STYLE_STYLESHEET +#endif +#ifndef QT_NO_STYLE_WINDOWSCE +# define QT_NO_STYLE_WINDOWSCE +#endif +#ifndef QT_NO_STYLE_WINDOWSMOBILE +# define QT_NO_STYLE_WINDOWSMOBILE +#endif +#ifndef QT_NO_STYLE_WINDOWSVISTA +# define QT_NO_STYLE_WINDOWSVISTA +#endif +#ifndef QT_NO_STYLE_WINDOWSXP +# define QT_NO_STYLE_WINDOWSXP +#endif + +/* Utilities */ +#ifndef QT_NO_ACCESSIBILITY +# define QT_NO_ACCESSIBILITY +#endif +#ifndef QT_NO_COMPLETER +# define QT_NO_COMPLETER +#endif +#ifndef QT_NO_DESKTOPSERVICES +# define QT_NO_DESKTOPSERVICES +#endif +#ifndef QT_NO_SCRIPT +# define QT_NO_SCRIPT +#endif +#ifndef QT_NO_SYSTEMTRAYICON +# define QT_NO_SYSTEMTRAYICON +#endif + +/* Windows */ +#ifndef QT_NO_WIN_ACTIVEQT +# define QT_NO_WIN_ACTIVEQT +#endif diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index ca3219f..45153b8 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -216,6 +216,8 @@ namespace QT_NAMESPACE {} # define Q_OS_ULTRIX #elif defined(sinix) # define Q_OS_RELIANT +#elif defined(__native_client__) +# define Q_OS_NACL #elif defined(__linux__) || defined(__linux) # define Q_OS_LINUX #elif defined(__FreeBSD__) || defined(__DragonFly__) @@ -2661,6 +2663,10 @@ QT_LICENSED_MODULE(DBus) # define QT_NO_PROCESS #endif +#ifdef Q_OS_NACL +#include +#endif + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/global/qnaclunimplemented.cpp b/src/corelib/global/qnaclunimplemented.cpp new file mode 100644 index 0000000..618ff3e --- /dev/null +++ b/src/corelib/global/qnaclunimplemented.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** + ** + ** 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 QtCore 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 "qnaclunimplemented.h" +#include +#include + +/* + The purpose of this file is to stub out certain functions + that are not provided by the Native Client SDK. This is + done as an alterative to sprinkling the Qt sources with + NACL ifdefs. + + There are two main classes of functions: + + - Fuctions that are called but can have no effect: + For these we simply give an empty implementation + + - Functions that are referenced in the source code, but + is not/must not be called at run-time: + These we either leave undefined or implement with a + qFatal. + + This is a work in progress. +*/ + +extern "C" { + +void pthread_cleanup_push(void (*)(void *), void *) +{ + +} + +void pthread_cleanup_pop(int) +{ + +} + +int pthread_setcancelstate(int, int *) +{ + return 0; +} + +int pthread_setcanceltype(int, int *) +{ + return 0; +} + +void pthread_testcancel(void) +{ + +} + + +int pthread_cancel(pthread_t) +{ + return 0; +} + +int pthread_attr_setinheritsched(pthread_attr_t *,int) +{ + return 0; +} + + +int pthread_attr_getinheritsched(const pthread_attr_t *, int *) +{ + return 0; +} + +// event dispatcher, select +//struct fd_set; +//struct timeval; + +int fcntl(int, int, ...) +{ + return 0; +} + +int sigaction(int, const struct sigaction *, struct sigaction *) +{ + return 0; +} + +int open(const char *, int, ...) +{ + return 0; +} + +int open64(const char *, int, ...) +{ + return 0; +} + +int access(const char *, int) +{ + return 0; +} + +typedef long off64_t; +off64_t ftello64(void *) +{ + qFatal("ftello64 called"); + return 0; +} + +off64_t lseek64(int, off_t, int) +{ + qFatal("lseek64 called"); + return 0; +} + +} // Extern C + +int select(int, fd_set *, fd_set *, fd_set *, struct timeval *) +{ + return 0; +} diff --git a/src/corelib/global/qnaclunimplemented.h b/src/corelib/global/qnaclunimplemented.h new file mode 100644 index 0000000..84085b5 --- /dev/null +++ b/src/corelib/global/qnaclunimplemented.h @@ -0,0 +1,85 @@ +/**************************************************************************** + ** + ** 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 QtCore 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 QNACLUNIMPLEMENTED_H +#define QNACLUNIMPLEMENTED_H + +#ifdef Q_OS_NACL + +// pthread +#include +#define PTHREAD_CANCEL_DISABLE 1 +#define PTHREAD_CANCEL_ENABLE 2 +#define PTHREAD_INHERIT_SCHED 3 + +extern "C" { + +void pthread_cleanup_push(void (*handler)(void *), void *arg); +void pthread_cleanup_pop(int execute); + +int pthread_setcancelstate(int state, int *oldstate); +int pthread_setcanceltype(int type, int *oldtype); +void pthread_testcancel(void); +int pthread_cancel(pthread_t thread); + +int pthread_attr_setinheritsched(pthread_attr_t *attr, + int inheritsched); +int pthread_attr_getinheritsched(const pthread_attr_t *attr, + int *inheritsched); + +// event dispatcher, select +//struct fd_set; +//struct timeval; +int fcntl(int fildes, int cmd, ...); +int sigaction(int sig, const struct sigaction * act, struct sigaction * oact); + +typedef long off64_t; +off64_t ftello64(void *stream); +off64_t lseek64(int fildes, off_t offset, int whence); +int open64(const char *path, int oflag, ...); + +} + +int select(int nfds, fd_set * readfds, fd_set * writefds, fd_set * errorfds, struct timeval * timeout); + +#endif //Q_OS_NACL + +#endif //QNACLUNIMPLEMENTED_H diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index ef448b1..7c14886 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -69,7 +69,7 @@ win32 { SOURCES += io/qfsfileengine_iterator_unix.cpp symbian:SOURCES += io/qprocess_symbian.cpp else:SOURCES += io/qprocess_unix.cpp - macx-*: { + !nacl:macx-*: { HEADERS += io/qfilesystemwatcher_fsevents_p.h SOURCES += io/qsettings_mac.cpp io/qfilesystemwatcher_fsevents.cpp } @@ -84,9 +84,11 @@ win32 { io/qfilesystemwatcher_dnotify_p.h } - freebsd-*|macx-*|darwin-*|openbsd-*:{ - SOURCES += io/qfilesystemwatcher_kqueue.cpp - HEADERS += io/qfilesystemwatcher_kqueue_p.h + !nacl { + freebsd-*|macx-*|darwin-*|openbsd-*:{ + SOURCES += io/qfilesystemwatcher_kqueue.cpp + HEADERS += io/qfilesystemwatcher_kqueue_p.h + } } symbian { diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 8e76e9e..783fbb0 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -928,7 +928,7 @@ public: } }; -#if defined(Q_OS_UNIX) +#if defined(Q_OS_UNIX) && ! defined (Q_OS_NACL) #define QT_USE_MMAP #endif diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index 1851e04..6f53a3f 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -78,12 +78,12 @@ wince*: { kernel/qfunctions_wince.h } -mac:!embedded { +mac:!embedded:!embedded_lite { SOURCES += \ kernel/qcoreapplication_mac.cpp } -mac { +mac:!nacl { SOURCES += \ kernel/qcore_mac.cpp } diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index e0d92c0..685576b 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -42,7 +42,8 @@ #include "qcore_unix_p.h" #include "qelapsedtimer.h" -#ifndef Q_OS_VXWORKS +#ifdef Q_OS_NACL +#elif !defined (Q_OS_VXWORKS) # if !defined(Q_OS_HPUX) || defined(__ia64) # include # endif diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index f7d45ac..0c336e7 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -112,7 +112,9 @@ QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate() bool pipefail = false; // initialize the common parts of the event loop -#if defined(Q_OS_INTEGRITY) +#if defined(Q_OS_NACL) + // do nothing. +#elif defined(Q_OS_INTEGRITY) // INTEGRITY doesn't like a "select" on pipes, so use socketpair instead if (socketpair(AF_INET, SOCK_STREAM, PF_INET, thread_pipe) == -1) { perror("QEventDispatcherUNIXPrivate(): Unable to create socket pair"); @@ -157,7 +159,9 @@ QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate() QEventDispatcherUNIXPrivate::~QEventDispatcherUNIXPrivate() { -#if defined(Q_OS_VXWORKS) +#if defined(Q_OS_NACL) + // do nothing. +#elif defined(Q_OS_VXWORKS) close(thread_pipe[0]); char name[20]; @@ -312,7 +316,7 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags, QTimerInfoList::QTimerInfoList() { -#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) +#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) && !defined(Q_OS_NACL) if (!QElapsedTimer::isMonotonic()) { // not using monotonic timers, initialize the timeChanged() machinery previousTime = qt_gettime(); @@ -364,6 +368,10 @@ timeval qAbs(const timeval &t) */ bool QTimerInfoList::timeChanged(timeval *delta) { +#ifdef Q_OS_NACL + Q_UNUSED(delta) + return false; // Calling "times" crashes. +#endif struct tms unused; clock_t currentTicks = times(&unused); diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index cbe58de..d38acf3 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -64,7 +64,7 @@ # include #else # include -# if !defined(Q_OS_HPUX) || defined(__ia64) +# if (!defined(Q_OS_HPUX) || defined(__ia64)) && !defined(Q_OS_NACL) # include # endif #endif diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 6b34b5f..47a13d7 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -457,6 +457,7 @@ void QThread::usleep(unsigned long usecs) // Does some magic and calculate the Unix scheduler priorities // sched_policy is IN/OUT: it must be set to a valid policy before calling this function // sched_priority is OUT only +#if defined(Q_OS_DARWIN) || !defined(Q_OS_OPENBSD) && !defined(Q_OS_SYMBIAN) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING-0 >= 0) static bool calculateUnixPriority(int priority, int *sched_policy, int *sched_priority) { #ifdef SCHED_IDLE @@ -484,6 +485,7 @@ static bool calculateUnixPriority(int priority, int *sched_policy, int *sched_pr *sched_priority = prio; return true; } +#endif void QThread::start(Priority priority) { diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 4e0ebbc..f540f14 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -83,7 +83,7 @@ SOURCES += \ symbian:SOURCES+=tools/qlocale_symbian.cpp -mac:SOURCES += tools/qelapsedtimer_mac.cpp +!nacl:mac:SOURCES += tools/qelapsedtimer_mac.cpp else:symbian:SOURCES += tools/qelapsedtimer_symbian.cpp else:unix:SOURCES += tools/qelapsedtimer_unix.cpp else:win32:SOURCES += tools/qelapsedtimer_win.cpp diff --git a/src/gui/kernel/mac.pri b/src/gui/kernel/mac.pri index 1538510..eb47ce9 100644 --- a/src/gui/kernel/mac.pri +++ b/src/gui/kernel/mac.pri @@ -1,4 +1,4 @@ -!x11:!embedded:mac { +!x11:!embedded:!nacl:mac { LIBS_PRIVATE += -framework Carbon -lz *-mwerks:INCLUDEPATH += compat } diff --git a/src/gui/kernel/qplatformintegrationfactory_lite.cpp b/src/gui/kernel/qplatformintegrationfactory_lite.cpp index 9a00dea..cd7d171 100644 --- a/src/gui/kernel/qplatformintegrationfactory_lite.cpp +++ b/src/gui/kernel/qplatformintegrationfactory_lite.cpp @@ -60,8 +60,8 @@ QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key) QStringList paramList = key.split(QLatin1Char(':')); QString platform = paramList.takeFirst().toLower(); - qDebug() << loader()->keys(); #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + qDebug() << loader()->keys(); if (QPlatformIntegrationFactoryInterface *factory = qobject_cast(loader()->instance(platform))) ret = factory->create(platform, paramList); #endif diff --git a/src/gui/text/qfontdatabase_qws.cpp b/src/gui/text/qfontdatabase_qws.cpp index 4dd5019..09fb07c 100644 --- a/src/gui/text/qfontdatabase_qws.cpp +++ b/src/gui/text/qfontdatabase_qws.cpp @@ -388,12 +388,14 @@ static void initializeDb() } #endif +#ifndef QT_NO_QWS_QPF2 QDir dir(fontpath, QLatin1String("*.qpf2")); for (int i = 0; i < int(dir.count()); ++i) { const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i])); //qDebug() << "looking at" << file; db->addQPF2File(file); } +#endif #endif //QT_FONTS_ARE_RESOURCES diff --git a/src/src.pro b/src/src.pro index 9c4831c..d15e973 100644 --- a/src/src.pro +++ b/src/src.pro @@ -5,6 +5,8 @@ unset(SRC_SUBDIRS) win32:SRC_SUBDIRS += src_winmain symbian:SRC_SUBDIRS += src_s60main SRC_SUBDIRS += src_corelib src_xml src_network src_sql src_testlib +nacl: SRC_SUBDIRS -= src_network src_testlib +win32:SRC_SUBDIRS += src_activeqt !symbian:contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus !contains(QT_CONFIG, no-gui): SRC_SUBDIRS += src_gui !wince*:!symbian:!vxworks:contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_qt3support -- cgit v0.12 From 03db204f7c2b0c33c7235080362c7838980d0d8e Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 14 May 2010 12:42:45 +0200 Subject: make handle{Keyboard|Mouse|Wheel}Event thread-safe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed by: Jørgen --- src/gui/kernel/qeventdispatcher_glib_lite.cpp | 2 ++ src/gui/kernel/qeventdispatcher_lite.cpp | 2 ++ src/gui/kernel/qwindowsysteminterface.cpp | 12 ++++++++++++ src/gui/kernel/qwindowsysteminterface.h | 8 +++++--- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qeventdispatcher_glib_lite.cpp b/src/gui/kernel/qeventdispatcher_glib_lite.cpp index 0cfea8a..744925c 100644 --- a/src/gui/kernel/qeventdispatcher_glib_lite.cpp +++ b/src/gui/kernel/qeventdispatcher_glib_lite.cpp @@ -79,6 +79,8 @@ static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer) QWindowSystemInterface::UserEvent * event; while (QWindowSystemInterfacePrivate::userEventsQueued()) { event = QWindowSystemInterfacePrivate::getUserEvent(); + if (!event) + break; // send through event filter if (source->q->filterEvent(event)) { diff --git a/src/gui/kernel/qeventdispatcher_lite.cpp b/src/gui/kernel/qeventdispatcher_lite.cpp index d500ad6..5b99a2f 100644 --- a/src/gui/kernel/qeventdispatcher_lite.cpp +++ b/src/gui/kernel/qeventdispatcher_lite.cpp @@ -89,6 +89,8 @@ bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags) && QWindowSystemInterfacePrivate::userEventsQueued() > 0) { // process a pending user input event event = QWindowSystemInterfacePrivate::getUserEvent(); + if (!event) + break; } else { break; } diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index d7b5eef..05ca3d3 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -52,6 +52,7 @@ QTime QWindowSystemInterface::eventTime; // QList QWindowSystemInterfacePrivate::userEventQueue; +QMutex QWindowSystemInterfacePrivate::queueMutex; extern QPointer qt_last_mouse_receiver; /*! @@ -109,4 +110,15 @@ void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, con QWindowSystemInterfacePrivate::queueUserEvent(e); } +QWindowSystemInterface::UserEvent * QWindowSystemInterfacePrivate::getUserEvent() +{ + queueMutex.lock(); + QWindowSystemInterface::UserEvent *ret; + if (userEventQueue.isEmpty()) + ret = 0; + else + ret = userEventQueue.takeFirst(); + queueMutex.unlock(); + return ret; +} QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 70b2830..d9bfc70 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -46,6 +46,7 @@ #include #include #include +#include QT_BEGIN_HEADER @@ -128,10 +129,11 @@ private: class QWindowSystemInterfacePrivate { public: static QList userEventQueue; + static QMutex queueMutex; - static int userEventsQueued() { return userEventQueue.count(); } - static QWindowSystemInterface::UserEvent * getUserEvent() { return userEventQueue.takeFirst(); } - static void queueUserEvent(QWindowSystemInterface::UserEvent *ev) { userEventQueue.append(ev); } + static int userEventsQueued() { queueMutex.lock(); int ret = userEventQueue.count(); queueMutex.unlock(); return ret; } + static QWindowSystemInterface::UserEvent * getUserEvent(); + static void queueUserEvent(QWindowSystemInterface::UserEvent *ev) { queueMutex.lock(); userEventQueue.append(ev); queueMutex.unlock(); } }; QT_END_NAMESPACE -- cgit v0.12 From 3cd3206cdaf4b1cf0ccf50b2d0a7d67a68be582e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 14 May 2010 13:18:23 +0200 Subject: Hardcode qDetectCPUFeatures to 0 for NaCl. The assembler fails verification, disable for now. --- src/corelib/tools/qsimd.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index 1ef513c..11357b3 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -54,7 +54,12 @@ uint qDetectCPUFeatures() if (features != 0xffffffff) return features; -#if defined (Q_OS_WINCE) +#if defined (Q_OS_NACL) + // The qDetectCPUFeatures assembler fails verification in the + // Native Client sandbox due to use of pushf/popf. + features = 0; + return features; +#elif defined (Q_OS_WINCE) #if defined (ARM) if (IsProcessorFeaturePresent(PF_ARM_INTEL_WMMX)) { features = IWMMXT; -- cgit v0.12 From 8ace0f0b97a4b321037e034b35b6342cf0e779cf Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 19 May 2010 11:15:21 +0200 Subject: fix event dispatcher sleep problem on Android --- src/gui/kernel/qapplication_p.h | 3 +++ src/gui/kernel/qwindowsysteminterface.cpp | 12 ++++++++++++ src/gui/kernel/qwindowsysteminterface.h | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 7202ae5..7ad8ca5 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -322,6 +322,9 @@ public: #if defined(Q_WS_LITE) static QPlatformIntegration *platformIntegration() { return platform_integration; } + + static QAbstractEventDispatcher *qt_lite_core_dispatcher() + { return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; } #endif void createEventDispatcher(); diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 05ca3d3..22b45ac 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qwindowsysteminterface.h" #include "qapplication_p.h" +#include QT_BEGIN_NAMESPACE @@ -121,4 +122,15 @@ QWindowSystemInterface::UserEvent * QWindowSystemInterfacePrivate::getUserEvent( queueMutex.unlock(); return ret; } + +void QWindowSystemInterfacePrivate::queueUserEvent(QWindowSystemInterface::UserEvent *ev) +{ + queueMutex.lock(); + userEventQueue.append(ev); + queueMutex.unlock(); + + QAbstractEventDispatcher *dispatcher = QApplicationPrivate::qt_lite_core_dispatcher(); + if (dispatcher) + dispatcher->wakeUp(); +} QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index d9bfc70..e0c46d1 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -133,7 +133,7 @@ public: static int userEventsQueued() { queueMutex.lock(); int ret = userEventQueue.count(); queueMutex.unlock(); return ret; } static QWindowSystemInterface::UserEvent * getUserEvent(); - static void queueUserEvent(QWindowSystemInterface::UserEvent *ev) { queueMutex.lock(); userEventQueue.append(ev); queueMutex.unlock(); } + static void queueUserEvent(QWindowSystemInterface::UserEvent *ev); }; QT_END_NAMESPACE -- cgit v0.12 From 4fa3766090972de9faf9c25d9cba6d5ab467abeb Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 26 May 2010 15:46:01 +0200 Subject: touch interface for lighthouse plugins --- src/gui/kernel/qapplication_lite.cpp | 31 +++++++++++++++++++++++++++++++ src/gui/kernel/qapplication_p.h | 1 + src/gui/kernel/qwindowsysteminterface.cpp | 9 +++++++++ src/gui/kernel/qwindowsysteminterface.h | 23 +++++++++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 5fc56a8..491dd02 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -102,6 +102,11 @@ void QApplicationPrivate::processUserEvent(QWindowSystemInterface::UserEvent *e) case QEvent::KeyRelease: QApplicationPrivate::processKeyEvent(static_cast(e)); break; + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: + QApplicationPrivate::processTouchEvent(static_cast(e)); + break; default: qWarning() << "Unknown user input event type:" << e->type; break; @@ -797,4 +802,30 @@ void QApplicationPrivate::processCloseEvent(QWidget *tlw) tlw->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent); } +void QApplicationPrivate::processTouchEvent(QWindowSystemInterface::TouchEvent *e) +{ + QList touchPoints; + Qt::TouchPointStates states; + + int primaryPoint = -1; + foreach(struct QWindowSystemInterface::TouchPoint point, e->points) { + QTouchEvent::TouchPoint p; + p.setId(point.id); + p.setPressure(point.pressure); + states |= point.state; + if (point.isPrimary) { + point.state |= Qt::TouchPointPrimary; + primaryPoint = point.id; + } + p.setState(point.state); + p.setRect(point.area); + p.setScreenPos(point.area.center()); + p.setNormalizedPos(point.normalPosition); + + touchPoints.append(p); + } + + translateRawTouchEvent(e->widget.data(), e->devType, touchPoints); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 7ad8ca5..f06826d 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -489,6 +489,7 @@ public: static void processMouseEvent(QWindowSystemInterface::MouseEvent *e); static void processKeyEvent(QWindowSystemInterface::KeyEvent *e); static void processWheelEvent(QWindowSystemInterface::WheelEvent *e); + static void processTouchEvent(QWindowSystemInterface::TouchEvent *e); static void processCloseEvent(QWidget *tlw); static void processGeometryChange(QWidget *tlw, const QRect &newRect); diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 22b45ac..102d1a3 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -133,4 +133,13 @@ void QWindowSystemInterfacePrivate::queueUserEvent(QWindowSystemInterface::UserE if (dispatcher) dispatcher->wakeUp(); } + +void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, QList points) +{ + if (!points.size()) // Touch events must have at least one point + return; + TouchEvent *e = new TouchEvent(tlw, timestamp, type, devType, points); + QWindowSystemInterfacePrivate::queueUserEvent(e); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index e0c46d1..ca73305 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -75,6 +75,21 @@ public: static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o); + struct TouchPoint { + int id; // for application use + bool isPrimary; // for application use + QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1) + QRectF area; // the touched area, centered at position in screen coordinates + qreal pressure; // 0 to 1 + Qt::TouchPointStates state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released} + }; + + static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, QList points) { + handleTouchEvent(w, eventTime.elapsed(), type, devType, points); + } + + static void handleTouchEvent(QWidget *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, QList points); + // delivered directly by the plugin via spontaneous events static void handleGeometryChange(QWidget *w, const QRect &newRect); static void handleCloseEvent(QWidget *w); @@ -121,6 +136,14 @@ public: Qt::KeyboardModifiers modifiers; }; + class TouchEvent : public UserEvent { + public: + TouchEvent(QWidget *w, ulong time, QEvent::Type t, QTouchEvent::DeviceType d, QList p) + :UserEvent(w, time, t) { devType = d; points = p; } + QTouchEvent::DeviceType devType; + QList points; + }; + private: static QTime eventTime; -- cgit v0.12 From e998a905f6cf67a193aebc950776e84c8db13b6b Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 27 May 2010 17:34:25 +0200 Subject: include QTouchEvent header --- src/gui/kernel/qwindowsysteminterface.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index ca73305..efb515f 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -47,6 +47,7 @@ #include #include #include +#include QT_BEGIN_HEADER -- cgit v0.12 From 28580117adf5149e7ca15a43a398b412f4ec0ab4 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 31 May 2010 15:27:41 +0200 Subject: APIs for lighthouse plugins to declare screen changes These APIs provide a method for lighthouse plugins to intiate delivery of the QDesktopWidget signals: resized, screenCountChanged, and workAreaResized. The handleScreenGeometryChange and handleScreenAvailableGeometryChange functions also resize fullscreen and maximized toplevel widgets. --- src/gui/kernel/qapplication_lite.cpp | 44 +++++++++++++++++++++++++++++++ src/gui/kernel/qapplication_p.h | 4 +++ src/gui/kernel/qwindowsysteminterface.cpp | 15 +++++++++++ src/gui/kernel/qwindowsysteminterface.h | 4 +++ 4 files changed, 67 insertions(+) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 491dd02..6008a9f 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -828,4 +828,48 @@ void QApplicationPrivate::processTouchEvent(QWindowSystemInterface::TouchEvent * translateRawTouchEvent(e->widget.data(), e->devType, touchPoints); } +void QApplicationPrivate::reportScreenCount(int count) +{ + // signal anything listening for creation or deletion of screens + QDesktopWidget *desktop = QApplication::desktop(); + if (desktop) + emit desktop->screenCountChanged(count); +} + +void QApplicationPrivate::reportGeometryChange(int screenIndex) +{ + // signal anything listening for screen geometry changes + QDesktopWidget *desktop = QApplication::desktop(); + if (desktop) + emit desktop->resized(screenIndex); + + // make sure maximized and fullscreen windows are updated + QWidgetList list = QApplication::topLevelWidgets(); + for (int i = list.size() - 1; i >= 0; --i) { + QWidget *w = list.at(i); + if (w->isFullScreen()) + w->d_func()->setFullScreenSize_helper(); + else if (w->isMaximized()) + w->d_func()->setMaxWindowState_helper(); + } +} + +void QApplicationPrivate::reportAvailableGeometryChange(int screenIndex) +{ + // signal anything listening for screen geometry changes + QDesktopWidget *desktop = QApplication::desktop(); + if (desktop) + emit desktop->workAreaResized(screenIndex); + + // make sure maximized and fullscreen windows are updated + QWidgetList list = QApplication::topLevelWidgets(); + for (int i = list.size() - 1; i >= 0; --i) { + QWidget *w = list.at(i); + if (w->isFullScreen()) + w->d_func()->setFullScreenSize_helper(); + else if (w->isMaximized()) + w->d_func()->setMaxWindowState_helper(); + } +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index f06826d..e272a36 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -496,6 +496,10 @@ public: static void processUserEvent(QWindowSystemInterface::UserEvent *e); + static void reportScreenCount(int count); + static void reportGeometryChange(int screenIndex); + static void reportAvailableGeometryChange(int screenIndex); + #endif #ifdef Q_WS_QWS diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 102d1a3..cd466e3 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -142,4 +142,19 @@ void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEv QWindowSystemInterfacePrivate::queueUserEvent(e); } +void QWindowSystemInterface::handleScreenGeometryChange(int screenIndex) +{ + QApplicationPrivate::reportGeometryChange(screenIndex); +} + +void QWindowSystemInterface::handleScreenAvailableGeometryChange(int screenIndex) +{ + QApplicationPrivate::reportAvailableGeometryChange(screenIndex); +} + +void QWindowSystemInterface::handleScreenCountChange(int count) +{ + QApplicationPrivate::reportScreenCount(count); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index efb515f..8c69218 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -97,6 +97,10 @@ public: static void handleEnterEvent(QWidget *w); static void handleLeaveEvent(QWidget *w); + // Changes to the screen + static void handleScreenGeometryChange(int screenIndex); + static void handleScreenAvailableGeometryChange(int screenIndex); + static void handleScreenCountChange(int count); class UserEvent { public: -- cgit v0.12 From f3a920be362b85d248a9b76c1b15a0b096d7c90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 14 May 2010 14:07:51 +0200 Subject: gl on openkode. QGLWidget only works for toplevel widgets and QGLWindowSurface is used for anything else --- src/gui/egl/egl.pri | 18 +- src/gui/kernel/qwidget_lite.cpp | 4 +- src/opengl/opengl.pro | 10 +- src/opengl/qgl_lite.cpp | 104 --------- src/plugins/platforms/openkode/main.cpp | 5 +- src/plugins/platforms/openkode/openkode.pro | 23 +- .../platforms/openkode/qopenkodeglintegration.cpp | 259 +++++++++++++++++++++ .../platforms/openkode/qopenkodeglintegration.h | 81 +++++++ .../platforms/openkode/qopenkodeintegration.cpp | 23 +- .../platforms/openkode/qopenkodeintegration.h | 4 + src/plugins/platforms/openkode/qopenkodewindow.cpp | 41 ++-- src/plugins/platforms/openkode/qopenkodewindow.h | 1 + .../platforms/openkode/qopenkodewindowsurface.cpp | 10 +- 13 files changed, 444 insertions(+), 139 deletions(-) create mode 100644 src/plugins/platforms/openkode/qopenkodeglintegration.cpp create mode 100644 src/plugins/platforms/openkode/qopenkodeglintegration.h diff --git a/src/gui/egl/egl.pri b/src/gui/egl/egl.pri index 595d135..253c091 100644 --- a/src/gui/egl/egl.pri +++ b/src/gui/egl/egl.pri @@ -6,9 +6,21 @@ contains(QT_CONFIG, egl): { egl/qeglcontext_p.h \ egl/qeglproperties_p.h - SOURCES += \ - egl/qegl.cpp \ - egl/qeglproperties.cpp + SOURCES += \ + egl/qegl.cpp \ + egl/qeglproperties.cpp + unix { + !isEmpty(QMAKE_INCDIR_EGL){ + INCLUDEPATH += $$QMAKE_INCDIR_EGL + } + !isEmpty(QMAKE_LIBDIR_EGL){ + for(p, QMAKE_LIBDIR_EGL) { + exists($$p):LIBS += -L$$p + } + } + + !isEmpty(QMAKE_LIBS_EGL): LIBS += $$QMAKE_LIBS_EGL + } wince*: SOURCES += egl/qegl_wince.cpp diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index eae83f9..d281bec 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -76,10 +76,10 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO } Q_ASSERT(platformWindow); - if (!surface) { + // QGLWidget does not need/work with a windowsurface + if (!surface && !q->inherits("QGLWidget")) { surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId()); } - Q_ASSERT(surface); data.window_flags = q->platformWindow()->setWindowFlags(data.window_flags); diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 6eb4ebe..53f9d3e 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -77,16 +77,12 @@ SOURCES += qgl.cpp \ } embedded_lite { + DEFINES += QT_NO_EGL + SOURCES += qgl_lite.cpp HEADERS += qglplatformintegration_lite.h - # If we have EGL, use the EGL implementation of QGLPixelBuffer, otherwise we just provide - # a stubbed out one. PBuffers aren't too interesting anyway. - contains(QT_CONFIG, egl) { - SOURCES += qglpixelbuffer_egl.cpp - } else { - SOURCES += qglpixelbuffer_stub.cpp - } + SOURCES += qglpixelbuffer_stub.cpp } x11 { diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp index 426683b..636c711 100644 --- a/src/opengl/qgl_lite.cpp +++ b/src/opengl/qgl_lite.cpp @@ -49,110 +49,6 @@ #include "qgl_p.h" #include "qglplatformintegration_lite.h" -#ifndef QT_NO_EGL -#include "qgl_egl_p.h" - -void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLFormat& glFormat) -{ - int redSize = glFormat.redBufferSize(); - int greenSize = glFormat.greenBufferSize(); - int blueSize = glFormat.blueBufferSize(); - int alphaSize = glFormat.alphaBufferSize(); - int depthSize = glFormat.depthBufferSize(); - int stencilSize = glFormat.stencilBufferSize(); - int sampleCount = glFormat.samples(); - - // QGLFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that - // type has been requested. So we must check QGLFormat's booleans too if size is -1: - if (glFormat.alpha() && alphaSize <= 0) - alphaSize = 1; - if (glFormat.depth() && depthSize <= 0) - depthSize = 1; - if (glFormat.stencil() && stencilSize <= 0) - stencilSize = 1; - if (glFormat.sampleBuffers() && sampleCount <= 0) - sampleCount = 1; - - // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide - // the best performance. The EGL config selection algorithm is a bit stange in this regard: - // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard - // 32-bit configs completely from the selection. So it then comes to the sorting algorithm. - // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort - // order is special and described as "by larger _total_ number of color bits.". So EGL will - // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on - // to say "If the requested number of bits in attrib_list for a particular component is 0, - // then the number of bits for that component is not considered". This part of the spec also - // seems to imply that setting the red/green/blue bits to zero means none of the components - // are considered and EGL disregards the entire sorting rule. It then looks to the next - // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being - // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are - // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit, - // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that - // if the application sets the red/green/blue size to 5/6/5 on the QGLFormat, they will - // probably get a 32-bit config, even when there's an RGB565 config avaliable. Oh well. - - // Now normalize the values so -1 becomes 0 - redSize = redSize > 0 ? redSize : 0; - greenSize = greenSize > 0 ? greenSize : 0; - blueSize = blueSize > 0 ? blueSize : 0; - alphaSize = alphaSize > 0 ? alphaSize : 0; - depthSize = depthSize > 0 ? depthSize : 0; - stencilSize = stencilSize > 0 ? stencilSize : 0; - sampleCount = sampleCount > 0 ? sampleCount : 0; - - eglProperties.setValue(EGL_RED_SIZE, redSize); - eglProperties.setValue(EGL_GREEN_SIZE, greenSize); - eglProperties.setValue(EGL_BLUE_SIZE, blueSize); - eglProperties.setValue(EGL_ALPHA_SIZE, alphaSize); - eglProperties.setValue(EGL_DEPTH_SIZE, depthSize); - eglProperties.setValue(EGL_STENCIL_SIZE, stencilSize); - eglProperties.setValue(EGL_SAMPLES, sampleCount); - eglProperties.setValue(EGL_SAMPLE_BUFFERS, sampleCount ? 1 : 0); -} - -// Updates "format" with the parameters of the selected configuration. -void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config) -{ - EGLint redSize = 0; - EGLint greenSize = 0; - EGLint blueSize = 0; - EGLint alphaSize = 0; - EGLint depthSize = 0; - EGLint stencilSize = 0; - EGLint sampleCount = 0; - EGLint level = 0; - - EGLDisplay display = QEgl::display(); - eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize); - eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize); - eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize); - eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize); - eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize); - eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize); - eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount); - eglGetConfigAttrib(display, config, EGL_LEVEL, &level); - - format.setRedBufferSize(redSize); - format.setGreenBufferSize(greenSize); - format.setBlueBufferSize(blueSize); - format.setAlphaBufferSize(alphaSize); - format.setDepthBufferSize(depthSize); - format.setStencilBufferSize(stencilSize); - format.setSamples(sampleCount); - format.setPlane(level + 1); // EGL calls level 0 "normal" whereas Qt calls 1 "normal" - format.setDirectRendering(true); // All EGL contexts are direct-rendered - format.setRgba(true); // EGL doesn't support colour index rendering - format.setStereo(false); // EGL doesn't support stereo buffers - format.setAccumBufferSize(0); // EGL doesn't support accululation buffers - - // Clear the EGL error state because some of the above may - // have errored out because the attribute is not applicable - // to the surface type. Such errors don't matter. - eglGetError(); -} -#endif - - QT_BEGIN_NAMESPACE QPlatformGLContext::QPlatformGLContext() diff --git a/src/plugins/platforms/openkode/main.cpp b/src/plugins/platforms/openkode/main.cpp index bd2b5c7..b60ae1b 100644 --- a/src/plugins/platforms/openkode/main.cpp +++ b/src/plugins/platforms/openkode/main.cpp @@ -48,7 +48,7 @@ class QOpenKODEPlugin : public QPlatformIntegrationPlugin { public: QStringList keys() const; - QPlatformIntegration *create(const QString&); + QPlatformIntegration *create(const QString&, const QStringList&); }; QStringList QOpenKODEPlugin::keys() const @@ -58,8 +58,9 @@ QStringList QOpenKODEPlugin::keys() const return list; } -QPlatformIntegration * QOpenKODEPlugin::create(const QString& system) +QPlatformIntegration * QOpenKODEPlugin::create(const QString& system, const QStringList& paramList) { + Q_UNUSED(paramList); if (system.toLower() == "openkode") return new QOpenKODEIntegration; diff --git a/src/plugins/platforms/openkode/openkode.pro b/src/plugins/platforms/openkode/openkode.pro index 042b74d..0614b3b 100644 --- a/src/plugins/platforms/openkode/openkode.pro +++ b/src/plugins/platforms/openkode/openkode.pro @@ -1,20 +1,37 @@ TARGET = qopenkodeintegration include(../../qpluginbase.pri) +QT += opengl + QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms SOURCES = main.cpp \ qopenkodeintegration.cpp \ qopenkodewindowsurface.cpp \ - qopenkodewindow.cpp + qopenkodewindow.cpp \ + qopenkodeglintegration.cpp HEADERS = qopenkodeintegration.h \ qopenkodewindowsurface.h \ - qopenkodewindow.h + qopenkodewindow.h \ + qopenkodeglintegration.h RESOURCES = resources.qrc target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target -LIBS += -lKD -lEGL -lGLESv2 +LIBS += -lKD -lEGL +!isEmpty(QMAKE_INCDIR_OPENGL_ES2){ + INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES2 +} +!isEmpty(QMAKE_LIBDIR_OPENGL_ES2){ + for(p, QMAKE_LIBDIR_OPENGL_ES2) { + exists($$p):LIBS += -L$$p + } +} +!isEmpty(QMAKE_LIBS_OPENGL_ES2){ + LIBS += $$QMAKE_LIBS_OPENGL_ES2 +} else { + LIBS += -lGLESv2 +} diff --git a/src/plugins/platforms/openkode/qopenkodeglintegration.cpp b/src/plugins/platforms/openkode/qopenkodeglintegration.cpp new file mode 100644 index 0000000..b0d901b --- /dev/null +++ b/src/plugins/platforms/openkode/qopenkodeglintegration.cpp @@ -0,0 +1,259 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qopenkodeglintegration.h" +#include +#include +#include + +#include + +#include + +void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLFormat& glFormat) +{ + int redSize = glFormat.redBufferSize(); + int greenSize = glFormat.greenBufferSize(); + int blueSize = glFormat.blueBufferSize(); + int alphaSize = glFormat.alphaBufferSize(); + int depthSize = glFormat.depthBufferSize(); + int stencilSize = glFormat.stencilBufferSize(); + int sampleCount = glFormat.samples(); + + // QGLFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that + // type has been requested. So we must check QGLFormat's booleans too if size is -1: + if (glFormat.alpha() && alphaSize <= 0) + alphaSize = 1; + if (glFormat.depth() && depthSize <= 0) + depthSize = 1; + if (glFormat.stencil() && stencilSize <= 0) + stencilSize = 1; + if (glFormat.sampleBuffers() && sampleCount <= 0) + sampleCount = 1; + + // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide + // the best performance. The EGL config selection algorithm is a bit stange in this regard: + // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard + // 32-bit configs completely from the selection. So it then comes to the sorting algorithm. + // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort + // order is special and described as "by larger _total_ number of color bits.". So EGL will + // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on + // to say "If the requested number of bits in attrib_list for a particular component is 0, + // then the number of bits for that component is not considered". This part of the spec also + // seems to imply that setting the red/green/blue bits to zero means none of the components + // are considered and EGL disregards the entire sorting rule. It then looks to the next + // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being + // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are + // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit, + // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that + // if the application sets the red/green/blue size to 5/6/5 on the QGLFormat, they will + // probably get a 32-bit config, even when there's an RGB565 config avaliable. Oh well. + + // Now normalize the values so -1 becomes 0 + redSize = redSize > 0 ? redSize : 0; + greenSize = greenSize > 0 ? greenSize : 0; + blueSize = blueSize > 0 ? blueSize : 0; + alphaSize = alphaSize > 0 ? alphaSize : 0; + depthSize = depthSize > 0 ? depthSize : 0; + stencilSize = stencilSize > 0 ? stencilSize : 0; + sampleCount = sampleCount > 0 ? sampleCount : 0; + + eglProperties.setValue(EGL_RED_SIZE, redSize); + eglProperties.setValue(EGL_GREEN_SIZE, greenSize); + eglProperties.setValue(EGL_BLUE_SIZE, blueSize); + eglProperties.setValue(EGL_ALPHA_SIZE, alphaSize); + eglProperties.setValue(EGL_DEPTH_SIZE, depthSize); + eglProperties.setValue(EGL_STENCIL_SIZE, stencilSize); + eglProperties.setValue(EGL_SAMPLES, sampleCount); + eglProperties.setValue(EGL_SAMPLE_BUFFERS, sampleCount ? 1 : 0); +} + +// Updates "format" with the parameters of the selected configuration. +void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config) +{ + EGLint redSize = 0; + EGLint greenSize = 0; + EGLint blueSize = 0; + EGLint alphaSize = 0; + EGLint depthSize = 0; + EGLint stencilSize = 0; + EGLint sampleCount = 0; + EGLint level = 0; + + EGLDisplay display = QEgl::display(); + eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize); + eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize); + eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize); + eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize); + eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize); + eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize); + eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount); + eglGetConfigAttrib(display, config, EGL_LEVEL, &level); + + format.setRedBufferSize(redSize); + format.setGreenBufferSize(greenSize); + format.setBlueBufferSize(blueSize); + format.setAlphaBufferSize(alphaSize); + format.setDepthBufferSize(depthSize); + format.setStencilBufferSize(stencilSize); + format.setSamples(sampleCount); + format.setPlane(level + 1); // EGL calls level 0 "normal" whereas Qt calls 1 "normal" + format.setDirectRendering(true); // All EGL contexts are direct-rendered + format.setRgba(true); // EGL doesn't support colour index rendering + format.setStereo(false); // EGL doesn't support stereo buffers + format.setAccumBufferSize(0); // EGL doesn't support accululation buffers + + // Clear the EGL error state because some of the above may + // have errored out because the attribute is not applicable + // to the surface type. Such errors don't matter. + eglGetError(); +} + +QEGLPlatformWidgetSurface::QEGLPlatformWidgetSurface() + :QPlatformGLWidgetSurface() +{ + +} +QEGLPlatformWidgetSurface::~QEGLPlatformWidgetSurface() +{ +} + +bool QEGLPlatformWidgetSurface::create(QGLWidget* widget, QGLFormat& format) +{ + return true; +} +void QEGLPlatformWidgetSurface::setGeometry(const QRect& rect) +{ + Q_UNUSED(rect); +} +bool QEGLPlatformWidgetSurface::filterEvent(QEvent *event) +{ + return QPlatformGLWidgetSurface::filterEvent(event); +} + +QEGLPlatformContext::QEGLPlatformContext() +{ +} + +QEGLPlatformContext::~QEGLPlatformContext() +{ + if (m_eglSurface != EGL_NO_SURFACE) { + doneCurrent(); + eglDestroySurface(QEgl::display(), m_eglSurface); + m_eglSurface = EGL_NO_SURFACE; + } + + if (m_context != EGL_NO_CONTEXT) { + eglDestroyContext(QEgl::display(), m_context); + m_context = EGL_NO_CONTEXT; + } +} + +bool QEGLPlatformContext::create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext) +{ + QEglProperties properties; + properties.setValue(EGL_CONTEXT_CLIENT_VERSION, 2); + //lets go with all defaults :) Seems like we get bad attributes for anything else + //qt_eglproperties_set_glformat(properties,format); + format.setDepthBufferSize(1); + EGLConfig config = QEgl::defaultConfig(device->devType(), QEgl::OpenGL,QEgl::Renderable); + QEGLPlatformContext *eglShareContext = static_cast(shareContext); + if (shareContext && eglShareContext->m_context != EGL_NO_CONTEXT) { + m_context = eglCreateContext(QEgl::display(), config, eglShareContext->m_context, properties.properties()); + if (m_context == EGL_NO_CONTEXT) { + qWarning() << "QEglContext::createContext(): Could not share context:" << QEgl::errorString(); + shareContext = 0; + } + } else { + m_context = eglCreateContext(QEgl::display(), config, EGL_NO_CONTEXT, properties.properties()); + if (m_context == EGL_NO_CONTEXT) { + qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << QEgl::errorString(); + return false; + } + } + //Get/create the EGLSurface + if (device && device->devType() == QInternal::Widget){ + QWidget* widget = static_cast(device); + QGLWidget* glWidget = qobject_cast(widget); + + if (!widget->isTopLevel()) { + qWarning("Creating a GL context is only supported on top-level QWidgets"); + return false; + } + EGLNativeWindowType winId = (EGLNativeWindowType) widget->window()->winId(); + + m_eglSurface = eglCreateWindowSurface(QEgl::display(), config, winId, 0); + makeCurrent(); + glClearColor(0.0, 0.0, 0.0, 1.0); + swapBuffers(); + + + } else { + qDebug() << "QEGLPlatformContext::create: didn't create surface!!!!!"; + } + return true; + +} + +void QEGLPlatformContext::makeCurrent() +{ + eglBindAPI(EGL_OPENGL_API); + bool ok = eglMakeCurrent(QEgl::display(), m_eglSurface, m_eglSurface, m_context); + if (!ok) + qWarning() << "QEGLPlatformContext::makeCurrent(" << m_eglSurface << "):" << QEgl::errorString(); +} +void QEGLPlatformContext::doneCurrent() +{ + eglBindAPI(EGL_OPENGL_ES_API); + bool ok = eglMakeCurrent(QEgl::display(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + if (!ok) + qWarning() << "QEGLPlatformContext::doneCurrent():" << QEgl::errorString(); +} +void QEGLPlatformContext::swapBuffers() +{ + bool ok = eglSwapBuffers(QEgl::display(), m_eglSurface); + if (!ok) + qWarning() << "QEGLPlatformContext::swapBuffers():" << QEgl::errorString(); +} +void* QEGLPlatformContext::getProcAddress(const QString& procName) +{ + eglGetProcAddress(qPrintable(procName)); +} diff --git a/src/plugins/platforms/openkode/qopenkodeglintegration.h b/src/plugins/platforms/openkode/qopenkodeglintegration.h new file mode 100644 index 0000000..c3291b8 --- /dev/null +++ b/src/plugins/platforms/openkode/qopenkodeglintegration.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOPENKODEGLINTEGRATION_H +#define QOPENKODEGLINTEGRATION_H + +#include +#include +#include + +void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLFormat& glFormat); +// Updates "format" with the parameters of the selected configuration. +void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config); + +class QEGLPlatformWidgetSurface : public QPlatformGLWidgetSurface +{ +public: + QEGLPlatformWidgetSurface(); + virtual ~QEGLPlatformWidgetSurface(); + + bool create(QGLWidget*, QGLFormat&); + void setGeometry(const QRect&); + bool filterEvent(QEvent *); +}; + +class QEGLPlatformContext : public QPlatformGLContext +{ +public: + QEGLPlatformContext(); + ~QEGLPlatformContext(); + + bool create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext); + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString& procName); + +private: + EGLContext m_context; + EGLSurface m_eglSurface; +}; + +#endif //QOPENKODEGLINTEGRATION_H diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index d9430c2..cd957af 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -42,6 +42,10 @@ #include "qopenkodeintegration.h" #include "qopenkodewindowsurface.h" #include "qopenkodewindow.h" +#include "qopenkodeglintegration.h" + +#include +#include #include @@ -198,7 +202,7 @@ QOpenKODEIntegration::QOpenKODEIntegration() QPixmapData *QOpenKODEIntegration::createPixmapData(QPixmapData::PixelType type) const { - return new QRasterPixmapData(type); + return new QGLPixmapData(type); } QPlatformWindow *QOpenKODEIntegration::createPlatformWindow(QWidget *tlw, WId ) const @@ -206,9 +210,22 @@ QPlatformWindow *QOpenKODEIntegration::createPlatformWindow(QWidget *tlw, WId ) return new QOpenKODEWindow(tlw); } -QWindowSurface *QOpenKODEIntegration::createWindowSurface(QWidget *widget, WId winId) const +QWindowSurface *QOpenKODEIntegration::createWindowSurface(QWidget *widget, WId wid) const +{ + return new QGLWindowSurface(widget); +} + +bool QOpenKODEIntegration::hasOpenGL() const +{ + return true; +} +QPlatformGLContext *QOpenKODEIntegration::createGLContext() +{ + return new QEGLPlatformContext; +} +QPlatformGLWidgetSurface *QOpenKODEIntegration::createGLWidgetSurface() { - return new QOpenKODEWindowSurface(widget,winId); + return new QEGLPlatformWidgetSurface; } GLuint QOpenKODEIntegration::blitterProgram() diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h index 76ce219..ad6db4b 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeintegration.h @@ -81,6 +81,10 @@ public: QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + bool hasOpenGL() const; + QPlatformGLContext * createGLContext(); + QPlatformGLWidgetSurface * createGLWidgetSurface(); + virtual QList screens() const { return mScreens; } static GLuint blitterProgram(); diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index 8e1527c..4d18a6f 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -63,23 +63,28 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) return; } - const KDint windowSize[2] = { tlw->width(), tlw->height() }; + const KDint windowSize[2] = { tlw->width(), tlw->height()-1 }; if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { qErrnoWarning(kdGetError(), "Could not set native window size"); return; } + KDboolean visibillity(false); + if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) { + qErrnoWarning(kdGetError(), "Could not set visibillity to false"); + } + // const KDboolean windowExclusive[] = { false }; // if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, windowExclusive)) { // qErrnoWarning(kdGetError(), "Could not set exclusive bit"); // //return; // } // -// const KDint windowPos[2] = { tlw->x(), tlw->y() }; -// if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { -// qErrnoWarning(kdGetError(), "Could not set native window position"); -// return; -// } + const KDint windowPos[2] = { tlw->x(), tlw->y() }; + if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { + qErrnoWarning(kdGetError(), "Could not set native window position"); + return; + } if (kdRealizeWindow(kdWindow, &eglWindow)) { qErrnoWarning(kdGetError(), "Could not realize native window"); @@ -87,6 +92,11 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) } } +QOpenKODEWindow::~QOpenKODEWindow() +{ + qDebug() << "destroying window"; + kdDestroyWindow(kdWindow); +} void QOpenKODEWindow::setGeometry(const QRect &rect) { const QRect geo = geometry(); @@ -98,17 +108,20 @@ void QOpenKODEWindow::setGeometry(const QRect &rect) } } -// if (geo.topLeft() != rect.topLeft()) { -// const KDint windowPos[2] = { rect.x(), rect.y() }; -// if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { -// qErrnoWarning(kdGetError(), "Could not set native window position"); -// //return; -// } -// } + if (geo.topLeft() != rect.topLeft()) { + const KDint windowPos[2] = { rect.x(), rect.y() }; + if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { + qErrnoWarning(kdGetError(), "Could not set native window position"); + //return; + } + } } void QOpenKODEWindow::setVisible(bool visible) { - + KDboolean visibillity(visible); + if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) { + qErrnoWarning(kdGetError(), "Could not set visibillity to false"); + } } diff --git a/src/plugins/platforms/openkode/qopenkodewindow.h b/src/plugins/platforms/openkode/qopenkodewindow.h index b52f8e6..741e676 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.h +++ b/src/plugins/platforms/openkode/qopenkodewindow.h @@ -50,6 +50,7 @@ class QOpenKODEWindow : public QPlatformWindow { public: QOpenKODEWindow(QWidget *tlw); + ~QOpenKODEWindow(); void setGeometry(const QRect &rect); void setVisible(bool visible); diff --git a/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp b/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp index 5eb0d2d..dacd019 100644 --- a/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp @@ -135,7 +135,7 @@ void QOpenKODEWindowSurface::flush(QWidget *, const QRegion ®ion, const QPoin glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, blitImage.bits()); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, mImage.bits()); // Enable vertex attribute associated with vertex position glEnableVertexAttribArray(posId); @@ -157,8 +157,12 @@ void QOpenKODEWindowSurface::flush(QWidget *, const QRegion ®ion, const QPoin if (texId) glDeleteTextures(1, &texId); + eglWaitGL(); + mContext.swapBuffers(mSurface); mContext.doneCurrent(); + + eglWaitNative(EGL_CORE_NATIVE_ENGINE); } void QOpenKODEWindowSurface::resize(const QSize &size) @@ -171,10 +175,14 @@ void QOpenKODEWindowSurface::resize(const QSize &size) } void QOpenKODEWindowSurface::beginPaint(const QRegion ®ion) { + Q_UNUSED(region); if (mSurface == EGL_NO_SURFACE) { EGLConfig config = QEgl::defaultConfig(QInternal::Widget,QEgl::OpenGL,QEgl::Renderable); EGLint windowAttrs[] = { EGL_NONE }; mSurface = eglCreateWindowSurface(QEgl::display(), config, mWin, windowAttrs); + if (mSurface == EGL_NO_SURFACE) { + qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError()); + } mImage = QImage(size(),QImage::Format_RGB32); } } -- cgit v0.12 From e17ada56a676c7d87c0803cdc8367065e7aaa317 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 1 Jun 2010 15:34:52 +0200 Subject: make reporting screen size/count changes safe before QApplication constructor --- src/gui/kernel/qapplication.cpp | 3 +++ src/gui/kernel/qapplication_lite.cpp | 23 +++++++++++++++++------ src/gui/kernel/qapplication_p.h | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 5b294cc..6dbb7f2 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -812,6 +812,9 @@ void QApplicationPrivate::construct( if (qt_is_gui_used) qt_guiPlatformPlugin(); #endif +#ifdef Q_WS_LITE + QApplicationPrivate::qapp_constructed = true; +#endif } #if defined(Q_WS_X11) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 6008a9f..2b94102 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -86,6 +86,8 @@ static int mousePressX; static int mousePressY; static int mouse_double_click_distance = 5; +bool QApplicationPrivate::qapp_constructed = false; // QApplication::QApplication completed? + void QApplicationPrivate::processUserEvent(QWindowSystemInterface::UserEvent *e) { switch(e->type) { @@ -830,18 +832,24 @@ void QApplicationPrivate::processTouchEvent(QWindowSystemInterface::TouchEvent * void QApplicationPrivate::reportScreenCount(int count) { + // This operation only makes sense after the QApplication constructor runs + if (!QApplicationPrivate::qapp_constructed) + return; + // signal anything listening for creation or deletion of screens QDesktopWidget *desktop = QApplication::desktop(); - if (desktop) - emit desktop->screenCountChanged(count); + emit desktop->screenCountChanged(count); } void QApplicationPrivate::reportGeometryChange(int screenIndex) { + // This operation only makes sense after the QApplication constructor runs + if (!QApplicationPrivate::qapp_constructed) + return; + // signal anything listening for screen geometry changes QDesktopWidget *desktop = QApplication::desktop(); - if (desktop) - emit desktop->resized(screenIndex); + emit desktop->resized(screenIndex); // make sure maximized and fullscreen windows are updated QWidgetList list = QApplication::topLevelWidgets(); @@ -856,10 +864,13 @@ void QApplicationPrivate::reportGeometryChange(int screenIndex) void QApplicationPrivate::reportAvailableGeometryChange(int screenIndex) { + // This operation only makes sense after the QApplication constructor runs + if (!QApplicationPrivate::qapp_constructed) + return; + // signal anything listening for screen geometry changes QDesktopWidget *desktop = QApplication::desktop(); - if (desktop) - emit desktop->workAreaResized(screenIndex); + emit desktop->workAreaResized(screenIndex); // make sure maximized and fullscreen windows are updated QWidgetList list = QApplication::topLevelWidgets(); diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index e272a36..58128c8 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -428,6 +428,7 @@ public: static QString graphics_system_name; #if defined(Q_WS_LITE) static QPlatformIntegration *platform_integration; + static bool qapp_constructed; #endif private: -- cgit v0.12 From 56a57f127354a42a5de8dc59510ba5a3cfd8b442 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 2 Jun 2010 12:36:37 +0200 Subject: use QCoreApplication::startingUp() to decide if QApplication::desktop() is safe --- src/gui/kernel/qapplication.cpp | 3 --- src/gui/kernel/qapplication_lite.cpp | 8 +++----- src/gui/kernel/qapplication_p.h | 1 - 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 6dbb7f2..5b294cc 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -812,9 +812,6 @@ void QApplicationPrivate::construct( if (qt_is_gui_used) qt_guiPlatformPlugin(); #endif -#ifdef Q_WS_LITE - QApplicationPrivate::qapp_constructed = true; -#endif } #if defined(Q_WS_X11) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 2b94102..792b28b 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -86,8 +86,6 @@ static int mousePressX; static int mousePressY; static int mouse_double_click_distance = 5; -bool QApplicationPrivate::qapp_constructed = false; // QApplication::QApplication completed? - void QApplicationPrivate::processUserEvent(QWindowSystemInterface::UserEvent *e) { switch(e->type) { @@ -833,7 +831,7 @@ void QApplicationPrivate::processTouchEvent(QWindowSystemInterface::TouchEvent * void QApplicationPrivate::reportScreenCount(int count) { // This operation only makes sense after the QApplication constructor runs - if (!QApplicationPrivate::qapp_constructed) + if (QCoreApplication::startingUp()) return; // signal anything listening for creation or deletion of screens @@ -844,7 +842,7 @@ void QApplicationPrivate::reportScreenCount(int count) void QApplicationPrivate::reportGeometryChange(int screenIndex) { // This operation only makes sense after the QApplication constructor runs - if (!QApplicationPrivate::qapp_constructed) + if (QCoreApplication::startingUp()) return; // signal anything listening for screen geometry changes @@ -865,7 +863,7 @@ void QApplicationPrivate::reportGeometryChange(int screenIndex) void QApplicationPrivate::reportAvailableGeometryChange(int screenIndex) { // This operation only makes sense after the QApplication constructor runs - if (!QApplicationPrivate::qapp_constructed) + if (QCoreApplication::startingUp()) return; // signal anything listening for screen geometry changes diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 58128c8..e272a36 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -428,7 +428,6 @@ public: static QString graphics_system_name; #if defined(Q_WS_LITE) static QPlatformIntegration *platform_integration; - static bool qapp_constructed; #endif private: -- cgit v0.12 From 31608f9ca899b4d85b3c339bbab24cf42450831f Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 2 Jun 2010 16:08:56 +0200 Subject: pass the QList of TouchPoints as a constant reference for handleTouchEvent --- src/gui/kernel/qapplication_lite.cpp | 23 +---------------------- src/gui/kernel/qwindowsysteminterface.cpp | 30 ++++++++++++++++++++++++++++-- src/gui/kernel/qwindowsysteminterface.h | 8 ++++---- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 792b28b..4b935ae 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -804,28 +804,7 @@ void QApplicationPrivate::processCloseEvent(QWidget *tlw) void QApplicationPrivate::processTouchEvent(QWindowSystemInterface::TouchEvent *e) { - QList touchPoints; - Qt::TouchPointStates states; - - int primaryPoint = -1; - foreach(struct QWindowSystemInterface::TouchPoint point, e->points) { - QTouchEvent::TouchPoint p; - p.setId(point.id); - p.setPressure(point.pressure); - states |= point.state; - if (point.isPrimary) { - point.state |= Qt::TouchPointPrimary; - primaryPoint = point.id; - } - p.setState(point.state); - p.setRect(point.area); - p.setScreenPos(point.area.center()); - p.setNormalizedPos(point.normalPosition); - - touchPoints.append(p); - } - - translateRawTouchEvent(e->widget.data(), e->devType, touchPoints); + translateRawTouchEvent(e->widget.data(), e->devType, e->points); } void QApplicationPrivate::reportScreenCount(int count) diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index cd466e3..c9d177d 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -134,11 +134,37 @@ void QWindowSystemInterfacePrivate::queueUserEvent(QWindowSystemInterface::UserE dispatcher->wakeUp(); } -void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, QList points) +void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points) { if (!points.size()) // Touch events must have at least one point return; - TouchEvent *e = new TouchEvent(tlw, timestamp, type, devType, points); + + QList touchPoints; + Qt::TouchPointStates states; + QTouchEvent::TouchPoint p; + + int primaryPoint = -1; + QList::const_iterator point = points.constBegin(); + QList::const_iterator end = points.constEnd(); + while (point != end) { + p.setId(point->id); + p.setPressure(point->pressure); + states |= point->state; + Qt::TouchPointStates state = point->state; + if (point->isPrimary) { + state |= Qt::TouchPointPrimary; + primaryPoint = point->id; + } + p.setState(state); + p.setRect(point->area); + p.setScreenPos(point->area.center()); + p.setNormalizedPos(point->normalPosition); + + touchPoints.append(p); + ++point; + } + + TouchEvent *e = new TouchEvent(tlw, timestamp, type, devType, touchPoints); QWindowSystemInterfacePrivate::queueUserEvent(e); } diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 8c69218..88d6475 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -85,11 +85,11 @@ public: Qt::TouchPointStates state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released} }; - static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, QList points) { + static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points) { handleTouchEvent(w, eventTime.elapsed(), type, devType, points); } - static void handleTouchEvent(QWidget *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, QList points); + static void handleTouchEvent(QWidget *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points); // delivered directly by the plugin via spontaneous events static void handleGeometryChange(QWidget *w, const QRect &newRect); @@ -143,10 +143,10 @@ public: class TouchEvent : public UserEvent { public: - TouchEvent(QWidget *w, ulong time, QEvent::Type t, QTouchEvent::DeviceType d, QList p) + TouchEvent(QWidget *w, ulong time, QEvent::Type t, QTouchEvent::DeviceType d, const QList &p) :UserEvent(w, time, t) { devType = d; points = p; } QTouchEvent::DeviceType devType; - QList points; + QList points; }; private: -- cgit v0.12 From 37ef97675aeb71a542ef179e98d5ee29f98d25c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 2 Jun 2010 16:17:22 +0200 Subject: Use the QBlittable::drawPixmap implementation for pixmaps when we can just enable a few more states --- src/gui/painting/qpaintengine_blitter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 4144696..f2e6cdd 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -117,12 +117,12 @@ public: updateStateBits(&drawPixmapMask, STATE_XFORM_SCALE, true); updateStateBits(&drawPixmapMask, STATE_XFORM_COMPLEX, false); - updateStateBits(&drawPixmapMask, STATE_BRUSH_PATTERN, false); + updateStateBits(&drawPixmapMask, STATE_BRUSH_PATTERN, true); updateStateBits(&drawPixmapMask, STATE_BRUSH_ALPHA, false); - updateStateBits(&drawPixmapMask, STATE_PEN_ENABLED, false); + updateStateBits(&drawPixmapMask, STATE_PEN_ENABLED, true); - updateStateBits(&drawPixmapMask, STATE_ANTIALIASING, false); + updateStateBits(&drawPixmapMask, STATE_ANTIALIASING, true); updateStateBits(&drawPixmapMask, STATE_ALPHA, false); updateStateBits(&drawPixmapMask, STATE_BLENDING_COMPLEX, false); -- cgit v0.12 From 28547949cc78d25884a76bf3c2112a6217ba5b66 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Thu, 3 Jun 2010 13:19:37 +0200 Subject: software cursor cleanup --- src/plugins/platforms/fb_base/fb_base.cpp | 24 +++++++++++++----------- src/plugins/platforms/fb_base/fb_base.h | 6 ++++++ src/plugins/platforms/vnc/qvnccursor.cpp | 4 ++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index f2009c1..cdcb608 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -26,25 +26,29 @@ void QGraphicsSystemSoftwareCursor::pointerEvent(const QMouseEvent & e) { Q_UNUSED(e); currentRect = getCurrentRect(); - screen->setDirty(currentRect); + setDirty(); } QRect QGraphicsSystemSoftwareCursor::drawCursor(QPainter & painter) { + dirty = false; if (currentRect.isNull()) return QRect(); + if (!currentRect.intersects(screen->geometry())) + return QRect(); + prevRect = currentRect; painter.drawImage(prevRect, *graphic->image()); + onScreen = true; return prevRect; } QRect QGraphicsSystemSoftwareCursor::dirtyRect() { - if (!prevRect.isNull()) { - QRect rect = prevRect; - prevRect = QRect(); - return rect; + if (onScreen) { + onScreen = false; + return prevRect; } return QRect(); } @@ -78,7 +82,7 @@ void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget setCursor(shape); } currentRect = getCurrentRect(); - screen->setDirty(currentRect); + setDirty(); } QFbScreen::QFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false) @@ -126,8 +130,6 @@ QFbScreen::~QFbScreen() void QFbScreen::setDirty(const QRect &rect) { - -// qDebug() << "QFbScreen::setDirty" << rect; repaintRegion += rect; if (!redrawTimer.isActive()) { redrawTimer.start(); @@ -165,9 +167,9 @@ void QFbScreen::generateRects() QRegion QFbScreen::doRedraw() { QRegion touchedRegion; - if (cursor) + if (cursor && cursor->isDirty() && cursor->isOnScreen()) repaintRegion += cursor->dirtyRect(); - if (repaintRegion.isEmpty()) + if (repaintRegion.isEmpty() && !cursor->isDirty()) return touchedRegion; QVector rects = repaintRegion.rects(); @@ -223,7 +225,7 @@ QRegion QFbScreen::doRedraw() } QRect cursorRect; - if (cursor) { + if (cursor && cursor->isDirty()) { cursorRect = cursor->drawCursor(*compositePainter); touchedRegion += cursorRect; } diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index 13638a0..d94462d 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -29,6 +29,10 @@ public: virtual void pointerEvent(const QMouseEvent & event); virtual void changeCursor(QCursor * widgetCursor, QWidget * widget); + virtual void setDirty() { dirty = true; screen->setDirty(QRect()); } + virtual bool isDirty() { return dirty; } + virtual bool isOnScreen() { return onScreen; } + protected: QGraphicsSystemCursorImage * graphic; @@ -39,6 +43,8 @@ private: QRect currentRect; // next place to draw the cursor QRect prevRect; // last place the cursor was drawn QRect getCurrentRect(); + bool dirty; + bool onScreen; }; class QFbWindow; diff --git a/src/plugins/platforms/vnc/qvnccursor.cpp b/src/plugins/platforms/vnc/qvnccursor.cpp index 8da06aa..72dcb25 100644 --- a/src/plugins/platforms/vnc/qvnccursor.cpp +++ b/src/plugins/platforms/vnc/qvnccursor.cpp @@ -64,14 +64,14 @@ void QVNCCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) if (useVncCursor) { server->setDirtyCursor(); } else { - screen->setDirty(QRect(0,0,1,1)); + setDirty(); } } void QVNCCursor::setCursorMode(bool vnc) { if (vnc) { - screen->setDirty(dirtyRect()); + setDirty(); server->setDirtyCursor(); } else { server->setDirtyCursor(); -- cgit v0.12 From a498db43a02972e90df5f1cdd73e90260471f5f8 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 11 Jun 2010 12:50:27 +0200 Subject: litehouse multiscreen support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds QPlatformIntegration::moveToScreen(), which requests that a widget be moved to another screen. The default implementation ignores the request. The VNC plugin has been updated accordingly. It currently only supports non-virtual desktops. Review by: Jørgen --- src/gui/kernel/kernel.pri | 3 +- src/gui/kernel/qapplication_lite.cpp | 21 ++++++-- src/gui/kernel/qdesktopwidget_lite.cpp | 43 ++++++++++++++-- src/gui/kernel/qdesktopwidget_lite_p.h | 74 +++++++++++++++++++++++++++ src/gui/kernel/qplatformintegration_lite.h | 2 + src/gui/kernel/qwidget.cpp | 8 +++ src/gui/kernel/qwidget.h | 1 + src/gui/kernel/qwidget_lite.cpp | 31 ++++++++++- src/gui/kernel/qwidget_p.h | 2 + src/gui/kernel/qwindowsysteminterface.h | 2 +- src/plugins/platforms/fb_base/fb_base.cpp | 61 ++++++++++++++++------ src/plugins/platforms/fb_base/fb_base.h | 7 +-- src/plugins/platforms/vnc/qvncintegration.cpp | 40 +++++++++++++-- src/plugins/platforms/vnc/qvncintegration.h | 3 ++ src/plugins/platforms/vnc/qvncserver.cpp | 9 ++-- 15 files changed, 264 insertions(+), 43 deletions(-) create mode 100644 src/gui/kernel/qdesktopwidget_lite_p.h diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 049637f..bc9e70c 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -50,7 +50,8 @@ HEADERS += \ kernel/qgesturemanager_p.h \ kernel/qsoftkeymanager_p.h \ kernel/qsoftkeymanager_common_p.h \ - kernel/qguiplatformplugin_p.h + kernel/qguiplatformplugin_p.h \ + kernel/qdesktopwidget_lite_p.h SOURCES += \ kernel/qaction.cpp \ diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 4b935ae..dd25cd4 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -63,6 +63,7 @@ #include #include +#include "qdesktopwidget_lite_p.h" QT_BEGIN_NAMESPACE @@ -395,11 +396,16 @@ QWidget *QApplication::topLevelAt(const QPoint &pos) { QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); - QPlatformScreen *screen = pi->screens().first(); - if (!screen) - return 0; - QWidget *w = screen->topLevelAt(pos); - return w; + QList screens = pi->screens(); + QList::const_iterator screen = screens.constBegin(); + QList::const_iterator end = screens.constEnd(); + + while (screen != end) { + if ((*screen)->geometry().contains(pos)) + return (*screen)->topLevelAt(pos); + ++screen; + } + return 0; } void QApplication::beep() @@ -813,6 +819,7 @@ void QApplicationPrivate::reportScreenCount(int count) if (QCoreApplication::startingUp()) return; + QApplication::desktop()->d_func()->updateScreenList(); // signal anything listening for creation or deletion of screens QDesktopWidget *desktop = QApplication::desktop(); emit desktop->screenCountChanged(count); @@ -824,6 +831,8 @@ void QApplicationPrivate::reportGeometryChange(int screenIndex) if (QCoreApplication::startingUp()) return; + QApplication::desktop()->d_func()->updateScreenList(); + // signal anything listening for screen geometry changes QDesktopWidget *desktop = QApplication::desktop(); emit desktop->resized(screenIndex); @@ -845,6 +854,8 @@ void QApplicationPrivate::reportAvailableGeometryChange(int screenIndex) if (QCoreApplication::startingUp()) return; + QApplication::desktop()->d_func()->updateScreenList(); + // signal anything listening for screen geometry changes QDesktopWidget *desktop = QApplication::desktop(); emit desktop->workAreaResized(screenIndex); diff --git a/src/gui/kernel/qdesktopwidget_lite.cpp b/src/gui/kernel/qdesktopwidget_lite.cpp index b077d57..3e37faf 100644 --- a/src/gui/kernel/qdesktopwidget_lite.cpp +++ b/src/gui/kernel/qdesktopwidget_lite.cpp @@ -42,13 +42,43 @@ #include "qdesktopwidget.h" #include "private/qapplication_p.h" #include "private/qgraphicssystem_p.h" - +#include +#include "private/qwidget_p.h" +#include "private/qdesktopwidget_lite_p.h" QT_BEGIN_NAMESPACE QT_USE_NAMESPACE +void QDesktopWidgetPrivate::updateScreenList() +{ + QList screenList = QApplicationPrivate::platformIntegration()->screens(); + int targetLength = screenList.length(); + int currentLength = screens.length(); + + // Add or remove screen widgets as necessary + if(currentLength > targetLength) { + QDesktopScreenWidget *screen; + while (currentLength-- > targetLength) { + screen = screens.takeLast(); + delete screen; + } + } + else if (currentLength < targetLength) { + QDesktopScreenWidget *screen; + while (currentLength < targetLength) { + screen = new QDesktopScreenWidget(currentLength++); + screens.append(screen); + } + } + + // update the geometry of each screen widget + for (int i = 0; i < screens.length(); i++) { + screens.at(i)->setGeometry(screenList.at(i)->geometry()); + } +} + QDesktopWidget::QDesktopWidget() - : QWidget(0, Qt::Desktop) + : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop) { setObjectName(QLatin1String("desktop")); } @@ -59,7 +89,7 @@ QDesktopWidget::~QDesktopWidget() bool QDesktopWidget::isVirtualDesktop() const { - return true; + return QApplicationPrivate::platformIntegration()->isVirtualDesktop(); } int QDesktopWidget::primaryScreen() const @@ -73,9 +103,12 @@ int QDesktopWidget::numScreens() const return qMax(pi->screens().size(), 1); } -QWidget *QDesktopWidget::screen(int) +QWidget *QDesktopWidget::screen(int screen) { - return this; + Q_D(QDesktopWidget); + if (screen < 0 || screen >= d->screens.length()) + return d->screens.at(0); + return d->screens.at(screen); } const QRect QDesktopWidget::availableGeometry(int screenNo) const diff --git a/src/gui/kernel/qdesktopwidget_lite_p.h b/src/gui/kernel/qdesktopwidget_lite_p.h new file mode 100644 index 0000000..c04e172 --- /dev/null +++ b/src/gui/kernel/qdesktopwidget_lite_p.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +// +// 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. +// + +#ifndef QDESKTOPWIDGET_LITE_P_H +#define QDESKTOPWIDGET_LITE_P_H + +#include "QDesktopWidget" +#include "private/qwidget_p.h" + +class QDesktopScreenWidget : public QWidget { + Q_OBJECT +public: + QDesktopScreenWidget(int screenNumber) { setWindowFlags(Qt::Desktop); setVisible(false); d_func()->screenNumber = screenNumber; } +}; + +class QDesktopWidgetPrivate : public QWidgetPrivate { +public: + QDesktopWidgetPrivate() { updateScreenList(); } + ~QDesktopWidgetPrivate() {foreach(QDesktopScreenWidget *s, screens) delete s; } + void updateScreenList(); + + QList screens; +}; + +#endif // QDESKTOPWIDGET_LITE_P_H diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h index a509b52..aa71c3d 100644 --- a/src/gui/kernel/qplatformintegration_lite.h +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -66,9 +66,11 @@ public: virtual QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const = 0; virtual QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const = 0; virtual QBlittable *createBlittable(const QSize &size) const; + virtual void moveToScreen(QWidget *window, int screen) {Q_UNUSED(window); Q_UNUSED(screen);} // Window System functions virtual QList screens() const = 0; + virtual bool isVirtualDesktop() { return false; } virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; // OpenGL Integration functions diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 2c9730b..611bd50 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -211,6 +211,8 @@ QWidgetPrivate::QWidgetPrivate(int version) , hasAlienChildren(0) , window_event(0) , qd_hd(0) +#elif defined (Q_WS_LITE) + , screenNumber(0) #endif { if (!qApp) { @@ -1154,6 +1156,12 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) // programmer specified desktop widget xinfo = desktopWidget->d_func()->xinfo; } +#elif defined(Q_WS_LITE) + if (desktopWidget) { + int screen = desktopWidget->d_func()->screenNumber; + QPlatformIntegration *platform = QApplicationPrivate::platformIntegration(); + platform->moveToScreen(q, screen); + } #else Q_UNUSED(desktopWidget); #endif diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 7dff703..598e877 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -629,6 +629,7 @@ public: #if defined(Q_WS_LITE) void setPlatformWindow(QPlatformWindow *window); QPlatformWindow *platformWindow() const; + friend class QDesktopScreenWidget; #endif Q_SIGNALS: diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index d281bec..25cd0f6 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -85,6 +85,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO setWinId(q->platformWindow()->winId()); + QApplicationPrivate::platformIntegration()->moveToScreen(q, screenNumber); // qDebug() << "create_sys" << q << q->internalWinId(); } @@ -119,14 +120,31 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) { Q_Q(QWidget); -// QWidget *oldParent = q->parentWidget(); + + // QWidget *oldParent = q->parentWidget(); Qt::WindowFlags oldFlags = data.window_flags; + + int targetScreen = -1; + // Handle a request to move the widget to a particular screen + if (newparent && newparent->windowType() == Qt::Desktop) { + // make sure the widget is created on the same screen as the + // programmer specified desktop widget + + // get the desktop's screen number + targetScreen = newparent->d_func()->screenNumber; + newparent = 0; + } + if (parent != newparent) { QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? - } + if (!newparent) { f |= Qt::Window; + if (targetScreen == -1) { + if (parent) + targetScreen = qobject_cast(parent)->d_func()->screenNumber; + } } bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); @@ -153,6 +171,15 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) q->setAttribute(Qt::WA_WState_Hidden); q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); + // move the window to the selected screen + if (!newparent && targetScreen != -1) { + screenNumber = targetScreen; + // only if it is already created + if (q->testAttribute(Qt::WA_WState_Created)) { + QPlatformIntegration *platform = QApplicationPrivate::platformIntegration(); + platform->moveToScreen(q, targetScreen); + } + } } QPoint QWidget::mapToGlobal(const QPoint &pos) const diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index b5376a4..e0b8a67 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -815,6 +815,8 @@ public: #elif defined(Q_WS_LITE) void setMaxWindowState_helper(); void setFullScreenSize_helper(); + + int screenNumber; // screen the widget should be displayed on #ifndef QT_NO_CURSOR void updateCursor() const; #endif diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 88d6475..614f983 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -105,7 +105,7 @@ public: class UserEvent { public: UserEvent(QWidget * w, ulong time, QEvent::Type t) - { widget = QWeakPointer::QWeakPointer(w); type = t; timestamp = time; } + { widget = QWeakPointer(w); type = t; timestamp = time; } QWeakPointer widget; QEvent::Type type; unsigned long timestamp; diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index cdcb608..0463a60 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -18,6 +18,8 @@ QRect QGraphicsSystemSoftwareCursor::getCurrentRect() QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(), -graphic->hotspot().y()); rect.translate(QCursor::pos()); + QPoint screenOffset = screen->geometry().topLeft(); + rect.translate(-screenOffset); // global to local translation return rect; } @@ -25,8 +27,12 @@ QRect QGraphicsSystemSoftwareCursor::getCurrentRect() void QGraphicsSystemSoftwareCursor::pointerEvent(const QMouseEvent & e) { Q_UNUSED(e); + QPoint screenOffset = screen->geometry().topLeft(); currentRect = getCurrentRect(); - setDirty(); + // global to local translation + if (onScreen || screen->geometry().intersects(currentRect.translated(screenOffset))) { + setDirty(); + } } QRect QGraphicsSystemSoftwareCursor::drawCursor(QPainter & painter) @@ -35,7 +41,10 @@ QRect QGraphicsSystemSoftwareCursor::drawCursor(QPainter & painter) if (currentRect.isNull()) return QRect(); - if (!currentRect.intersects(screen->geometry())) + // We need this because the cursor might be dirty due to moving off screen + QPoint screenOffset = screen->geometry().topLeft(); + // global to local translation + if (!currentRect.translated(screenOffset).intersects(screen->geometry())) return QRect(); prevRect = currentRect; @@ -82,7 +91,9 @@ void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget setCursor(shape); } currentRect = getCurrentRect(); - setDirty(); + QPoint screenOffset = screen->geometry().topLeft(); // global to local translation + if (onScreen || screen->geometry().intersects(currentRect.translated(screenOffset))) + setDirty(); } QFbScreen::QFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false) @@ -130,7 +141,9 @@ QFbScreen::~QFbScreen() void QFbScreen::setDirty(const QRect &rect) { - repaintRegion += rect; + QRect intersection = rect.intersected(mGeometry); + QPoint screenOffset = mGeometry.topLeft(); + repaintRegion += intersection.translated(-screenOffset); // global to local translation if (!redrawTimer.isActive()) { redrawTimer.start(); } @@ -139,7 +152,8 @@ void QFbScreen::setDirty(const QRect &rect) void QFbScreen::generateRects() { cachedRects.clear(); - QRegion remainingScreen(mGeometry); + QPoint screenOffset = mGeometry.topLeft(); + QRegion remainingScreen(mGeometry.translated(-screenOffset)); // global to local translation for (int i = 0; i < windowStack.length(); i++) { if (remainingScreen.isEmpty()) @@ -148,8 +162,8 @@ void QFbScreen::generateRects() continue; if (!windowStack[i]->widget()->testAttribute(Qt::WA_TranslucentBackground)) { - remainingScreen -= windowStack[i]->geometry(); - QRegion windowRegion(windowStack[i]->geometry()); + remainingScreen -= windowStack[i]->localGeometry(); + QRegion windowRegion(windowStack[i]->localGeometry()); windowRegion -= remainingScreen; foreach(QRect rect, windowRegion.rects()) { cachedRects += QPair(rect, i); @@ -166,11 +180,16 @@ void QFbScreen::generateRects() QRegion QFbScreen::doRedraw() { + QPoint screenOffset = mGeometry.topLeft(); // optimize me! + QRegion touchedRegion; - if (cursor && cursor->isDirty() && cursor->isOnScreen()) - repaintRegion += cursor->dirtyRect(); - if (repaintRegion.isEmpty() && !cursor->isDirty()) + if (cursor && cursor->isDirty() && cursor->isOnScreen()) { + QRect lastCursor = cursor->dirtyRect(); + repaintRegion += lastCursor; + } + if (repaintRegion.isEmpty() && !cursor->isDirty()) { return touchedRegion; + } QVector rects = repaintRegion.rects(); @@ -206,10 +225,9 @@ QRegion QFbScreen::doRedraw() continue; if (windowStack[layerIndex]->widget()->isMinimized()) continue; - QRect windowRect = windowStack[layerIndex]->geometry(); + QRect windowRect = windowStack[layerIndex]->geometry().translated(-screenOffset); QRect windowIntersect = rect.translated(-windowRect.left(), - -windowRect.top()); -// qDebug() << " compositing" << layerIndex << windowStack[layerIndex]->surface->image().size(); + -windowRect.top()); compositePainter->drawImage(rect, windowStack[layerIndex]->surface->image(), windowIntersect); if (firstLayer) { @@ -218,10 +236,6 @@ QRegion QFbScreen::doRedraw() } } } - if (!rectRegion.isEmpty()) - qWarning() << "non-empty region!" << rectRegion; - // Everything on screen should be mapped to a sub-rectangle - // unless it's off the screen... } QRect cursorRect; @@ -240,6 +254,16 @@ QRegion QFbScreen::doRedraw() return touchedRegion; } +void QFbScreen::addWindow(QFbWindow *surface) +{ + windowStack.prepend(surface); + surface->mScreen = this; + QPoint screenOffset = mGeometry.topLeft(); + surface->localGeometry() = surface->geometry().translated(-screenOffset); // global to local translation + invalidateRectCache(); + setDirty(surface->geometry()); +} + void QFbScreen::removeWindow(QFbWindow * surface) { windowStack.removeOne(surface); @@ -369,6 +393,9 @@ void QFbWindow::setGeometry(const QRect &rect) //### QWindowSystemInterface::handleGeometryChange(window(), rect); QPlatformWindow::setGeometry(rect); + + QPoint screenOffset = mScreen->geometry().topLeft(); + mLocalGeometry = rect.translated(-screenOffset); // global to local translation } bool QFbWindowSurface::scroll(const QRegion &area, int dx, int dy) diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index d94462d..f1dd574 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -98,6 +98,8 @@ public: virtual void repaint(const QRegion&); + virtual QRect localGeometry() { return mLocalGeometry; } + protected: friend class QFbWindowSurface; friend class QFbScreen; @@ -106,7 +108,7 @@ protected: QRect oldGeometry; bool visibleFlag; Qt::WindowFlags flags; - + QRect mLocalGeometry; // local screen coordinates WId windowId; }; @@ -131,8 +133,7 @@ public: virtual void setDirty(const QRect &rect); virtual void removeWindow(QFbWindow * surface); - virtual void addWindow(QFbWindow * surface) { - windowStack.prepend(surface); invalidateRectCache(); } + virtual void addWindow(QFbWindow * surface); virtual void raise(QPlatformWindow * surface); virtual void lower(QPlatformWindow * surface); virtual QWidget * topLevelAt(const QPoint & p) const; diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp index 69aea79..de6d81f 100644 --- a/src/plugins/platforms/vnc/qvncintegration.cpp +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -50,7 +50,6 @@ #include - QVNCScreen::QVNCScreen(QRect screenSize, int screenId) : QFbScreen::QFbScreen() { @@ -99,6 +98,8 @@ QVNCIntegration::QVNCIntegration(const QStringList& paramList) { int sizeX = defaultWidth(); int sizeY = defaultHeight(); + int offsetX = 0; + int offsetY = 0; int display = defaultDisplay(); bool showUsage = false; @@ -111,6 +112,19 @@ QVNCIntegration::QVNCIntegration(const QStringList& paramList) else if (confString.startsWith(QLatin1String("display="))) { display = confString.section(QLatin1Char('='), 1, 1).toInt(); } + else if (confString.startsWith(QLatin1String("offset="))) { + QString val = confString.section(QLatin1Char('='), 1, 1); + offsetX = val.section(QLatin1Char('x'), 0, 0).toInt(); + offsetY = val.section(QLatin1Char('x'), 1, 1).toInt(); + } + else if (confString == QLatin1String("vnc")) { + QRect screenRect(offsetX, offsetY, sizeX, sizeY); + QVNCScreen *screen = new QVNCScreen(screenRect, display); + mScreens.append(screen); + screen->setObjectName(QString("screen %1").arg(display)); + screen->setDirty(screenRect); + ++display; + } else { qWarning() << "Unknown VNC option:" << confString; showUsage = true; @@ -120,9 +134,12 @@ QVNCIntegration::QVNCIntegration(const QStringList& paramList) if (showUsage) usage(); - mPrimaryScreen = new QVNCScreen(QRect(0, 0, sizeX, sizeY), display); - - mScreens.append(mPrimaryScreen); + QRect screenRect(offsetX, offsetY, sizeX, sizeY); + QVNCScreen *screen = new QVNCScreen(screenRect, display); + mScreens.append(screen); + mPrimaryScreen = qobject_cast(mScreens.first()); + screen->setObjectName(QString("screen %1").arg(display)); + screen->setDirty(screenRect); } QPixmapData *QVNCIntegration::createPixmapData(QPixmapData::PixelType type) const @@ -155,3 +172,18 @@ QPlatformWindow *QVNCIntegration::createPlatformWindow(QWidget *widget, WId /*wi return w; } +void QVNCIntegration::moveToScreen(QWidget *window, int screen) +{ + if (screen < 0 || screen > mScreens.size()) + return; + QVNCScreen * newScreen = qobject_cast(mScreens.at(screen)); + for(int i = 0; i < mScreens.size(); i++) { + QVNCScreen *oldScreen = qobject_cast(mScreens.at(i)); + if (oldScreen->windowStack.contains(static_cast(window->platformWindow()))) { + oldScreen->removeWindow(static_cast(window->platformWindow())); + break; + } + } + window->platformWindow()->setGeometry(window->geometry()); // this should be unified elsewhere + newScreen->addWindow(static_cast(window->platformWindow())); +} diff --git a/src/plugins/platforms/vnc/qvncintegration.h b/src/plugins/platforms/vnc/qvncintegration.h index dcb5419..3436e51 100644 --- a/src/plugins/platforms/vnc/qvncintegration.h +++ b/src/plugins/platforms/vnc/qvncintegration.h @@ -55,6 +55,7 @@ class QVNCScreenPrivate; class QVNCScreen : public QFbScreen { + Q_OBJECT public: QVNCScreen(QRect screenSize, int screenId); @@ -68,6 +69,7 @@ public: private: QVNCServer *server; QRegion doRedraw(); + friend class QVNCIntegration; }; class QVNCIntegrationPrivate; @@ -84,6 +86,7 @@ public: QList screens() const { return mScreens; } + void moveToScreen(QWidget *window, int screen); private: QVNCScreen *mPrimaryScreen; diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp index 6424083..fb6eaa8 100644 --- a/src/plugins/platforms/vnc/qvncserver.cpp +++ b/src/plugins/platforms/vnc/qvncserver.cpp @@ -831,14 +831,13 @@ static bool buttonChange(Qt::MouseButtons before, Qt::MouseButtons after, Qt::Mo void QVNCServer::pointerEvent() { + QPoint screenOffset = this->screen()->geometry().topLeft(); + QRfbPointerEvent ev; if (ev.read(client)) { -// const QPoint offset = qvnc_screen->offset(); -// QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons); - QPoint eventPoint(ev.x, ev.y); - eventPoint += screen()->geometry().topLeft(); - //qDebug() << "pointerEvent" << ev.x << ev.y << hex << ev.buttons; + eventPoint += screenOffset; // local to global translation + if (ev.wheelDirection == ev.WheelNone) { QEvent::Type type = QEvent::MouseMove; Qt::MouseButton button = Qt::NoButton; -- cgit v0.12 From 7497ae0504a4186103c835c3c0cfca5133f2d50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 11 Jun 2010 11:54:24 +0200 Subject: Added QPlatformGLContext to QPlatformWindow and removed the the creator function. Child QGLWidgets don't work --- src/gui/kernel/kernel.pri | 3 +- src/gui/kernel/qplatformglcontext_lite.h | 71 ++++++++++ src/gui/kernel/qplatformintegration_lite.cpp | 12 -- src/gui/kernel/qplatformintegration_lite.h | 10 -- src/gui/kernel/qplatformwindow_lite.cpp | 5 + src/gui/kernel/qplatformwindow_lite.h | 4 + src/gui/kernel/qwidget_lite.cpp | 12 +- src/opengl/opengl.pro | 6 +- src/opengl/qgl_lite.cpp | 80 ++--------- src/opengl/qgl_p.h | 6 +- src/opengl/qglplatformintegration_lite.h | 88 ------------ src/plugins/platforms/testlite/qglxintegration.cpp | 157 ++------------------- src/plugins/platforms/testlite/qglxintegration.h | 25 +--- .../platforms/testlite/qtestliteintegration.cpp | 18 --- .../platforms/testlite/qtestliteintegration.h | 6 - src/plugins/platforms/testlite/qtestlitewindow.cpp | 27 +++- src/plugins/platforms/testlite/qtestlitewindow.h | 4 + 17 files changed, 144 insertions(+), 390 deletions(-) create mode 100644 src/gui/kernel/qplatformglcontext_lite.h delete mode 100644 src/opengl/qglplatformintegration_lite.h diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index bc9e70c..f849ad7 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -208,7 +208,8 @@ embedded_lite { kernel/qplatformscreen_lite.h \ kernel/qplatformintegrationfactory_lite_p.h \ kernel/qplatformintegrationplugin_lite.h \ - kernel/qplatformwindow_lite.h + kernel/qplatformwindow_lite.h \ + kernel/qplatformglcontext_lite.h SOURCES += \ kernel/qapplication_lite.cpp \ diff --git a/src/gui/kernel/qplatformglcontext_lite.h b/src/gui/kernel/qplatformglcontext_lite.h new file mode 100644 index 0000000..8aeb635 --- /dev/null +++ b/src/gui/kernel/qplatformglcontext_lite.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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 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$ +** +****************************************************************************/ + +#ifndef QPLATFORM_GL_CONTEXT_H +#define QPLATFORM_GL_CONTEXT_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class Q_OPENGL_EXPORT QPlatformGLContext +{ +public: + //QPlatformGLContext(); + //virtual ~QPlatformGLContext(); + + //virtual bool create(QPaintDevice* device, QPlatformGLContext* shareContext) = 0; + + virtual void makeCurrent() = 0; + virtual void doneCurrent() = 0; + virtual void swapBuffers() = 0; + virtual void* getProcAddress(const QString& procName) = 0; + +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QPLATFORM_GL_INTEGRATION_P_H diff --git a/src/gui/kernel/qplatformintegration_lite.cpp b/src/gui/kernel/qplatformintegration_lite.cpp index 2d181f1..6499570 100644 --- a/src/gui/kernel/qplatformintegration_lite.cpp +++ b/src/gui/kernel/qplatformintegration_lite.cpp @@ -56,21 +56,9 @@ QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, in return QPixmap(); } -#ifndef QT_NO_OPENGL bool QPlatformIntegration::hasOpenGL() const { return false; } -QPlatformGLContext * QPlatformIntegration::createGLContext() -{ - return 0; -} - -QPlatformGLWidgetSurface * QPlatformIntegration::createGLWidgetSurface() -{ - return 0; -} -#endif - QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h index aa71c3d..88c3049 100644 --- a/src/gui/kernel/qplatformintegration_lite.h +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -51,11 +51,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) -#ifndef QT_NO_OPENGL -class QPlatformGLContext; -class QPlatformGLWidgetSurface; -#endif - class Q_GUI_EXPORT QPlatformIntegration { public: @@ -73,12 +68,7 @@ public: virtual bool isVirtualDesktop() { return false; } virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; -// OpenGL Integration functions -#ifndef QT_NO_OPENGL virtual bool hasOpenGL() const; - virtual QPlatformGLContext * createGLContext(); - virtual QPlatformGLWidgetSurface * createGLWidgetSurface(); -#endif }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformwindow_lite.cpp b/src/gui/kernel/qplatformwindow_lite.cpp index c8a3ed5..151e93d 100644 --- a/src/gui/kernel/qplatformwindow_lite.cpp +++ b/src/gui/kernel/qplatformwindow_lite.cpp @@ -76,3 +76,8 @@ void QPlatformWindow::setOpacity(qreal level) Q_UNUSED(level); qWarning("This plugin does not support setting window opacity"); } + +QPlatformGLContext *QPlatformWindow::glContext() +{ + return 0; +} diff --git a/src/gui/kernel/qplatformwindow_lite.h b/src/gui/kernel/qplatformwindow_lite.h index 583ac28..0a94fc0 100644 --- a/src/gui/kernel/qplatformwindow_lite.h +++ b/src/gui/kernel/qplatformwindow_lite.h @@ -54,6 +54,8 @@ QT_BEGIN_NAMESPACE class QPlatformWindowPrivate; class QWidget; +class QPlatformGLContext; + class Q_GUI_EXPORT QPlatformWindow { Q_DECLARE_PRIVATE(QPlatformWindow); @@ -75,6 +77,8 @@ public: virtual void lower(); virtual void setOpacity(qreal level); + + virtual QPlatformGLContext *glContext(); protected: QScopedPointer d_ptr; }; diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 25cd0f6..e1a8d0d 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -77,7 +77,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO Q_ASSERT(platformWindow); // QGLWidget does not need/work with a windowsurface - if (!surface && !q->inherits("QGLWidget")) { + if (!surface) {// && !q->inherits("QGLWidget")) { surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId()); } @@ -343,18 +343,20 @@ void QWidgetPrivate::show_sys() if (!q->isWindow()) return; - if (QWindowSurface *surface = q->windowSurface()) { + if (QPlatformWindow *window = q->platformWindow()) { const QRect geomRect = q->geometry(); - const QRect windowRect = q->platformWindow()->geometry(); + const QRect windowRect = window->geometry(); if (windowRect != geomRect) { q->platformWindow()->setGeometry(geomRect); - if (windowRect.size() != geomRect.size()) { - surface->resize(geomRect.size()); + if (QWindowSurface *surface = q->windowSurface()) + if (windowRect.size() != geomRect.size()) { + surface->resize(geomRect.size()); } } q->platformWindow()->setVisible(true); } + if (q->windowType() != Qt::Popup && q->windowType() != Qt::ToolTip && !(q->windowFlags() & Qt::X11BypassWindowManagerHint)) q->activateWindow(); //### } diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 53f9d3e..6670d14 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -79,10 +79,8 @@ SOURCES += qgl.cpp \ embedded_lite { DEFINES += QT_NO_EGL - SOURCES += qgl_lite.cpp - HEADERS += qglplatformintegration_lite.h - - SOURCES += qglpixelbuffer_stub.cpp + SOURCES += qgl_lite.cpp \ + qglpixelbuffer_stub.cpp } x11 { diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp index 636c711..2003cc1 100644 --- a/src/opengl/qgl_lite.cpp +++ b/src/opengl/qgl_lite.cpp @@ -40,39 +40,18 @@ ****************************************************************************/ #include +#include #include #include #include +#include #include "qgl.h" #include "qgl_p.h" -#include "qglplatformintegration_lite.h" QT_BEGIN_NAMESPACE -QPlatformGLContext::QPlatformGLContext() -{ -} - -QPlatformGLContext::~QPlatformGLContext() -{ -} - -QPlatformGLWidgetSurface::QPlatformGLWidgetSurface() -{ -} - -QPlatformGLWidgetSurface::~QPlatformGLWidgetSurface() -{ -} - -bool QPlatformGLWidgetSurface::filterEvent(QEvent*) -{ - // By default, return false to allow the event to pass through - return false; -} - bool QGLFormat::hasOpenGL() { @@ -82,8 +61,16 @@ bool QGLFormat::hasOpenGL() bool QGLContext::chooseContext(const QGLContext* shareContext) { Q_D(QGLContext); - d->platformContext = QApplicationPrivate::platformIntegration()->createGLContext(); - d->valid = d->platformContext->create(d->paintDevice, d->glFormat, shareContext ? shareContext->d_func()->platformContext : 0); + if (!d->paintDevice && d->paintDevice->devType() != QInternal::Widget) { + d->valid = false; + }else { + QWidget *widget = static_cast(d->paintDevice); + if (!widget->platformWindow()){ + widget->winId();//make window + } + d->platformContext = widget->platformWindow()->glContext(); + d->valid =(bool) d->platformContext; + } return d->valid; } @@ -154,18 +141,6 @@ void QGLWidget::setContext(QGLContext *context, QGLContext* oldcx = d->glcx; d->glcx = context; - if (!d->wsurf) { - // If the application has set WA_TranslucentBackground and not explicitly set - // the alpha buffer size to zero, modify the format so it have an alpha channel - QGLFormat format = d->glcx->d_func()->glFormat; - if (testAttribute(Qt::WA_TranslucentBackground) && format.alphaBufferSize() == -1) - format.setAlphaBufferSize(1); - - d->wsurf = QApplicationPrivate::platformIntegration()->createGLWidgetSurface(); - d->wsurf->create(this, format); - d->glcx->d_func()->glFormat = format; - } - if (!d->glcx->isValid()) d->glcx->create(shareContext ? shareContext : oldcx); @@ -173,12 +148,6 @@ void QGLWidget::setContext(QGLContext *context, delete oldcx; } -QPlatformGLWidgetSurface* QGLWidget::platformSurface() -{ - Q_D(QGLWidget); - return d->wsurf; -} - void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) { initContext(context, shareWidget); @@ -247,33 +216,12 @@ void QGLWidget::setMouseTracking(bool enable) bool QGLWidget::event(QEvent *e) { - Q_D(QGLWidget); - - if (d->wsurf) { - bool eventFiltered = d->wsurf->filterEvent(e); - if (eventFiltered) - return true; - } - return QWidget::event(e); } -void QGLWidget::resizeEvent(QResizeEvent *) +void QGLWidget::resizeEvent(QResizeEvent *e) { - Q_D(QGLWidget); - if (!isValid()) - return; - - if (!d->wsurf) { - qWarning("QGLWidget::resizeEvent() - widget does not have a platform surface"); - return; - } - d->wsurf->setGeometry(geometry()); //### What about moveEvent? - - makeCurrent(); - if (!d->glcx->initialized()) - glInit(); - resizeGL(width(), height()); + return QWidget::resizeEvent(e); } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 37466d8..042d5ae 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -69,7 +69,7 @@ #endif #if defined(Q_WS_LITE) -#include +#include #endif QT_BEGIN_NAMESPACE @@ -165,7 +165,7 @@ class QGLWidgetPrivate : public QWidgetPrivate public: QGLWidgetPrivate() : QWidgetPrivate() , disable_clear_on_painter_begin(false) -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) , wsurf(0) #endif #if defined(Q_WS_X11) && !defined(QT_NO_EGL) @@ -207,8 +207,6 @@ public: void updatePaintDevice(); #elif defined(Q_WS_QWS) QWSGLWindowSurface *wsurf; -#elif defined (Q_WS_LITE) - QPlatformGLWidgetSurface* wsurf; #endif }; diff --git a/src/opengl/qglplatformintegration_lite.h b/src/opengl/qglplatformintegration_lite.h deleted file mode 100644 index bec920c..0000000 --- a/src/opengl/qglplatformintegration_lite.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** 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 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$ -** -****************************************************************************/ - -#ifndef QPLATFORM_GL_CONTEXT_H -#define QPLATFORM_GL_CONTEXT_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -// QGLPlatformWidgetSurface does _not_ inherit from QWindowSurface -// - The backing store may be totally unaware of it's existance. -class Q_OPENGL_EXPORT QPlatformGLWidgetSurface -{ -public: - QPlatformGLWidgetSurface(); - virtual ~QPlatformGLWidgetSurface(); - - virtual bool create(QGLWidget*, QGLFormat&) = 0; - - virtual void setGeometry(const QRect&) = 0; - virtual bool filterEvent(QEvent*); -}; - - -class Q_OPENGL_EXPORT QPlatformGLContext -{ -public: - QPlatformGLContext(); - virtual ~QPlatformGLContext(); - - virtual bool create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext) = 0; - - virtual void makeCurrent() = 0; - virtual void doneCurrent() = 0; - virtual void swapBuffers() = 0; - virtual void* getProcAddress(const QString& procName) = 0; - -}; - - - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QPLATFORM_GL_INTEGRATION_P_H diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index 79596f5..ba89dbd 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -128,106 +128,24 @@ GLXFBConfig qt_glx_integration_choose_config(MyDisplay* xd, QGLFormat& format, i return chosenConfig; } - -QGLXGLWidgetSurface::QGLXGLWidgetSurface(MyDisplay* xd) - : QPlatformGLWidgetSurface() +QGLXGLContext::QGLXGLContext(WId winId, MyDisplay *xd, QGLFormat& format, QPlatformGLContext* shareContext) + : QPlatformGLContext() , m_xd(xd) + , m_drawable((Drawable)winId) , m_config(0) - , m_winId(0) - , m_widget(0) -{ -} - -QGLXGLWidgetSurface::~QGLXGLWidgetSurface() -{ -} - -static Colormap qt_glx_integration_colormap = 0; - - -bool QGLXGLWidgetSurface::create(QGLWidget *widget, QGLFormat& format) + , m_context(0) { - m_widget = widget; + GLXContext shareGlxContext = 0; + if (shareContext) + shareGlxContext = static_cast(shareContext)->glxContext(); m_config = qt_glx_integration_choose_config(m_xd, format, GLX_WINDOW_BIT); - Window parentWindow = widget->window()->winId(); - - XVisualInfo* visualInfo; - visualInfo = glXGetVisualFromFBConfig(m_xd->display, m_config); - - // ### This will leak the colormap, but we need a colormap for each visual -// if (!qt_glx_integration_colormap) { - qt_glx_integration_colormap = XCreateColormap(m_xd->display, parentWindow, - visualInfo->visual, AllocNone); -// } - - XSetWindowAttributes windowAttribs; - windowAttribs.background_pixel = m_xd->whitePixel(); - windowAttribs.border_pixel = m_xd->blackPixel(); - windowAttribs.colormap = qt_glx_integration_colormap; - - m_winId = XCreateWindow(m_xd->display, parentWindow, - widget->x(), widget->y(), widget->width(), widget->height(), - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWBackPixel|CWBorderPixel|CWColormap, &windowAttribs); + m_context = glXCreateNewContext(m_xd->display, m_config, GLX_RGBA_TYPE, shareGlxContext, True); #ifdef MYX11_DEBUG - qDebug() << "QGLXGLWidgetSurface::create" << hex << "parent" << parentWindow << "win:" << m_winId << widget; + qDebug() << "QGLXGLContext::create context" << m_context; #endif - XSetWindowBackgroundPixmap(m_xd->display, m_winId, XNone); - XMapWindow(m_xd->display, m_winId); - - XFree(visualInfo); - return true; -} - -void QGLXGLWidgetSurface::setGeometry(const QRect& rect) -{ -#ifdef MYX11_DEBUG - qDebug() << "QGLXGLWidgetSurface::setGeometry" << rect << hex << m_xd->display << m_winId << "toplevel?" << m_widget->isWindow(); -#endif - //### toplevel QGLWidgets do have a separate X window owned by the surface, but it has a - // local geometry - if (m_widget->isWindow()) - XMoveResizeWindow(m_xd->display, m_winId, 0, 0, rect.width(), rect.height()); - else - XMoveResizeWindow(m_xd->display, m_winId, rect.x(), rect.y(), rect.width(), rect.height()); -} - -bool QGLXGLWidgetSurface::filterEvent(QEvent *e) -{ - if (e->type() == QEvent::ParentAboutToChange) { - // We temporarily hide the window and re-parent it with the root window - // as it's quite likely that the parent window is about to be deleted, - // which would otherwise destroy our window along with it. - XUnmapWindow(m_xd->display, m_winId); - XReparentWindow(m_xd->display, m_winId, m_xd->rootWindow(), 0, 0); -#ifdef MYX11_DEBUG - qDebug() << "filterEvent unmap" << hex << m_winId; -#endif - } - - if (e->type() == QEvent::ParentChange) { - // Once we've got a new parent, we need to reparent the window and show it again: - XReparentWindow(m_xd->display, m_winId, m_widget->window()->winId(), m_widget->x(), m_widget->y()); - XMapWindow(m_xd->display, m_winId); -#ifdef MYX11_DEBUG - qDebug() << "filterEvent reparent" << hex << m_winId << "to:" << m_widget->window()->winId(); -#endif - } - - return false; // Allow the event to pass through to QGLWidget -} - - -QGLXGLContext::QGLXGLContext(MyDisplay *xd) - : QPlatformGLContext() - , m_xd(xd) - , m_drawable(0) - , m_config(0) - , m_context(0) -{ } QGLXGLContext::~QGLXGLContext() @@ -238,63 +156,6 @@ QGLXGLContext::~QGLXGLContext() } } -bool QGLXGLContext::create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext) -{ - Q_UNUSED(format); - - if (device->devType() != QInternal::Widget) { - qWarning("Creating a GL context is only supported on QWidgets"); - return false; - } - - GLXContext shareGlxContext = 0; - if (shareContext) - shareGlxContext = static_cast(shareContext)->glxContext(); - - - QWidget* widget = static_cast(device); - QGLWidget* glWidget = qobject_cast(widget); - if (glWidget) { - // Take the config from the QGLWidget's glx surface: - QGLXGLWidgetSurface* surface = static_cast(glWidget->platformSurface()); - m_config = surface->config(); - m_drawable = (Drawable)surface->winId(); -#ifdef MYX11_DEBUG - qDebug() << "QGLXGLContext::create" << hex << m_config << m_drawable; -#endif - } - else { - if (!widget->isTopLevel()) { - qWarning("Creating a GL context is only supported on top-level QWidgets"); - return false; - } - m_drawable = (Drawable)widget->platformWindow()->winId(); - - // ### This might choose a config with a visual that isn't compatable with the native window: - m_config = qt_glx_integration_choose_config(m_xd, format, GLX_WINDOW_BIT); - } - - m_context = glXCreateNewContext(m_xd->display, m_config, GLX_RGBA_TYPE, shareGlxContext, True); -#ifdef MYX11_DEBUG - qDebug() << "QGLXGLContext::create context" << m_context; -#endif - - // Get the XVisualInfo for the window: -// XWindowAttributes windowAttribs; -// XGetWindowAttributes(m_display, m_widget->winId(), &windowAttribs); -// XVisualInfo visualInfoTemplate; -// visualInfoTemplate.visualid = 33; //XVisualIDFromVisual(windowAttribs.visual); -// XVisualInfo *visualInfo; -// int matchingCount = 0; -// visualInfo = XGetVisualInfo(m_xd->display, VisualIDMask, &visualInfoTemplate, &matchingCount); - -// m_context = glXCreateContext(m_xd->display, visualInfo, 0, True); - -// qDebug("Created GLX context 0x%x for visual ID %d", m_context, visualInfoTemplate.visualid); - - return true; -} - void QGLXGLContext::makeCurrent() { #ifdef MYX11_DEBUG diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h index 0302950..6d9a216 100644 --- a/src/plugins/platforms/testlite/qglxintegration.h +++ b/src/plugins/platforms/testlite/qglxintegration.h @@ -42,40 +42,19 @@ #ifndef Q_GLX_CONTEXT_H #define Q_GLX_CONTEXT_H -#include +#include #include QT_BEGIN_NAMESPACE class MyDisplay; -class QGLXGLWidgetSurface : public QPlatformGLWidgetSurface -{ -public: - QGLXGLWidgetSurface(MyDisplay* xd); - virtual ~QGLXGLWidgetSurface(); - - virtual bool create(QGLWidget*, QGLFormat&); - virtual void setGeometry(const QRect&); - virtual bool filterEvent(QEvent*); - - GLXFBConfig config() {return m_config;} - Window winId() {return m_winId;} - -private: - MyDisplay *m_xd; - GLXFBConfig m_config; - Window m_winId; - QGLWidget* m_widget; -}; - class QGLXGLContext : public QPlatformGLContext { public: - QGLXGLContext(MyDisplay* xd); + QGLXGLContext(WId winId, MyDisplay *xd, QGLFormat& format, QPlatformGLContext* shareContext); ~QGLXGLContext(); - virtual bool create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext); virtual void makeCurrent(); virtual void doneCurrent(); virtual void swapBuffers(); diff --git a/src/plugins/platforms/testlite/qtestliteintegration.cpp b/src/plugins/platforms/testlite/qtestliteintegration.cpp index 3fa3495..3ce9b7c 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.cpp +++ b/src/plugins/platforms/testlite/qtestliteintegration.cpp @@ -109,19 +109,15 @@ QTestLiteIntegration::QTestLiteIntegration(bool useOpenGL) QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type) const { -#ifndef QT_NO_OPENGL if (mUseOpenGL) return new QGLPixmapData(type); -#endif return new QRasterPixmapData(type); } QWindowSurface *QTestLiteIntegration::createWindowSurface(QWidget *widget, WId) const { -#ifndef QT_NO_OPENGL if (mUseOpenGL) return new QGLWindowSurface(widget); -#endif return new QTestLiteWindowSurface(mPrimaryScreen, widget); } @@ -140,23 +136,9 @@ QPixmap QTestLiteIntegration::grabWindow(WId window, int x, int y, int width, in return QPixmap::fromImage(img); } -#ifndef QT_NO_OPENGL bool QTestLiteIntegration::hasOpenGL() const { return glXQueryExtension(xd->display, 0, 0) != 0; } -QPlatformGLContext *QTestLiteIntegration::createGLContext() -{ - return new QGLXGLContext(xd); -} - -QPlatformGLWidgetSurface *QTestLiteIntegration::createGLWidgetSurface() -{ - return new QGLXGLWidgetSurface(xd); -} - -#endif // QT_NO_OPENGL - - QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qtestliteintegration.h b/src/plugins/platforms/testlite/qtestliteintegration.h index 8289a5c..01d428c 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.h +++ b/src/plugins/platforms/testlite/qtestliteintegration.h @@ -81,18 +81,12 @@ public: QList screens() const { return mScreens; } -#ifndef QT_NO_OPENGL bool hasOpenGL() const; - QPlatformGLContext * createGLContext(); - QPlatformGLWidgetSurface * createGLWidgetSurface(); -#endif MyDisplay *xd; private: -#ifndef QT_NO_OPENGL bool mUseOpenGL; -#endif QTestLiteScreen *mPrimaryScreen; QList mScreens; }; diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index b5ae4fc..4ddb7ca 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -55,6 +55,9 @@ #include #include +#include +#include "qglxintegration.h" + #include #include @@ -146,7 +149,7 @@ private: QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration, QTestLiteScreen */*screen*/, QWidget *window) - :QPlatformWindow(window) + :QPlatformWindow(window), mGLContext(0) { xd = platformIntegration->xd; xd->windowList.append(this); @@ -191,6 +194,7 @@ QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration setWindowFlags(window->windowFlags()); //##### This should not be the plugin's responsibility + //xw->windowTL = this; } @@ -661,8 +665,6 @@ void QTestLiteWindow::setWindowTitle(const QString &title) XSetWMName(xd->display, x_window, &windowName); } - - GC QTestLiteWindow::createGC() { GC gc; @@ -674,14 +676,14 @@ GC QTestLiteWindow::createGC() return gc; } - void QTestLiteWindow::paintEvent() { #ifdef MYX11_DEBUG // qDebug() << "QTestLiteWindow::paintEvent" << shm_img.size() << painted; #endif - widget()->windowSurface()->flush(widget(), QRect(xpos,ypos,width, height), QPoint()); + if (QWindowSurface *surface = widget()->windowSurface()) + surface->flush(widget(), QRect(xpos,ypos,width, height), QPoint()); } @@ -1005,6 +1007,21 @@ void QTestLiteWindow::setCursor(QCursor * cursor) XFlush(xd->display); } +QPlatformGLContext *QTestLiteWindow::glContext() +{ + if (!mGLContext) { + mGLContext = createGLContext(); + } + return mGLContext; +} + +QPlatformGLContext *QTestLiteWindow::createGLContext() +{ + QGLFormat format; + QPlatformGLContext *context = new QGLXGLContext(x_window, xd, format, 0); + return context; +} + Cursor QTestLiteWindow::createCursorBitmap(QCursor * cursor) { XColor bg, fg; diff --git a/src/plugins/platforms/testlite/qtestlitewindow.h b/src/plugins/platforms/testlite/qtestlitewindow.h index 28e49be..5d27f3a 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.h +++ b/src/plugins/platforms/testlite/qtestlitewindow.h @@ -126,6 +126,8 @@ public: void setCursor(QCursor * cursor); + QPlatformGLContext *glContext(); + private: int xpos, ypos; int width, height; @@ -135,6 +137,7 @@ private: GC createGC(); Cursor createCursorShape(int cshape); Cursor createCursorBitmap(QCursor * cursor); + QPlatformGLContext *createGLContext(); int currentCursor; @@ -142,6 +145,7 @@ private: QTestLiteScreen *mScreen; Qt::WindowFlags window_flags; + QPlatformGLContext *mGLContext; friend class QTestLiteWindowSurface; // x_window, gc and windowSurface }; -- cgit v0.12 From 0fdbda6da734969a8ea4e28a327071865b58fb5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 11 Jun 2010 13:23:01 +0200 Subject: Add support for native children in QtGui again no pluginsupport though --- src/gui/kernel/qwidget.cpp | 6 ------ src/gui/painting/qbackingstore.cpp | 6 +----- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 611bd50..5078ba4 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2429,10 +2429,7 @@ WId QWidget::effectiveWinId() const return id; QWidget *realParent = nativeParentWidget(); Q_ASSERT(realParent); -#ifndef Q_WS_LITE - //### we really need to implement winId functionality Q_ASSERT(realParent->internalWinId()); -#endif return realParent->internalWinId(); } @@ -4121,9 +4118,6 @@ QWidget *QWidget::window() const */ QWidget *QWidget::nativeParentWidget() const { -#ifdef Q_WS_LITE - return window(); //### we don't have native child widgets yet -#endif QWidget *parent = parentWidget(); while (parent && !parent->internalWinId()) parent = parent->parentWidget(); diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 7220ce6..b158a76 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -747,12 +747,8 @@ void QWidgetBackingStore::markDirtyOnScreen(const QRegion ®ion, QWidget *widg } // Alien widgets. - if (!widget->internalWinId() && !widget->isWindow()) { //### LITEHACK we need winid support!!! -#ifdef Q_WS_LITE - QWidget *nativeParent = widget->window(); //### LITEHACK so far only toplevels are native -#else + if (!widget->internalWinId() && !widget->isWindow()) { QWidget *nativeParent = widget->nativeParentWidget(); // Alien widgets with the top-level as the native parent (common case). -#endif if (nativeParent == tlw) { if (!widget->testAttribute(Qt::WA_WState_InPaintEvent)) dirtyOnScreen += region.translated(topLevelOffset); -- cgit v0.12 From e5d607b3635d53c84dbb782f534d8cac9096dd14 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 15 Jun 2010 11:07:04 +0200 Subject: fixed software cursor rendering when the widget under the cursor is redrawn also check if the cursor exists before checking if it is dirty when considering an early exit from QFbScreen::doRedraw() --- src/plugins/platforms/fb_base/fb_base.cpp | 4 ++-- src/plugins/platforms/fb_base/fb_base.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index 0463a60..5004a5a 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -187,7 +187,7 @@ QRegion QFbScreen::doRedraw() QRect lastCursor = cursor->dirtyRect(); repaintRegion += lastCursor; } - if (repaintRegion.isEmpty() && !cursor->isDirty()) { + if (repaintRegion.isEmpty() && (!cursor || !cursor->isDirty())) { return touchedRegion; } @@ -239,7 +239,7 @@ QRegion QFbScreen::doRedraw() } QRect cursorRect; - if (cursor && cursor->isDirty()) { + if (cursor && (cursor->isDirty() || repaintRegion.intersects(cursor->lastPainted()))) { cursorRect = cursor->drawCursor(*compositePainter); touchedRegion += cursorRect; } diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index f1dd574..124dde0 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -32,6 +32,7 @@ public: virtual void setDirty() { dirty = true; screen->setDirty(QRect()); } virtual bool isDirty() { return dirty; } virtual bool isOnScreen() { return onScreen; } + virtual QRect lastPainted() { return prevRect; } protected: QGraphicsSystemCursorImage * graphic; -- cgit v0.12 From 47b8d9d08386e841580ddc920681b07b338cbdb6 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 15 Jun 2010 13:09:50 +0200 Subject: virtual desktop multiscreen support - VNC plugin --- src/gui/kernel/qapplication_lite.cpp | 6 ++ src/gui/kernel/qdesktopwidget_lite.cpp | 14 ++++- src/gui/kernel/qdesktopwidget_lite_p.h | 3 +- src/plugins/platforms/fb_base/fb_base.cpp | 79 +++++++++++++++++++-------- src/plugins/platforms/fb_base/fb_base.h | 7 +-- src/plugins/platforms/vnc/qvncintegration.cpp | 22 +++++++- src/plugins/platforms/vnc/qvncintegration.h | 2 + 7 files changed, 100 insertions(+), 33 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index dd25cd4..bd72663 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -400,6 +400,12 @@ QWidget *QApplication::topLevelAt(const QPoint &pos) QList::const_iterator screen = screens.constBegin(); QList::const_iterator end = screens.constEnd(); + // The first screen in a virtual environment should know about all top levels + if (pi->isVirtualDesktop()) { + QWidget *w = (*screen)->topLevelAt(pos); + return w; + } + while (screen != end) { if ((*screen)->geometry().contains(pos)) return (*screen)->topLevelAt(pos); diff --git a/src/gui/kernel/qdesktopwidget_lite.cpp b/src/gui/kernel/qdesktopwidget_lite.cpp index 3e37faf..52c1b17 100644 --- a/src/gui/kernel/qdesktopwidget_lite.cpp +++ b/src/gui/kernel/qdesktopwidget_lite.cpp @@ -71,9 +71,19 @@ void QDesktopWidgetPrivate::updateScreenList() } } + QRegion virtualGeometry; + bool doVirtualGeometry = QApplicationPrivate::platformIntegration()->isVirtualDesktop(); + // update the geometry of each screen widget for (int i = 0; i < screens.length(); i++) { - screens.at(i)->setGeometry(screenList.at(i)->geometry()); + QRect screenGeometry = screenList.at(i)->geometry(); + screens.at(i)->setGeometry(screenGeometry); + if (doVirtualGeometry) + virtualGeometry += screenGeometry; + } + + if (doVirtualGeometry) { + virtualScreen.setGeometry(virtualGeometry.boundingRect()); } } @@ -106,6 +116,8 @@ int QDesktopWidget::numScreens() const QWidget *QDesktopWidget::screen(int screen) { Q_D(QDesktopWidget); + if (QApplicationPrivate::platformIntegration()->isVirtualDesktop()) + return &d->virtualScreen; if (screen < 0 || screen >= d->screens.length()) return d->screens.at(0); return d->screens.at(screen); diff --git a/src/gui/kernel/qdesktopwidget_lite_p.h b/src/gui/kernel/qdesktopwidget_lite_p.h index c04e172..2f7ad52 100644 --- a/src/gui/kernel/qdesktopwidget_lite_p.h +++ b/src/gui/kernel/qdesktopwidget_lite_p.h @@ -59,7 +59,7 @@ class QDesktopScreenWidget : public QWidget { Q_OBJECT public: - QDesktopScreenWidget(int screenNumber) { setWindowFlags(Qt::Desktop); setVisible(false); d_func()->screenNumber = screenNumber; } + QDesktopScreenWidget(int screenNumber = -1) { setWindowFlags(Qt::Desktop); setVisible(false); d_func()->screenNumber = screenNumber; } }; class QDesktopWidgetPrivate : public QWidgetPrivate { @@ -69,6 +69,7 @@ public: void updateScreenList(); QList screens; + QDesktopScreenWidget virtualScreen; }; #endif // QDESKTOPWIDGET_LITE_P_H diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index 5004a5a..be4a530 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -162,8 +162,9 @@ void QFbScreen::generateRects() continue; if (!windowStack[i]->widget()->testAttribute(Qt::WA_TranslucentBackground)) { - remainingScreen -= windowStack[i]->localGeometry(); - QRegion windowRegion(windowStack[i]->localGeometry()); + QRect localGeometry = windowStack.at(i)->geometry().translated(-screenOffset); // global to local translation + remainingScreen -= localGeometry; + QRegion windowRegion(localGeometry); windowRegion -= remainingScreen; foreach(QRect rect, windowRegion.rects()) { cachedRects += QPair(rect, i); @@ -180,7 +181,7 @@ void QFbScreen::generateRects() QRegion QFbScreen::doRedraw() { - QPoint screenOffset = mGeometry.topLeft(); // optimize me! + QPoint screenOffset = mGeometry.topLeft(); QRegion touchedRegion; if (cursor && cursor->isDirty() && cursor->isOnScreen()) { @@ -257,9 +258,7 @@ QRegion QFbScreen::doRedraw() void QFbScreen::addWindow(QFbWindow *surface) { windowStack.prepend(surface); - surface->mScreen = this; - QPoint screenOffset = mGeometry.topLeft(); - surface->localGeometry() = surface->geometry().translated(-screenOffset); // global to local translation + surface->mScreens.append(this); invalidateRectCache(); setDirty(surface->geometry()); } @@ -267,13 +266,19 @@ void QFbScreen::addWindow(QFbWindow *surface) void QFbScreen::removeWindow(QFbWindow * surface) { windowStack.removeOne(surface); + surface->mScreens.removeOne(this); invalidateRectCache(); setDirty(surface->geometry()); } void QFbWindow::raise() { - mScreen->raise(this); + QList::const_iterator i = mScreens.constBegin(); + QList::const_iterator end = mScreens.constEnd(); + while (i != end) { + (*i)->raise(this); + ++i; + } } void QFbScreen::raise(QPlatformWindow * surface) @@ -289,7 +294,12 @@ void QFbScreen::raise(QPlatformWindow * surface) void QFbWindow::lower() { - mScreen->lower(this); + QList::const_iterator i = mScreens.constBegin(); + QList::const_iterator end = mScreens.constEnd(); + while (i != end) { + (*i)->lower(this); + ++i; + } } void QFbScreen::lower(QPlatformWindow * surface) @@ -315,9 +325,8 @@ QWidget * QFbScreen::topLevelAt(const QPoint & p) const return 0; } -QFbWindow::QFbWindow(QFbScreen *screen, QWidget *window) +QFbWindow::QFbWindow(QWidget *window) :QPlatformWindow(window), - mScreen(screen), visibleFlag(false) { static QAtomicInt winIdGenerator(1); @@ -327,7 +336,12 @@ QFbWindow::QFbWindow(QFbScreen *screen, QWidget *window) QFbWindow::~QFbWindow() { - mScreen->removeWindow(this); + QList::const_iterator i = mScreens.constBegin(); + QList::const_iterator end = mScreens.constEnd(); + while (i != end) { + (*i)->removeWindow(this); + ++i; + } } @@ -361,18 +375,23 @@ void QFbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoin void QFbWindow::repaint(const QRegion ®ion) { QRect currentGeometry = geometry(); - // If this is a move, redraw the previous location - if (oldGeometry != currentGeometry) { - mScreen->setDirty(oldGeometry); - oldGeometry = currentGeometry; - } QRect dirtyClient = region.boundingRect(); QRect dirtyRegion(currentGeometry.left() + dirtyClient.left(), currentGeometry.top() + dirtyClient.top(), dirtyClient.width(), dirtyClient.height()); - mScreen->setDirty(dirtyRegion); + QList::const_iterator i = mScreens.constBegin(); + QList::const_iterator end = mScreens.constEnd(); + while (i != end) { + // If this is a move, redraw the previous location + if (oldGeometry != currentGeometry) { + (*i)->setDirty(oldGeometry); + oldGeometry = currentGeometry; + } + (*i)->setDirty(dirtyRegion); + ++i; + } } void QFbWindowSurface::resize(const QSize &size) @@ -389,13 +408,15 @@ void QFbWindow::setGeometry(const QRect &rect) oldGeometry = geometry(); - mScreen->invalidateRectCache(); + QList::const_iterator i = mScreens.constBegin(); + QList::const_iterator end = mScreens.constEnd(); + while (i != end) { + (*i)->invalidateRectCache(); + ++i; + } //### QWindowSystemInterface::handleGeometryChange(window(), rect); QPlatformWindow::setGeometry(rect); - - QPoint screenOffset = mScreen->geometry().topLeft(); - mLocalGeometry = rect.translated(-screenOffset); // global to local translation } bool QFbWindowSurface::scroll(const QRegion &area, int dx, int dy) @@ -416,14 +437,24 @@ void QFbWindowSurface::endPaint(const QRegion ®ion) void QFbWindow::setVisible(bool visible) { visibleFlag = visible; - mScreen->invalidateRectCache(); - mScreen->setDirty(geometry()); + QList::const_iterator i = mScreens.constBegin(); + QList::const_iterator end = mScreens.constEnd(); + while (i != end) { + (*i)->invalidateRectCache(); + (*i)->setDirty(geometry()); + ++i; + } } Qt::WindowFlags QFbWindow::setWindowFlags(Qt::WindowFlags type) { flags = type; - mScreen->invalidateRectCache(); + QList::const_iterator i = mScreens.constBegin(); + QList::const_iterator end = mScreens.constEnd(); + while (i != end) { + (*i)->invalidateRectCache(); + ++i; + } return flags; } diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index 124dde0..3b5075d 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -80,7 +80,7 @@ class QFbWindow : public QPlatformWindow { public: - QFbWindow(QFbScreen *screen, QWidget *window); + QFbWindow(QWidget *window); ~QFbWindow(); @@ -99,17 +99,14 @@ public: virtual void repaint(const QRegion&); - virtual QRect localGeometry() { return mLocalGeometry; } - protected: friend class QFbWindowSurface; friend class QFbScreen; QFbWindowSurface *surface; - QFbScreen *mScreen; + QList mScreens; QRect oldGeometry; bool visibleFlag; Qt::WindowFlags flags; - QRect mLocalGeometry; // local screen coordinates WId windowId; }; diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp index de6d81f..2ae34dc 100644 --- a/src/plugins/platforms/vnc/qvncintegration.cpp +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -95,6 +95,7 @@ static void usage() } QVNCIntegration::QVNCIntegration(const QStringList& paramList) + : virtualDesktop(false) { int sizeX = defaultWidth(); int sizeY = defaultHeight(); @@ -125,6 +126,9 @@ QVNCIntegration::QVNCIntegration(const QStringList& paramList) screen->setDirty(screenRect); ++display; } + else if (confString == QLatin1String("virtual")) { + virtualDesktop = true; + } else { qWarning() << "Unknown VNC option:" << confString; showUsage = true; @@ -167,13 +171,27 @@ QWindowSurface *QVNCIntegration::createWindowSurface(QWidget *widget, WId) const QPlatformWindow *QVNCIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const { - QFbWindow *w = new QFbWindow(mPrimaryScreen, widget); - mPrimaryScreen->addWindow(w); + QFbWindow *w = new QFbWindow(widget); + if (virtualDesktop) { + QList::const_iterator i = mScreens.constBegin(); + QList::const_iterator end = mScreens.constEnd(); + QFbScreen *screen; + while (i != end) { + screen = static_cast(*i); + screen->addWindow(w); + ++i; + } + } + else + mPrimaryScreen->addWindow(w); return w; } void QVNCIntegration::moveToScreen(QWidget *window, int screen) { + if (virtualDesktop) { // all windows exist on all screens in virtual desktop mode + return; + } if (screen < 0 || screen > mScreens.size()) return; QVNCScreen * newScreen = qobject_cast(mScreens.at(screen)); diff --git a/src/plugins/platforms/vnc/qvncintegration.h b/src/plugins/platforms/vnc/qvncintegration.h index 3436e51..d49e051 100644 --- a/src/plugins/platforms/vnc/qvncintegration.h +++ b/src/plugins/platforms/vnc/qvncintegration.h @@ -86,11 +86,13 @@ public: QList screens() const { return mScreens; } + bool isVirtualDesktop() { return virtualDesktop; } void moveToScreen(QWidget *window, int screen); private: QVNCScreen *mPrimaryScreen; QList mScreens; + bool virtualDesktop; }; -- cgit v0.12 From 853c01fe35431f78f2d3191b1592cc616c03ee09 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 15 Jun 2010 13:20:33 +0200 Subject: LinuxFB compilation fix --- src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp index 391e105..f79f956 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp @@ -794,7 +794,7 @@ QWindowSurface *QLinuxFbIntegration::createWindowSurface(QWidget *widget, WId) c QPlatformWindow *QLinuxFbIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const { - QFbWindow *w = new QFbWindow(mPrimaryScreen, widget); + QFbWindow *w = new QFbWindow(widget); mPrimaryScreen->addWindow(w); return w; } -- cgit v0.12 From 598455952bee3931934820db1dfe9e9ce4dc0388 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 15 Jun 2010 13:49:41 +0200 Subject: fix repaint of resized widgets that span multiple screens --- src/plugins/platforms/fb_base/fb_base.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index be4a530..d63bfce 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -383,11 +383,13 @@ void QFbWindow::repaint(const QRegion ®ion) dirtyClient.height()); QList::const_iterator i = mScreens.constBegin(); QList::const_iterator end = mScreens.constEnd(); + QRect oldGeometryLocal = oldGeometry; + oldGeometry = currentGeometry; while (i != end) { // If this is a move, redraw the previous location - if (oldGeometry != currentGeometry) { - (*i)->setDirty(oldGeometry); - oldGeometry = currentGeometry; + if (oldGeometryLocal != currentGeometry) { + qDebug() << "repaint old area on screen" << (*i)->objectName(); + (*i)->setDirty(oldGeometryLocal); } (*i)->setDirty(dirtyRegion); ++i; -- cgit v0.12 From 7722d8c5f9871dfd09a298b4be243af6808407f1 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 15 Jun 2010 15:00:42 +0200 Subject: fix minimizing VNC and LinuxFB top levels --- src/plugins/platforms/fb_base/fb_base.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index d63bfce..3b69550 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -160,6 +160,8 @@ void QFbScreen::generateRects() break; if (!windowStack[i]->visible()) continue; + if (windowStack[i]->widget()->isMinimized()) + continue; if (!windowStack[i]->widget()->testAttribute(Qt::WA_TranslucentBackground)) { QRect localGeometry = windowStack.at(i)->geometry().translated(-screenOffset); // global to local translation -- cgit v0.12 From 5343c882496586a73b7e0071178866b14b1dde8f Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 16 Jun 2010 12:47:23 +0200 Subject: Set the desktop widget geometry to reflect the size of the screen(s) Also removed a stray debug message --- src/gui/kernel/qdesktopwidget_lite.cpp | 6 +++--- src/plugins/platforms/fb_base/fb_base.cpp | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qdesktopwidget_lite.cpp b/src/gui/kernel/qdesktopwidget_lite.cpp index 52c1b17..553173b 100644 --- a/src/gui/kernel/qdesktopwidget_lite.cpp +++ b/src/gui/kernel/qdesktopwidget_lite.cpp @@ -82,15 +82,15 @@ void QDesktopWidgetPrivate::updateScreenList() virtualGeometry += screenGeometry; } - if (doVirtualGeometry) { - virtualScreen.setGeometry(virtualGeometry.boundingRect()); - } + virtualScreen.setGeometry(virtualGeometry.boundingRect()); } QDesktopWidget::QDesktopWidget() : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop) { + Q_D(QDesktopWidget); setObjectName(QLatin1String("desktop")); + this->setGeometry(d->virtualScreen.geometry()); } QDesktopWidget::~QDesktopWidget() diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index 3b69550..213a710 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -390,7 +390,6 @@ void QFbWindow::repaint(const QRegion ®ion) while (i != end) { // If this is a move, redraw the previous location if (oldGeometryLocal != currentGeometry) { - qDebug() << "repaint old area on screen" << (*i)->objectName(); (*i)->setDirty(oldGeometryLocal); } (*i)->setDirty(dirtyRegion); -- cgit v0.12 From fef040c3b697f5a14b06c63858a5832e1e833abb Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 16 Jun 2010 14:45:40 +0200 Subject: Disable Qt3Support for Lighthouse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This turns it off hard, ignoring configure options to the contrary. Reviewed-by: Jørgen --- configure | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure b/configure index da34fb5..9db16e3 100755 --- a/configure +++ b/configure @@ -2322,6 +2322,11 @@ if [ "$CFG_GUI" = "no" ]; then CFG_QT3SUPPORT="no" fi +#disable Qt3Support for Lighthouse +if [ "$PLATFORM_EMBLITE" = "yes" ]; then + CFG_QT3SUPPORT="no" +fi + # update QT_CONFIG to show our current predefined configuration case "$CFG_QCONFIG" in minimal|small|medium|large|full) -- cgit v0.12 From c12c0186a0ecdf43f8d0dcfc1d8bea704a4fe32b Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 16 Jun 2010 15:34:25 +0200 Subject: update QDesktopWidget geometry when screens are added, removed, or resized --- src/gui/kernel/qdesktopwidget_lite.cpp | 4 +++- src/gui/kernel/qdesktopwidget_lite_p.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qdesktopwidget_lite.cpp b/src/gui/kernel/qdesktopwidget_lite.cpp index 553173b..6ba5dd9 100644 --- a/src/gui/kernel/qdesktopwidget_lite.cpp +++ b/src/gui/kernel/qdesktopwidget_lite.cpp @@ -83,6 +83,8 @@ void QDesktopWidgetPrivate::updateScreenList() } virtualScreen.setGeometry(virtualGeometry.boundingRect()); + Q_Q(QDesktopWidget); + q->setGeometry(virtualScreen.geometry()); } QDesktopWidget::QDesktopWidget() @@ -90,7 +92,7 @@ QDesktopWidget::QDesktopWidget() { Q_D(QDesktopWidget); setObjectName(QLatin1String("desktop")); - this->setGeometry(d->virtualScreen.geometry()); + d->updateScreenList(); } QDesktopWidget::~QDesktopWidget() diff --git a/src/gui/kernel/qdesktopwidget_lite_p.h b/src/gui/kernel/qdesktopwidget_lite_p.h index 2f7ad52..33e4c98 100644 --- a/src/gui/kernel/qdesktopwidget_lite_p.h +++ b/src/gui/kernel/qdesktopwidget_lite_p.h @@ -63,8 +63,9 @@ public: }; class QDesktopWidgetPrivate : public QWidgetPrivate { + Q_DECLARE_PUBLIC(QDesktopWidget) + public: - QDesktopWidgetPrivate() { updateScreenList(); } ~QDesktopWidgetPrivate() {foreach(QDesktopScreenWidget *s, screens) delete s; } void updateScreenList(); -- cgit v0.12 From c28069a0c4d54d1c8a63bb17bb30ef45e7cf47a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 17 Jun 2010 10:23:57 +0200 Subject: Adding support for setParent api in plugins This is work in progress, but boxes and wolfenqt works in testlite:) --- src/gui/kernel/qplatformwindow_lite.cpp | 2 + src/gui/kernel/qplatformwindow_lite.h | 1 + src/gui/kernel/qwidget_lite.cpp | 45 ++++++++++++++++------ src/plugins/platforms/testlite/qtestlitewindow.cpp | 22 ++++++++--- src/plugins/platforms/testlite/qtestlitewindow.h | 1 + 5 files changed, 54 insertions(+), 17 deletions(-) diff --git a/src/gui/kernel/qplatformwindow_lite.cpp b/src/gui/kernel/qplatformwindow_lite.cpp index 151e93d..9efbf8b 100644 --- a/src/gui/kernel/qplatformwindow_lite.cpp +++ b/src/gui/kernel/qplatformwindow_lite.cpp @@ -65,6 +65,8 @@ Qt::WindowFlags QPlatformWindow::windowFlags() const WId QPlatformWindow::winId() const { return WId(0); } +void QPlatformWindow::setParent(const QPlatformWindow *) { qWarning("This plugin does not support setParent!"); } + void QPlatformWindow::setWindowTitle(const QString &) {} void QPlatformWindow::raise() { qWarning("This plugin does not support raise()"); } diff --git a/src/gui/kernel/qplatformwindow_lite.h b/src/gui/kernel/qplatformwindow_lite.h index 0a94fc0..5f8d259 100644 --- a/src/gui/kernel/qplatformwindow_lite.h +++ b/src/gui/kernel/qplatformwindow_lite.h @@ -71,6 +71,7 @@ public: virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); virtual Qt::WindowFlags windowFlags() const; virtual WId winId() const; + virtual void setParent(const QPlatformWindow *window); virtual void setWindowTitle(const QString &); virtual void raise(); diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index e1a8d0d..445e166 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -85,6 +85,17 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO setWinId(q->platformWindow()->winId()); + QObjectList children = q->children(); + for (int i = 0; i < children.size(); i++) { + if (children.at(i)->isWidgetType()) { + const QWidget *childWidget = qobject_cast(children.at(i)); + QPlatformWindow *childWindow = childWidget->platformWindow(); + if (childWindow) { + childWindow->setParent(platformWindow); + } + } + } + QApplicationPrivate::platformIntegration()->moveToScreen(q, screenNumber); // qDebug() << "create_sys" << q << q->internalWinId(); } @@ -92,6 +103,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO void QWidget::destroy(bool destroyWindow, bool destroySubWindows) { Q_D(QWidget); + //### jl: subwindows now enabled Q_UNUSED(destroySubWindows); if ((windowType() == Qt::Popup)) @@ -137,6 +149,13 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) if (parent != newparent) { QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? + if (q->platformWindow()) { + QWidget * parentWithWindow = newparent->platformWindow()? newparent : newparent->nativeParentWidget(); + if (parentWithWindow && parentWithWindow->platformWindow()) { + q->platformWindow()->setParent(parentWithWindow->platformWindow()); + } + } + } if (!newparent) { @@ -167,6 +186,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) qDebug() << "######## setParent_sys() change from toplevel not implemented ########"; } + if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden) q->setAttribute(Qt::WA_WState_Hidden); q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); @@ -340,25 +360,26 @@ void QWidgetPrivate::show_sys() QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); - if (!q->isWindow()) - return; - - if (QPlatformWindow *window = q->platformWindow()) { + QPlatformWindow *window = q->platformWindow(); + if (window) { const QRect geomRect = q->geometry(); const QRect windowRect = window->geometry(); if (windowRect != geomRect) { - q->platformWindow()->setGeometry(geomRect); + window->setGeometry(geomRect); + } + if (q->isWindow()) { if (QWindowSurface *surface = q->windowSurface()) if (windowRect.size() != geomRect.size()) { surface->resize(geomRect.size()); } - } - q->platformWindow()->setVisible(true); - } + if (window) + window->setVisible(true); - if (q->windowType() != Qt::Popup && q->windowType() != Qt::ToolTip && !(q->windowFlags() & Qt::X11BypassWindowManagerHint)) - q->activateWindow(); //### + if (q->windowType() != Qt::Popup && q->windowType() != Qt::ToolTip && !(q->windowFlags() & Qt::X11BypassWindowManagerHint)) + q->activateWindow(); //### + } + } } @@ -540,10 +561,10 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (q->isVisible()) { - if (q->isWindow()) { + if (q->platformWindow()) { + q->platformWindow()->setGeometry(q->frameGeometry()); const QWidgetBackingStore *bs = maybeBackingStore(); if (bs->windowSurface) { - q->platformWindow()->setGeometry(q->frameGeometry()); if (isResize) bs->windowSurface->resize(r.size()); } diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index 4ddb7ca..2737db0 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -623,11 +623,6 @@ void QTestLiteWindow::handleKeyEvent(QEvent::Type type, void *ev) void QTestLiteWindow::setGeometry(const QRect &rect) { - QRect oldRect = geometry(); - if (rect == oldRect) - return; - - //if unchanged ### XMoveResizeWindow(xd->display, x_window, rect.x(), rect.y(), rect.width(), rect.height()); QPlatformWindow::setGeometry(rect); } @@ -643,6 +638,23 @@ WId QTestLiteWindow::winId() const return x_window; } +void QTestLiteWindow::setParent(const QPlatformWindow *window) +{ + /******** Cleaning up **********/ + Window parentXWindow, rootXWindow; + Window *children; + unsigned int nChildren; + if (XQueryTree(xd->display, x_window, &rootXWindow, &parentXWindow, &children, &nChildren)) { + if (parentXWindow) { + XUnmapWindow(xd->display, x_window); + XReparentWindow(xd->display, x_window, rootXWindow, 0, 0); + } + } + /******* Done cleaning up ********/ + XReparentWindow(xd->display,x_window,window->winId(),geometry().x(),geometry().y()); + XMapWindow(xd->display, x_window); +} + void QTestLiteWindow::raise() { XRaiseWindow(xd->display, x_window); diff --git a/src/plugins/platforms/testlite/qtestlitewindow.h b/src/plugins/platforms/testlite/qtestlitewindow.h index 5d27f3a..d405578 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.h +++ b/src/plugins/platforms/testlite/qtestlitewindow.h @@ -120,6 +120,7 @@ public: Qt::WindowFlags windowFlags() const; void setVisible(bool visible); WId winId() const; + void setParent(const QPlatformWindow *window); void raise(); void lower(); void setWindowTitle(const QString &title); -- cgit v0.12 From 793d1ed8d3a03eefdd487facdacf66ba575e1a07 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 17 Jun 2010 14:16:06 +0200 Subject: Tslib mouse input for Lighthouse --- src/plugins/generic/tslib/main.cpp | 78 +++++++++++++++++++ src/plugins/generic/tslib/qtslib.cpp | 144 +++++++++++++++++++++++++++++++++++ src/plugins/generic/tslib/qtslib.h | 77 +++++++++++++++++++ src/plugins/generic/tslib/tslib.pro | 13 ++++ 4 files changed, 312 insertions(+) create mode 100644 src/plugins/generic/tslib/main.cpp create mode 100644 src/plugins/generic/tslib/qtslib.cpp create mode 100644 src/plugins/generic/tslib/qtslib.h create mode 100644 src/plugins/generic/tslib/tslib.pro diff --git a/src/plugins/generic/tslib/main.cpp b/src/plugins/generic/tslib/main.cpp new file mode 100644 index 0000000..4e8e50a --- /dev/null +++ b/src/plugins/generic/tslib/main.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 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 +#include "qtslib.h" + +QT_BEGIN_NAMESPACE + +class QTsLibPlugin : public QGenericPlugin +{ +public: + QTsLibPlugin(); + + QStringList keys() const; + QObject* create(const QString &key, const QString &specification); +}; + +QTsLibPlugin::QTsLibPlugin() + : QGenericPlugin() +{ +} + +QStringList QTsLibPlugin::keys() const +{ + return (QStringList() + << QLatin1String("Tslib") + << QLatin1String("TslibRaw")); +} + +QObject* QTsLibPlugin::create(const QString &key, + const QString &specification) +{ + if (!key.compare(QLatin1String("Tslib"), Qt::CaseInsensitive) || !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive)) + return new QTsLibMouseHandler(key, specification); + return 0; + } + +Q_EXPORT_PLUGIN2(qtslibplugin, QTsLibPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/generic/tslib/qtslib.cpp b/src/plugins/generic/tslib/qtslib.cpp new file mode 100644 index 0000000..12963a0 --- /dev/null +++ b/src/plugins/generic/tslib/qtslib.cpp @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** 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 "qtslib.h" + + +#include +#include +#include +#include + +#include + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +QTsLibMouseHandler::QTsLibMouseHandler(const QString &key, + const QString &specification) + : m_notify(0), m_x(0), m_y(0), m_pressed(0), m_rawMode(false) +{ + qDebug() << "QTsLibMouseHandler" << key << specification; + setObjectName(QLatin1String("TSLib Mouse Handler")); + + QByteArray device = "/dev/input/event1"; + if (specification.startsWith("/dev/")) + device = specification.toLocal8Bit(); + + m_dev = ts_open(device.constData(), 1); + + if (ts_config(m_dev)) { + perror("Error configuring\n"); + } + + + m_rawMode = !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive); + + int fd = ts_fd(m_dev); + if (fd >= 0) { + m_notify = new QSocketNotifier(fd, QSocketNotifier::Read, this); + connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData())); + } else { + qWarning("Cannot open mouse input device '%s': %s", device.constData(), strerror(errno)); + return; + } +} + + +QTsLibMouseHandler::~QTsLibMouseHandler() +{ + if (m_dev) + ts_close(m_dev); +} + + +static bool get_sample(struct tsdev *dev, struct ts_sample *sample, bool rawMode) +{ + if (rawMode) { + return (ts_read_raw(dev, sample, 1) == 1); + } else { + int ret = ts_read(dev, sample, 1); + return ( ret == 1); + } +} + + +void QTsLibMouseHandler::readMouseData() +{ + ts_sample sample; + while (get_sample(m_dev, &sample, m_rawMode)) { + + bool pressed = sample.pressure; + int x = sample.x; + int y = sample.y; + + + if (!m_rawMode) { + //filtering: ignore movements of 2 pixels or less + int dx = x - m_x; + int dy = y - m_y; + if (dx*dx <= 4 && dy*dy <= 4 && pressed == m_pressed) + continue; + } else { + // work around missing coordinates on mouse release in raw mode + if (sample.pressure == 0 && sample.x == 0 && sample.y == 0) { + x = m_x; + y = m_y; + } + } + QPoint pos(x, y); + + //printf("handleMouseEvent %d %d %d %ld\n", m_x, m_y, pressed, sample.tv.tv_usec); + + QWindowSystemInterface::handleMouseEvent(0, pos, pos, pressed ? Qt::LeftButton : Qt::NoButton); + + m_x = x; + m_y = y; + m_pressed = pressed; + } +} + +QT_END_NAMESPACE diff --git a/src/plugins/generic/tslib/qtslib.h b/src/plugins/generic/tslib/qtslib.h new file mode 100644 index 0000000..5eab8b9 --- /dev/null +++ b/src/plugins/generic/tslib/qtslib.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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 QTSLIB_H +#define QTSLIB_H + +#include +//#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QSocketNotifier; +struct tsdev; + +class QTsLibMouseHandler : public QObject +{ + Q_OBJECT +public: + QTsLibMouseHandler(const QString &key, const QString &specification); + ~QTsLibMouseHandler(); + +private slots: + void readMouseData(); + +private: + QSocketNotifier * m_notify; + tsdev *m_dev; + int m_x, m_y; + bool m_pressed; + bool m_rawMode; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QTSLIB_H diff --git a/src/plugins/generic/tslib/tslib.pro b/src/plugins/generic/tslib/tslib.pro new file mode 100644 index 0000000..74c7fd2 --- /dev/null +++ b/src/plugins/generic/tslib/tslib.pro @@ -0,0 +1,13 @@ +TARGET = qlinuxinputplugin +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/generic +target.path = $$[QT_INSTALL_PLUGINS]/generic +INSTALLS += target + +HEADERS = qtslib.h + +SOURCES = main.cpp \ + qtslib.cpp + +LIBS += -lts -- cgit v0.12 From 3566ab0c99056f20964f5586b5f7a1b92c095579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Mon, 21 Jun 2010 13:19:27 +0200 Subject: Compile testlite plugin without OpenGL (QT_NO_OPENGL). Reviewed-by: jorgen --- src/plugins/platforms/testlite/qtestliteintegration.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/testlite/qtestliteintegration.cpp b/src/plugins/platforms/testlite/qtestliteintegration.cpp index 3ce9b7c..46f2384 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.cpp +++ b/src/plugins/platforms/testlite/qtestliteintegration.cpp @@ -109,16 +109,19 @@ QTestLiteIntegration::QTestLiteIntegration(bool useOpenGL) QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type) const { +#ifndef QT_NO_OPENGL if (mUseOpenGL) return new QGLPixmapData(type); +#endif return new QRasterPixmapData(type); } QWindowSurface *QTestLiteIntegration::createWindowSurface(QWidget *widget, WId) const { +#ifndef QT_NO_OPENGL if (mUseOpenGL) return new QGLWindowSurface(widget); - +#endif return new QTestLiteWindowSurface(mPrimaryScreen, widget); } @@ -138,7 +141,10 @@ QPixmap QTestLiteIntegration::grabWindow(WId window, int x, int y, int width, in bool QTestLiteIntegration::hasOpenGL() const { +#ifndef QT_NO_OPENGL return glXQueryExtension(xd->display, 0, 0) != 0; +#endif + return false; } QT_END_NAMESPACE -- cgit v0.12 From 220174b663a2b4db94fc82feba6939b0bef52aa2 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 21 Jun 2010 17:38:19 +0200 Subject: document VNC options for multiple screens --- src/plugins/platforms/vnc/qvncintegration.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp index 2ae34dc..16fa5bb 100644 --- a/src/plugins/platforms/vnc/qvncintegration.cpp +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -92,6 +92,11 @@ static void usage() qWarning() << " defaults to" << defaultWidth() << "x" << defaultHeight(); qWarning() << " display= - set the VNC display port to ID + 5900"; qWarning() << " defaults to" << defaultDisplay(); + qWarning() << " offset=x - set the current screens offset"; + qWarning() << " vnc - start configuration of a new screen"; + qWarning() << " size and offset are inherited from the previous screen if not set"; + qWarning() << " display id is incremented from the previous screen if not set"; + qWarning() << " virtual - manage the set of screens as a virtual desktop"; } QVNCIntegration::QVNCIntegration(const QStringList& paramList) -- cgit v0.12 From dbbc370400922cf9963a9a80ac0d1396450e8ef3 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 21 Jun 2010 14:31:36 +0200 Subject: Copied VNC crash fixes from QWS Copied from commit 71b840ef81a9 and commit 57fcc060f --- src/plugins/platforms/vnc/qvncserver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp index fb6eaa8..288d1bc 100644 --- a/src/plugins/platforms/vnc/qvncserver.cpp +++ b/src/plugins/platforms/vnc/qvncserver.cpp @@ -889,7 +889,7 @@ void QVNCServer::clientCutText() { QRfbClientCutText ev; - if (ev.read(client)) { + if (cutTextPending == 0 && ev.read(client)) { cutTextPending = ev.length; if (!cutTextPending) handleMsg = false; @@ -1317,7 +1317,7 @@ void QVNCServer::convertPixels(char *dst, const char *src, int count) const } if (count & 0x1) { const quint16 *src16 = reinterpret_cast(src); - dst32[count - 1] = qt_conv16ToRgb(src16[count - 1]); + *dst32 = qt_conv16ToRgb(src16[count - 1]); } return; #endif -- cgit v0.12 From 7e5ddd5ffb23fa5ebd33b747f28ee20647b9325b Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 21 Jun 2010 17:30:47 +0200 Subject: Support multiple display IDs for Lighthouse QVFb plugin --- src/plugins/platforms/qvfb/main.cpp | 2 +- src/plugins/platforms/qvfb/qvfbintegration.cpp | 35 ++++++++++++++------------ src/plugins/platforms/qvfb/qvfbintegration.h | 4 +-- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/plugins/platforms/qvfb/main.cpp b/src/plugins/platforms/qvfb/main.cpp index 206ece8..997e544 100644 --- a/src/plugins/platforms/qvfb/main.cpp +++ b/src/plugins/platforms/qvfb/main.cpp @@ -63,7 +63,7 @@ QPlatformIntegration* QVFbIntegrationPlugin::create(const QString& system, const { Q_UNUSED(paramList); if (system.toLower() == "qvfb") - return new QVFbIntegration; + return new QVFbIntegration(paramList); return 0; } diff --git a/src/plugins/platforms/qvfb/qvfbintegration.cpp b/src/plugins/platforms/qvfb/qvfbintegration.cpp index 84ab9fb..a50763a 100644 --- a/src/plugins/platforms/qvfb/qvfbintegration.cpp +++ b/src/plugins/platforms/qvfb/qvfbintegration.cpp @@ -69,7 +69,7 @@ class QVFbScreenKeyboardHandler : public QObject { Q_OBJECT public: - QVFbScreenKeyboardHandler(); + QVFbScreenKeyboardHandler(int displayId); ~QVFbScreenKeyboardHandler(); private slots: @@ -83,9 +83,8 @@ private: QSocketNotifier *keyNotifier; }; -QVFbScreenKeyboardHandler::QVFbScreenKeyboardHandler() +QVFbScreenKeyboardHandler::QVFbScreenKeyboardHandler(int displayId) { - int displayId = 0; //TODO displayId const QString keyboardDev = QT_VFB_KEYBOARD_PIPE(displayId); @@ -165,7 +164,7 @@ class QVFbScreenMouseHandler : public QObject { Q_OBJECT public: - QVFbScreenMouseHandler(); + QVFbScreenMouseHandler(int displayId); ~QVFbScreenMouseHandler(); private slots: @@ -181,9 +180,8 @@ private: int oldButtonState; }; -QVFbScreenMouseHandler::QVFbScreenMouseHandler() +QVFbScreenMouseHandler::QVFbScreenMouseHandler(int displayId) { - int displayId = 0; //TODO: displayId QString mouseDev = QT_VFB_MOUSE_PIPE(displayId); mouseFD = QT_OPEN(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY); @@ -257,10 +255,11 @@ void QVFbScreenMouseHandler::readMouseData() class QVFbScreenPrivate { public: - QVFbScreenPrivate(QVFbScreen *) + QVFbScreenPrivate(int id) : shmrgn(0), hdr(0), data(0), mouseHandler(0), keyboardHandler(0) { - connect(0); //for now we only handle one screen + displayId = id; + connect(displayId); } ~QVFbScreenPrivate() { disconnect(); } @@ -281,7 +280,7 @@ private: uchar *data; QVFbScreenMouseHandler *mouseHandler; QVFbScreenKeyboardHandler *keyboardHandler; - + int displayId; QImage img; }; @@ -296,7 +295,7 @@ void QVFbScreenPrivate::setDirty(const QRect &r) bool QVFbScreenPrivate::connect(int displayId) { - + qDebug() << "QVFbScreenPrivate::connect" << displayId; key_t key = ftok(QT_VFB_MOUSE_PIPE(displayId).toLatin1(), 'b'); if (key == -1) @@ -339,8 +338,8 @@ bool QVFbScreenPrivate::connect(int displayId) qDebug("connected %dx%d %d bpp", w, h, d); - mouseHandler = new QVFbScreenMouseHandler; - keyboardHandler = new QVFbScreenKeyboardHandler; + mouseHandler = new QVFbScreenMouseHandler(displayId); + keyboardHandler = new QVFbScreenKeyboardHandler(displayId); return true; } @@ -357,9 +356,9 @@ void QVFbScreenPrivate::disconnect() } -QVFbScreen::QVFbScreen() +QVFbScreen::QVFbScreen(int id) { - d_ptr = new QVFbScreenPrivate(this); + d_ptr = new QVFbScreenPrivate(id); } @@ -409,9 +408,13 @@ QImage *QVFbScreen::screenImage() return d_ptr->screenImage(); } -QVFbIntegration::QVFbIntegration() +QVFbIntegration::QVFbIntegration(const QStringList ¶mList) { - mPrimaryScreen = new QVFbScreen(); + int displayId = 0; + if (paramList.length() > 0) + displayId = paramList.at(0).toInt(); + + mPrimaryScreen = new QVFbScreen(displayId); mScreens.append(mPrimaryScreen); } diff --git a/src/plugins/platforms/qvfb/qvfbintegration.h b/src/plugins/platforms/qvfb/qvfbintegration.h index ab44d46..e46e0da 100644 --- a/src/plugins/platforms/qvfb/qvfbintegration.h +++ b/src/plugins/platforms/qvfb/qvfbintegration.h @@ -53,7 +53,7 @@ class QVFbScreenPrivate; class QVFbScreen : public QPlatformScreen { public: - QVFbScreen(); + QVFbScreen(int id); ~QVFbScreen(); QRect geometry() const; @@ -76,7 +76,7 @@ class QVFbIntegrationPrivate; class QVFbIntegration : public QPlatformIntegration { public: - QVFbIntegration(); + QVFbIntegration(const QStringList ¶mList); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; -- cgit v0.12 From a2be3a026b1a18a14782c11fd89427e707b0d270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Mon, 21 Jun 2010 18:34:41 +0200 Subject: Remove unused function (declared, but not implemented). Doesn't compile on the Mac without this fix. Reviewed-by: Paul --- src/plugins/platforms/vnc/qvncserver.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/platforms/vnc/qvncserver.h b/src/plugins/platforms/vnc/qvncserver.h index 837f1f4..7244bdf 100644 --- a/src/plugins/platforms/vnc/qvncserver.h +++ b/src/plugins/platforms/vnc/qvncserver.h @@ -488,7 +488,6 @@ private slots: void readClient(); void checkUpdate(); void discardClient(); - void sendInputEvents(); private: void init(uint port); -- cgit v0.12 From e7a423571981294a8e0d27f041ff9296711b15e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 23 Jun 2010 13:59:39 +0200 Subject: Remove dead code (QPlatformGLWidgetSurface). Reviewed-by: jorgen --- src/opengl/qgl.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 8da48ed..f0b36f7 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -128,10 +128,6 @@ class QGLOverlayWidget; class QGLWidgetPrivate; class QGLContextPrivate; -#ifdef Q_WS_LITE -class QPlatformGLWidgetSurface; -#endif - // Namespace class: namespace QGL { @@ -539,11 +535,6 @@ public: void drawTexture(const QPointF &point, QMacCompatGLuint textureId, QMacCompatGLenum textureTarget = GL_TEXTURE_2D); #endif -#ifdef Q_WS_LITE - // Used by the platform context to get at the surface which it created for the glwidget: - QPlatformGLWidgetSurface* platformSurface(); -#endif - public Q_SLOTS: virtual void updateGL(); virtual void updateOverlayGL(); -- cgit v0.12 From c845f1ed4c35e8a626389a415a56b07d6b5b83f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 23 Jun 2010 14:33:49 +0200 Subject: Compile openkode plugin. Reviewed-by: jorgen --- .../platforms/openkode/qopenkodeglintegration.cpp | 22 ---------------------- .../platforms/openkode/qopenkodeglintegration.h | 13 +------------ .../platforms/openkode/qopenkodeintegration.cpp | 6 +----- .../platforms/openkode/qopenkodeintegration.h | 2 +- 4 files changed, 3 insertions(+), 40 deletions(-) diff --git a/src/plugins/platforms/openkode/qopenkodeglintegration.cpp b/src/plugins/platforms/openkode/qopenkodeglintegration.cpp index b0d901b..7223538 100644 --- a/src/plugins/platforms/openkode/qopenkodeglintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeglintegration.cpp @@ -147,28 +147,6 @@ void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config) eglGetError(); } -QEGLPlatformWidgetSurface::QEGLPlatformWidgetSurface() - :QPlatformGLWidgetSurface() -{ - -} -QEGLPlatformWidgetSurface::~QEGLPlatformWidgetSurface() -{ -} - -bool QEGLPlatformWidgetSurface::create(QGLWidget* widget, QGLFormat& format) -{ - return true; -} -void QEGLPlatformWidgetSurface::setGeometry(const QRect& rect) -{ - Q_UNUSED(rect); -} -bool QEGLPlatformWidgetSurface::filterEvent(QEvent *event) -{ - return QPlatformGLWidgetSurface::filterEvent(event); -} - QEGLPlatformContext::QEGLPlatformContext() { } diff --git a/src/plugins/platforms/openkode/qopenkodeglintegration.h b/src/plugins/platforms/openkode/qopenkodeglintegration.h index c3291b8..b0b7a48 100644 --- a/src/plugins/platforms/openkode/qopenkodeglintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeglintegration.h @@ -42,7 +42,7 @@ #ifndef QOPENKODEGLINTEGRATION_H #define QOPENKODEGLINTEGRATION_H -#include +#include #include #include @@ -50,17 +50,6 @@ void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLForma // Updates "format" with the parameters of the selected configuration. void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config); -class QEGLPlatformWidgetSurface : public QPlatformGLWidgetSurface -{ -public: - QEGLPlatformWidgetSurface(); - virtual ~QEGLPlatformWidgetSurface(); - - bool create(QGLWidget*, QGLFormat&); - void setGeometry(const QRect&); - bool filterEvent(QEvent *); -}; - class QEGLPlatformContext : public QPlatformGLContext { public: diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index cd957af..5e461ae 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -212,7 +212,7 @@ QPlatformWindow *QOpenKODEIntegration::createPlatformWindow(QWidget *tlw, WId ) QWindowSurface *QOpenKODEIntegration::createWindowSurface(QWidget *widget, WId wid) const { - return new QGLWindowSurface(widget); + return new QOpenKODEWindowSurface(widget, wid); } bool QOpenKODEIntegration::hasOpenGL() const @@ -223,10 +223,6 @@ QPlatformGLContext *QOpenKODEIntegration::createGLContext() { return new QEGLPlatformContext; } -QPlatformGLWidgetSurface *QOpenKODEIntegration::createGLWidgetSurface() -{ - return new QEGLPlatformWidgetSurface; -} GLuint QOpenKODEIntegration::blitterProgram() { diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h index ad6db4b..f53c520 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeintegration.h @@ -47,6 +47,7 @@ #include #include #include +#include # include @@ -83,7 +84,6 @@ public: bool hasOpenGL() const; QPlatformGLContext * createGLContext(); - QPlatformGLWidgetSurface * createGLWidgetSurface(); virtual QList screens() const { return mScreens; } -- cgit v0.12 From fe26a83447d50422c992bde6bd429ba3209a9222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 21 Jun 2010 13:36:03 +0200 Subject: Removing the default graphicsystem from lighthouse Reviewed-by: paul --- src/gui/kernel/qapplication_lite.cpp | 4 -- src/gui/kernel/qwidget_lite.cpp | 4 +- src/gui/painting/painting.pri | 6 +-- src/gui/painting/qgraphicssystem_lite.cpp | 62 --------------------------- src/gui/painting/qgraphicssystem_lite_p.h | 70 ------------------------------- 5 files changed, 4 insertions(+), 142 deletions(-) delete mode 100644 src/gui/painting/qgraphicssystem_lite.cpp delete mode 100644 src/gui/painting/qgraphicssystem_lite_p.h diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index bd72663..db31abd 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -57,7 +57,6 @@ #include #include -#include #include #include #include @@ -425,7 +424,6 @@ void QApplication::alert(QWidget *, int) static void init_platform(const QString &name) { QApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name); - QApplicationPrivate::graphics_system = new QLiteGraphicsSystem; if (!QApplicationPrivate::platform_integration) { QStringList keys = QPlatformIntegrationFactory::keys(); QString fatalMessage = @@ -444,8 +442,6 @@ static void cleanup_platform() { delete QApplicationPrivate::platform_integration; QApplicationPrivate::platform_integration = 0; - delete QApplicationPrivate::graphics_system; - QApplicationPrivate::graphics_system = 0; } static void init_plugins(const QList pluginList) diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 445e166..5380445 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -728,8 +728,8 @@ QPaintEngine *QWidget::paintEngine() const QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys() { - qFatal("CreateDefaultWindowSurface_sys should not be used on lighthouse"); - return 0; + Q_Q(QWidget); + return QApplicationPrivate::platformIntegration()->createWindowSurface(q,0); } void QWidgetPrivate::setModal_sys() diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 37de177..46be728 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -191,11 +191,9 @@ embedded_lite { SOURCES += \ painting/qcolormap_lite.cpp \ painting/qpaintdevice_lite.cpp \ - painting/qgraphicssystemcursor_lite.cpp \ - painting/qgraphicssystem_lite.cpp + painting/qgraphicssystemcursor_lite.cpp HEADERS += \ - painting/qgraphicssystemcursor_lite.h \ - painting/qgraphicssystem_lite_p.h + painting/qgraphicssystemcursor_lite.h } symbian { diff --git a/src/gui/painting/qgraphicssystem_lite.cpp b/src/gui/painting/qgraphicssystem_lite.cpp deleted file mode 100644 index 1d24129..0000000 --- a/src/gui/painting/qgraphicssystem_lite.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** 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 "qgraphicssystem_lite_p.h" -#include - -QT_BEGIN_NAMESPACE - -QPixmapData *QLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ - return QApplicationPrivate::platformIntegration()->createPixmapData(type); -} - -QWindowSurface *QLiteGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - return QApplicationPrivate::platformIntegration()->createWindowSurface(widget, widget->winId()); -} - -QBlittable *QLiteGraphicsSystem::createBlittable(const QSize &size) const -{ - return QApplicationPrivate::platformIntegration()->createBlittable(size); -} - -QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem_lite_p.h b/src/gui/painting/qgraphicssystem_lite_p.h deleted file mode 100644 index e29fa83..0000000 --- a/src/gui/painting/qgraphicssystem_lite_p.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** 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 QGRAPHICSSYSTEM_MAC_P_H -#define QGRAPHICSSYSTEM_MAC_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 "private/qgraphicssystem_p.h" - -QT_BEGIN_NAMESPACE - -class Q_GUI_EXPORT QLiteGraphicsSystem : public QGraphicsSystem -{ -public: - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - QBlittable *createBlittable(const QSize &size) const; -}; - -QT_END_NAMESPACE - -#endif -- cgit v0.12 From 57522c3c389c133343c31770950648c3cf271406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 23 Jun 2010 15:55:30 +0200 Subject: Disable the all native child widgets on lighthouse and make the mapping of native child widgets work with nativeParentWidget --- src/gui/kernel/qapplication_lite.cpp | 6 +++ src/gui/kernel/qwidget.cpp | 18 ++++----- src/gui/kernel/qwidget_lite.cpp | 44 +++++++++++++++------- src/opengl/qwindowsurface_gl.cpp | 2 +- src/plugins/platforms/testlite/qtestlitewindow.cpp | 17 ++------- 5 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index db31abd..9c36ef5 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -479,6 +479,7 @@ void qt_init(QApplicationPrivate *priv, int type) { Q_UNUSED(type); + qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); char *p; char **argv = priv->argv; int argc = priv->argc; @@ -787,6 +788,11 @@ void QApplicationPrivate::processKeyEvent(QWindowSystemInterface::KeyEvent *e) void QApplicationPrivate::processGeometryChange(QWidget *tlw, const QRect &newRect) { + if (!tlw->isWindow()) + return; //geo of native child widgets is controlled by lighthouse + //so we already have sent the events; besides this new rect + //is not mapped to parent + QRect cr(tlw->geometry()); bool isResize = cr.size() != newRect.size(); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 1df73c2..782cc1d 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1342,6 +1342,7 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) flags |= Qt::Window; } +#ifndef Q_WS_LITE if (QWidget *parent = parentWidget()) { #ifdef Q_WS_MAC if (testAttribute(Qt::WA_NativeWindow) == false) @@ -1362,6 +1363,7 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) return; } } +#endif //Q_WS_LITE #ifdef QT3_SUPPORT if (flags & Qt::WStaticContents) @@ -2424,6 +2426,7 @@ void QWidgetPrivate::createWinId(WId winid) #endif const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow); if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) { +#ifndef Q_WS_LITE if (!q->isWindow()) { QWidget *parent = q->parentWidget(); QWidgetPrivate *pd = parent->d_func(); @@ -2451,6 +2454,10 @@ void QWidgetPrivate::createWinId(WId winid) } else { q->create(); } +#else + q->create(); +#endif //Q_WS_LITE + } } @@ -10453,12 +10460,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8), "QWidget::setAttribute(WidgetAttribute, bool)", "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute"); -#ifdef Q_WS_LITE - //### we don't have native child widgets, and WinId isn't really there yet - if (attribute == Qt::WA_NativeWindow) - return; -#endif - #ifdef Q_WS_WIN // ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0 if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) { @@ -11945,11 +11946,6 @@ QWindowSurface *QWidget::windowSurface() const */ void QWidget::setPlatformWindow(QPlatformWindow *window) { -#ifndef Q_BACKINGSTORE_SUBSURFACES - if (!isTopLevel()) - return; -#endif - Q_D(QWidget); QTLWExtra *topData = d->topData(); diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index 5380445..f92eb61 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -54,6 +54,23 @@ QT_BEGIN_NAMESPACE static QPlatformScreen *qt_screenForWidget(const QWidget *w); +void setParentForChildrenOfWidget(QPlatformWindow *window, const QWidget *widget) +{ + QObjectList children = widget->children(); + for (int i = 0; i < children.size(); i++) { + if (children.at(i)->isWidgetType()) { + const QWidget *childWidget = qobject_cast(children.at(i)); + if (childWidget) { // should not be nessesary + if (childWidget->platformWindow()) { + childWidget->platformWindow()->setParent(window); + } else { + setParentForChildrenOfWidget(window,childWidget); + } + } + } + } +} + void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) { Q_Q(QWidget); @@ -65,7 +82,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO Qt::WindowFlags flags = data.window_flags; - if (!(flags & Qt::Window) || q->windowType() == Qt::Desktop) + if ((!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow()) || q->windowType() == Qt::Desktop ) return; // we only care about real toplevels QWindowSurface *surface = q->windowSurface(); @@ -76,8 +93,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO } Q_ASSERT(platformWindow); - // QGLWidget does not need/work with a windowsurface - if (!surface) {// && !q->inherits("QGLWidget")) { + if (!surface) { surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId()); } @@ -85,14 +101,11 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO setWinId(q->platformWindow()->winId()); - QObjectList children = q->children(); - for (int i = 0; i < children.size(); i++) { - if (children.at(i)->isWidgetType()) { - const QWidget *childWidget = qobject_cast(children.at(i)); - QPlatformWindow *childWindow = childWidget->platformWindow(); - if (childWindow) { - childWindow->setParent(platformWindow); - } + //first check children. then find who for parent. + setParentForChildrenOfWidget(platformWindow,q); + if (QWidget *nativeParent = q->nativeParentWidget()) { + if (nativeParent->platformWindow()) { + platformWindow->setParent(nativeParent->platformWindow()); } } @@ -132,7 +145,6 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) { Q_Q(QWidget); - // QWidget *oldParent = q->parentWidget(); Qt::WindowFlags oldFlags = data.window_flags; @@ -560,9 +572,13 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) data.crect = r; if (q->isVisible()) { - if (q->platformWindow()) { - q->platformWindow()->setGeometry(q->frameGeometry()); + if (q->isWindow()) { + q->platformWindow()->setGeometry(q->frameGeometry()); + } else { + QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint()); + q->platformWindow()->setGeometry(QRect(posInNativeParent,r.size())); + } const QWidgetBackingStore *bs = maybeBackingStore(); if (bs->windowSurface) { if (isResize) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index ad7c568..98455e1 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -290,7 +290,7 @@ QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const QGLWindowSurface::QGLWindowSurface(QWidget *window) : QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate) { - Q_ASSERT(window->isTopLevel()); +// Q_ASSERT(window->isTopLevel()); d_ptr->pb = 0; d_ptr->fbo = 0; d_ptr->ctx = 0; diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index 2737db0..82e64e6 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -640,18 +640,8 @@ WId QTestLiteWindow::winId() const void QTestLiteWindow::setParent(const QPlatformWindow *window) { - /******** Cleaning up **********/ - Window parentXWindow, rootXWindow; - Window *children; - unsigned int nChildren; - if (XQueryTree(xd->display, x_window, &rootXWindow, &parentXWindow, &children, &nChildren)) { - if (parentXWindow) { - XUnmapWindow(xd->display, x_window); - XReparentWindow(xd->display, x_window, rootXWindow, 0, 0); - } - } - /******* Done cleaning up ********/ - XReparentWindow(xd->display,x_window,window->winId(),geometry().x(),geometry().y()); + QPoint point = widget()->mapTo(widget()->nativeParentWidget(),QPoint()); + XReparentWindow(xd->display,x_window,window->winId(),point.x(),point.y()); XMapWindow(xd->display, x_window); } @@ -701,7 +691,6 @@ void QTestLiteWindow::paintEvent() void QTestLiteWindow::resizeEvent(XConfigureEvent *e) { - if ((e->width != width || e->height != height) && e->x == 0 && e->y == 0) { //qDebug() << "resize with bogus pos" << e->x << e->y << e->width << e->height << "window"<< hex << window; } else { @@ -844,7 +833,7 @@ static inline bool isTransient(const QWidget *w) Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags) { - Q_ASSERT(flags & Qt::Window); +// Q_ASSERT(flags & Qt::Window); window_flags = flags; if (mwm_hint_atom == XNone) { -- cgit v0.12 From 415c1ee359249e3eb44ff56e6078076d6024afeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 24 Jun 2010 09:32:19 +0200 Subject: Say hello to Q_WS_QPA! Rename Q_WS_LITE -> Q_WS_QPA --- configure | 2 +- src/corelib/global/qglobal.cpp | 10 +++--- src/corelib/global/qglobal.h | 6 ++-- src/corelib/global/qnamespace.h | 2 +- src/corelib/io/qsettings.cpp | 2 +- src/corelib/io/qsettings_p.h | 2 +- src/gui/embedded/qkbd_qws.cpp | 4 +-- src/gui/image/qnativeimage.cpp | 2 +- src/gui/image/qpixmap.cpp | 2 +- src/gui/image/qpixmap_blitter.cpp | 2 +- src/gui/image/qpixmapdatafactory.cpp | 4 +-- src/gui/kernel/qapplication.cpp | 18 +++++----- src/gui/kernel/qapplication_p.h | 10 +++--- src/gui/kernel/qcursor.h | 2 +- src/gui/kernel/qcursor_p.h | 2 +- src/gui/kernel/qdnd_p.h | 2 +- src/gui/kernel/qguiplatformplugin.cpp | 2 +- src/gui/kernel/qwidget.cpp | 30 ++++++++-------- src/gui/kernel/qwidget.h | 2 +- src/gui/kernel/qwidget_p.h | 6 ++-- src/gui/kernel/qwindowdefs.h | 4 +-- src/gui/painting/qbackingstore.cpp | 10 +++--- src/gui/painting/qgraphicssystem.cpp | 4 +-- src/gui/painting/qpaintdevice.cpp | 2 +- src/gui/painting/qpaintengine.h | 2 +- src/gui/painting/qpaintengine_raster.cpp | 6 ++-- src/gui/painting/qregion.cpp | 4 +-- src/gui/painting/qregion.h | 6 ++-- src/gui/painting/qwindowsurface.cpp | 10 +++--- src/gui/painting/qwindowsurface_p.h | 2 +- src/gui/text/qfont.cpp | 6 ++-- src/gui/text/qfont.h | 4 +-- src/gui/text/qfontdatabase.cpp | 40 +++++++++++----------- src/gui/text/qfontdatabase.h | 2 +- src/gui/text/qfontengine.cpp | 4 +-- src/gui/text/qfontengine_ft_p.h | 2 +- src/gui/text/qfontengine_p.h | 2 +- src/gui/util/qdesktopservices.cpp | 2 +- src/opengl/qgl.cpp | 8 ++--- src/opengl/qgl_p.h | 6 ++-- src/opengl/qglpixelbuffer_p.h | 8 ++--- src/opengl/qwindowsurface_gl.cpp | 6 ++-- src/opengl/qwindowsurface_gl_p.h | 2 +- .../trace/qgraphicssystem_trace.cpp | 2 +- tests/auto/qaction/tst_qaction.cpp | 2 +- 45 files changed, 129 insertions(+), 129 deletions(-) diff --git a/configure b/configure index 41ccb34..6143ac1 100755 --- a/configure +++ b/configure @@ -7691,7 +7691,7 @@ fi # QWS if [ "$PLATFORM_EMBLITE" = "yes" ]; then # Add LITE to config.h - QCONFIG_FLAGS="$QCONFIG_FLAGS Q_WS_LITE QT_NO_QWS_QPF QT_NO_QWS_QPF2" + QCONFIG_FLAGS="$QCONFIG_FLAGS Q_WS_QPA QT_NO_QWS_QPF QT_NO_QWS_QPF2" fi if [ "${CFG_USE_FLOATMATH}" = "yes" ]; then diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index f4f9702..bf78c03 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1231,7 +1231,7 @@ bool qSharedBuild() Defined on Mac OS X. - \sa Q_WS_WIN, Q_WS_X11, Q_WS_QWS, Q_WS_LITE, Q_WS_S60 + \sa Q_WS_WIN, Q_WS_X11, Q_WS_QWS, Q_WS_QPA, Q_WS_S60 */ /*! @@ -1240,7 +1240,7 @@ bool qSharedBuild() Defined on Windows. - \sa Q_WS_MAC, Q_WS_X11, Q_WS_QWS, Q_WS_LITE, Q_WS_S60 + \sa Q_WS_MAC, Q_WS_X11, Q_WS_QWS, Q_WS_QPA, Q_WS_S60 */ /*! @@ -1249,7 +1249,7 @@ bool qSharedBuild() Defined on X11. - \sa Q_WS_MAC, Q_WS_WIN, Q_WS_QWS, Q_WS_LITE, Q_WS_S60 + \sa Q_WS_MAC, Q_WS_WIN, Q_WS_QWS, Q_WS_QPA, Q_WS_S60 */ /*! @@ -1258,11 +1258,11 @@ bool qSharedBuild() Defined on Qt for Embedded Linux. - \sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11, Q_WS_LITE, Q_WS_S60 + \sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11, Q_WS_QPA, Q_WS_S60 */ /*! - \macro Q_WS_LITE + \macro Q_WS_QPA \relates Defined on Qt for Embedded Linux, Lite version. diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 815b7da..00ba5c3 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -807,7 +807,7 @@ namespace QT_NAMESPACE {} # define Q_WS_PM # error "Qt does not work with OS/2 Presentation Manager or Workplace Shell" #elif defined(Q_OS_UNIX) -# if defined(Q_OS_MAC) && !defined(__USE_WS_X11__) && !defined(Q_WS_QWS) && !defined(Q_WS_LITE) +# if defined(Q_OS_MAC) && !defined(__USE_WS_X11__) && !defined(Q_WS_QWS) && !defined(Q_WS_QPA) # define Q_WS_MAC # define Q_WS_MACX # if defined(Q_OS_MAC64) @@ -819,7 +819,7 @@ namespace QT_NAMESPACE {} # if !defined(QT_NO_S60) # define Q_WS_S60 # endif -# elif !defined(Q_WS_QWS) && !defined(Q_WS_LITE) +# elif !defined(Q_WS_QWS) && !defined(Q_WS_QPA) # define Q_WS_X11 # endif #endif @@ -1078,7 +1078,7 @@ redefine to built-in booleans to make autotests work properly */ typedef int QNoImplicitBoolCast; -#if defined(QT_ARCH_ARM) || defined(QT_ARCH_ARMV6) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_MIPS) && (defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_WINCE))) || defined(QT_ARCH_SH) || defined(QT_ARCH_SH4A) +#if defined(QT_ARCH_ARM) || defined(QT_ARCH_ARMV6) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_MIPS) && (defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_WINCE))) || defined(QT_ARCH_SH) || defined(QT_ARCH_SH4A) #define QT_NO_FPU #endif diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 3a8b99f..6edadc5 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1654,7 +1654,7 @@ public: typedef void *HANDLE; #elif defined(Q_WS_X11) typedef unsigned long HANDLE; -#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) +#elif defined(Q_WS_QWS) || defined(Q_WS_QPA) typedef void * HANDLE; #elif defined(Q_OS_SYMBIAN) typedef unsigned long int HANDLE; // equivalent to TUint32 diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 703a9d2..998c7cc 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1126,7 +1126,7 @@ static void initDefaultPaths(QMutexLocker *locker) if (env == 0) { userPath = homePath; userPath += QLatin1Char('/'); -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) userPath += QLatin1String("Settings"); #else userPath += QLatin1String(".config"); diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h index 569a61c..5ff4d96 100644 --- a/src/corelib/io/qsettings_p.h +++ b/src/corelib/io/qsettings_p.h @@ -70,7 +70,7 @@ QT_BEGIN_NAMESPACE -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) #define QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER #endif diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp index c4dd6bd..a325b28 100644 --- a/src/gui/embedded/qkbd_qws.cpp +++ b/src/gui/embedded/qkbd_qws.cpp @@ -53,7 +53,7 @@ #include "qscreen_qws.h" #endif -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA #include #include #endif @@ -362,7 +362,7 @@ void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardM { #if defined(Q_WS_QWS) qwsServer->processKeyEvent(unicode, keycode, modifiers, isPress, autoRepeat); -#elif defined(Q_WS_LITE) +#elif defined(Q_WS_QPA) QEvent::Type type = isPress ? QEvent::KeyPress : QEvent::KeyRelease; QString str; if (unicode != 0xffff) diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp index d4cbdc6..84c9911 100644 --- a/src/gui/image/qnativeimage.cpp +++ b/src/gui/image/qnativeimage.cpp @@ -287,7 +287,7 @@ QNativeImage::~QNativeImage() QImage::Format QNativeImage::systemFormat() { -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA return QApplicationPrivate::platformIntegration()->screens().at(0)->format(); #else return QImage::Format_RGB32; diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index ec640fc..1ae3bef 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1934,7 +1934,7 @@ int QPixmap::defaultDepth() return 32; #elif defined(Q_OS_SYMBIAN) return S60->screenDepth; -#elif defined(Q_WS_LITE) +#elif defined(Q_WS_QPA) return 32; //LITE: use graphicssystem (we should do that in general) #endif } diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 38a2f81..660f4d2 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -56,7 +56,7 @@ void QBlittablePixmapData::resize(int width, int height) m_blittable = 0; delete m_engine; m_engine = 0; -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA d = QApplicationPrivate::platformIntegration()->screens().at(0)->depth(); #endif w = width; diff --git a/src/gui/image/qpixmapdatafactory.cpp b/src/gui/image/qpixmapdatafactory.cpp index ac79c75..b63d046 100644 --- a/src/gui/image/qpixmapdatafactory.cpp +++ b/src/gui/image/qpixmapdatafactory.cpp @@ -53,7 +53,7 @@ #ifdef Q_WS_MAC # include #endif -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA # include #endif #ifdef Q_WS_S60 @@ -85,7 +85,7 @@ QPixmapData* QSimplePixmapDataFactory::create(QPixmapData::PixelType type) return new QRasterPixmapData(type); #elif defined(Q_WS_MAC) return new QMacPixmapData(type); -#elif defined(Q_WS_LITE) +#elif defined(Q_WS_QPA) return new QRasterPixmapData(type); #elif defined(Q_WS_S60) return new QS60PixmapData(type); diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 8b53d35..b3e6fcd 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -447,7 +447,7 @@ QPalette *QApplicationPrivate::sys_pal = 0; // default system palette QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) QPlatformIntegration *QApplicationPrivate::platform_integration = 0; #endif QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization @@ -508,7 +508,7 @@ inline bool QApplicationPrivate::isAlien(QWidget *widget) { if (!widget) return false; -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) return !widget->isWindow() # ifdef Q_BACKINGSTORE_SUBSURFACES && !(widget->d_func()->maybeTopData() && widget->d_func()->maybeTopData()->windowSurface) @@ -923,7 +923,7 @@ void QApplicationPrivate::initialize() QWidgetPrivate::mapper = new QWidgetMapper; QWidgetPrivate::allWidgets = new QWidgetSet; -#if !defined(Q_WS_X11) && !defined(Q_WS_QWS) && !defined(Q_WS_LITE) +#if !defined(Q_WS_X11) && !defined(Q_WS_QWS) && !defined(Q_WS_QPA) // initialize the graphics system - on X11 this is initialized inside // qt_init() in qapplication_x11.cpp because of several reasons. // On QWS, the graphics system is set by the QScreen plugin. @@ -1590,7 +1590,7 @@ QStyle* QApplication::setStyle(const QString& style) void QApplication::setGraphicsSystem(const QString &system) { -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA Q_UNUSED(system); #else # ifdef QT_GRAPHICSSYSTEM_RUNTIME @@ -2735,7 +2735,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { // Update cursor for alien/graphics widgets. const bool enterOnAlien = (enter && (isAlien(enter) || enter->testAttribute(Qt::WA_DontShowOnScreen))); -#if defined(Q_WS_X11) || defined(Q_WS_LITE) +#if defined(Q_WS_X11) || defined(Q_WS_QPA) //Whenever we leave an alien widget on X11, we need to reset its nativeParentWidget()'s cursor. // This is not required on Windows as the cursor is reset on every single mouse move. QWidget *parentOfLeavingCursor = 0; @@ -2761,7 +2761,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { { #if defined(Q_WS_X11) qt_x11_enforce_cursor(parentOfLeavingCursor,true); -#elif defined(Q_WS_LITE) +#elif defined(Q_WS_QPA) if (enter == QApplication::desktop()) { qt_lite_set_cursor(enter, true); } else { @@ -2791,7 +2791,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { qt_x11_enforce_cursor(cursorWidget, true); #elif defined(Q_WS_S60) qt_symbian_set_cursor(cursorWidget, true); -#elif defined(Q_WS_LITE) +#elif defined(Q_WS_QPA) qt_lite_set_cursor(cursorWidget, true); #endif } @@ -3097,7 +3097,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, return result; } -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_LITE) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA) /* This function should only be called when the widget changes visibility, i.e. when the \a widget is shown, hidden or deleted. This function does nothing @@ -3109,7 +3109,7 @@ extern QWidget *qt_button_down; void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget) { #ifndef QT_NO_CURSOR -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) if (!widget || widget->isWindow()) return; #else diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 8d36519..ecfac78 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -76,7 +76,7 @@ #ifdef Q_OS_SYMBIAN #include #endif -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA #include #include "QtGui/qplatformintegration_lite.h" #endif @@ -324,7 +324,7 @@ public: { return graphics_system; } #endif -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) static QPlatformIntegration *platformIntegration() { return platform_integration; } @@ -489,7 +489,7 @@ public: static bool qt_mac_apply_settings(); #endif -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA static void processMouseEvent(QWindowSystemInterface::MouseEvent *e); static void processKeyEvent(QWindowSystemInterface::KeyEvent *e); static void processWheelEvent(QWindowSystemInterface::WheelEvent *e); @@ -552,7 +552,7 @@ public: int symbianResourceChange(const QSymbianEvent *symbianEvent); #endif -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_LITE) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA) void sendSyntheticEnterLeave(QWidget *widget); #endif @@ -660,7 +660,7 @@ Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, extern void qt_x11_enforce_cursor(QWidget *); #elif defined(Q_OS_SYMBIAN) extern void qt_symbian_set_cursor(QWidget *, bool); -#elif defined (Q_WS_LITE) +#elif defined (Q_WS_QPA) extern void qt_lite_set_cursor(QWidget *, bool); #endif diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h index cb9e8a6..b414a78 100644 --- a/src/gui/kernel/qcursor.h +++ b/src/gui/kernel/qcursor.h @@ -126,7 +126,7 @@ public: static int x11Screen(); #elif defined(Q_WS_MAC) Qt::HANDLE handle() const; -#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) +#elif defined(Q_WS_QWS) || defined(Q_WS_QPA) int handle() const; #elif defined(Q_OS_SYMBIAN) Qt::HANDLE handle() const; diff --git a/src/gui/kernel/qcursor_p.h b/src/gui/kernel/qcursor_p.h index dadb83c..bfd6eac 100644 --- a/src/gui/kernel/qcursor_p.h +++ b/src/gui/kernel/qcursor_p.h @@ -91,7 +91,7 @@ public: short hx, hy; #if defined (Q_WS_MAC) int mId; -#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) +#elif defined(Q_WS_QWS) || defined(Q_WS_QPA) int id; #endif #if defined (Q_WS_WIN) diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h index 3989979..598a9de 100644 --- a/src/gui/kernel/qdnd_p.h +++ b/src/gui/kernel/qdnd_p.h @@ -261,7 +261,7 @@ public: #endif private: -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) Qt::DropAction currentActionForOverrideCursor; #endif #ifdef Q_OS_SYMBIAN diff --git a/src/gui/kernel/qguiplatformplugin.cpp b/src/gui/kernel/qguiplatformplugin.cpp index 16a2a2b..98b9c4a 100644 --- a/src/gui/kernel/qguiplatformplugin.cpp +++ b/src/gui/kernel/qguiplatformplugin.cpp @@ -152,7 +152,7 @@ QString QGuiPlatformPlugin::styleName() return QLatin1String("Windows"); // default style for Symbian without S60 #elif defined(Q_WS_X11) && defined(Q_OS_IRIX) return QLatin1String("SGI"); // default style for X11 on IRIX -#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) +#elif defined(Q_WS_QWS) || defined(Q_WS_QPA) return QLatin1String("Plastique"); // default style for X11 and small devices #elif defined(Q_WS_MAC) return QLatin1String("Macintosh"); // default style for all Mac's diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 782cc1d..57e3a31 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -75,7 +75,7 @@ # include "qpaintengine.h" // for PorterDuff # include "private/qwindowsurface_qws_p.h" #endif -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) #include "qplatformwindow_lite.h" #endif #include "qpainter.h" @@ -259,7 +259,7 @@ QWidgetPrivate::QWidgetPrivate(int version) , hasAlienChildren(0) , window_event(0) , qd_hd(0) -#elif defined (Q_WS_LITE) +#elif defined (Q_WS_QPA) , screenNumber(0) #endif { @@ -1214,7 +1214,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) // programmer specified desktop widget xinfo = desktopWidget->d_func()->xinfo; } -#elif defined(Q_WS_LITE) +#elif defined(Q_WS_QPA) if (desktopWidget) { int screen = desktopWidget->d_func()->screenNumber; QPlatformIntegration *platform = QApplicationPrivate::platformIntegration(); @@ -1342,7 +1342,7 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) flags |= Qt::Window; } -#ifndef Q_WS_LITE +#ifndef Q_WS_QPA if (QWidget *parent = parentWidget()) { #ifdef Q_WS_MAC if (testAttribute(Qt::WA_NativeWindow) == false) @@ -1363,7 +1363,7 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) return; } } -#endif //Q_WS_LITE +#endif //Q_WS_QPA #ifdef QT3_SUPPORT if (flags & Qt::WStaticContents) @@ -1526,7 +1526,7 @@ QWidget::~QWidget() else if (!internalWinId() && isVisible()) { qApp->d_func()->sendSyntheticEnterLeave(this); } -#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) +#elif defined(Q_WS_QWS) || defined(Q_WS_QPA) else if (isVisible()) { qApp->d_func()->sendSyntheticEnterLeave(this); } @@ -1660,7 +1660,7 @@ void QWidgetPrivate::createTLExtra() static int count = 0; qDebug() << "tlextra" << ++count; #endif -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) x->platformWindow = 0; #endif } @@ -2426,7 +2426,7 @@ void QWidgetPrivate::createWinId(WId winid) #endif const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow); if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) { -#ifndef Q_WS_LITE +#ifndef Q_WS_QPA if (!q->isWindow()) { QWidget *parent = q->parentWidget(); QWidgetPrivate *pd = parent->d_func(); @@ -2456,7 +2456,7 @@ void QWidgetPrivate::createWinId(WId winid) } #else q->create(); -#endif //Q_WS_LITE +#endif //Q_WS_QPA } } @@ -5410,7 +5410,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP //actually send the paint event QPaintEvent e(toBePainted); QCoreApplication::sendSpontaneousEvent(q, &e); -#if !defined(Q_WS_MAC) && !defined(Q_WS_QWS) && !defined(Q_WS_LITE) +#if !defined(Q_WS_MAC) && !defined(Q_WS_QWS) && !defined(Q_WS_QPA) if (backingStore && !onScreen && !asRoot && (q->internalWinId() || !q->nativeParentWidget()->isWindow())) backingStore->markDirtyOnScreen(toBePainted, q, offset); #endif @@ -7448,7 +7448,7 @@ void QWidgetPrivate::hide_helper() // next bit tries to move the focus if the focus widget is now // hidden. if (wasVisible) { -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_LITE) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA) qApp->d_func()->sendSyntheticEnterLeave(q); #endif @@ -7580,7 +7580,7 @@ void QWidget::setVisible(bool visible) d->show_helper(); -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_LITE) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA) qApp->d_func()->sendSyntheticEnterLeave(this); #endif } @@ -7712,7 +7712,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous) widget->d_func()->hide_sys(); } } -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_LITE) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA) qApp->d_func()->sendSyntheticEnterLeave(widget); #endif #ifndef QT_NO_ACCESSIBILITY @@ -11937,7 +11937,7 @@ QWindowSurface *QWidget::windowSurface() const return bs ? bs->windowSurface : 0; } -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) /*! \preliminary @@ -11970,7 +11970,7 @@ QPlatformWindow *QWidget::platformWindow() const return 0; } -#endif //defined(Q_WS_LITE) +#endif //defined(Q_WS_QPA) void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const { diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 740f4ff..8e08ce5 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -628,7 +628,7 @@ public: void setWindowSurface(QWindowSurface *surface); QWindowSurface *windowSurface() const; -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) void setPlatformWindow(QPlatformWindow *window); QPlatformWindow *platformWindow() const; friend class QDesktopScreenWidget; diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 91cd1c5..5274c3b 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -102,7 +102,7 @@ class QWSManager; #if defined(Q_WS_MAC) class QCoreGraphicsPaintEnginePrivate; #endif -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) class QPlatformWindow; #endif class QPaintEngine; @@ -227,7 +227,7 @@ struct QTLWExtra { #endif #elif defined(Q_OS_SYMBIAN) uint inExpose : 1; // Prevents drawing recursion -#elif defined(Q_WS_LITE) +#elif defined(Q_WS_QPA) QPlatformWindow *platformWindow; #endif }; @@ -870,7 +870,7 @@ public: void updateCursor() const; #endif QScreen* getScreen() const; -#elif defined(Q_WS_LITE) +#elif defined(Q_WS_QPA) void setMaxWindowState_helper(); void setFullScreenSize_helper(); diff --git a/src/gui/kernel/qwindowdefs.h b/src/gui/kernel/qwindowdefs.h index ea3281f..1dc7203 100644 --- a/src/gui/kernel/qwindowdefs.h +++ b/src/gui/kernel/qwindowdefs.h @@ -131,11 +131,11 @@ QT_END_HEADER #endif // Q_WS_QWS -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) typedef unsigned long WId; -#endif // Q_WS_LITE +#endif // Q_WS_QPA #if defined(Q_OS_SYMBIAN) class CCoeControl; diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 590b9a8..a73d63f 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -286,7 +286,7 @@ bool QWidgetBackingStore::bltRect(const QRect &rect, int dx, int dy, QWidget *wi void QWidgetBackingStore::releaseBuffer() { if (windowSurface) -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) windowSurface->resize(QSize()); #else windowSurface->setGeometry(QRect()); @@ -420,7 +420,7 @@ QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const { const bool widgetDirty = widget && widget != tlw; const QRect tlwRect(topLevelRect()); -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size()); #else const QRect surfaceGeometry(windowSurface->geometry()); @@ -475,7 +475,7 @@ QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const QRegion QWidgetBackingStore::staticContents(QWidget *parent, const QRect &withinClipRect) const { if (!parent && tlw->testAttribute(Qt::WA_StaticContents)) { -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) const QSize surfaceGeometry(windowSurface->size()); #else const QRect surfaceGeometry(windowSurface->geometry()); @@ -1183,7 +1183,7 @@ void QWidgetBackingStore::sync() const bool inTopLevelResize = tlwExtra->inTopLevelResize; const QRect tlwRect(topLevelRect()); -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size()); #else const QRect surfaceGeometry(windowSurface->geometry()); @@ -1207,7 +1207,7 @@ void QWidgetBackingStore::sync() } } -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA if (inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) windowSurface->resize(tlwRect.size()); #else diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp index c9866ae..9f00e2a 100644 --- a/src/gui/painting/qgraphicssystem.cpp +++ b/src/gui/painting/qgraphicssystem.cpp @@ -50,7 +50,7 @@ #ifdef Q_WS_MAC # include #endif -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA # include #endif #ifdef Q_WS_S60 @@ -77,7 +77,7 @@ QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType typ return new QRasterPixmapData(type); #elif defined(Q_WS_MAC) return new QMacPixmapData(type); -#elif defined(Q_WS_LITE) +#elif defined(Q_WS_QPA) return QApplicationPrivate::platformIntegration()->createPixmapData(type); #elif defined(Q_WS_S60) return new QS60PixmapData(type); diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp index 0042a47..cde7bfa 100644 --- a/src/gui/painting/qpaintdevice.cpp +++ b/src/gui/painting/qpaintdevice.cpp @@ -59,7 +59,7 @@ QPaintDevice::~QPaintDevice() } -#ifndef Q_WS_LITE +#ifndef Q_WS_QPA int QPaintDevice::metric(PaintDeviceMetric) const { qWarning("QPaintDevice::metrics: Device has no metric information"); diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h index 349ebeb..ddb6195 100644 --- a/src/gui/painting/qpaintengine.h +++ b/src/gui/painting/qpaintengine.h @@ -271,7 +271,7 @@ private: friend class QtopiaPrintEnginePrivate; friend class QProxyFontEngine; #endif -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA friend class QProxyFontEngine; #endif friend class QPainter; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 4fad0c6..97db24b 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -95,7 +95,7 @@ # include #elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) # include -#elif defined(Q_WS_LITE) +#elif defined(Q_WS_QPA) # include #endif @@ -3410,9 +3410,9 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte } #endif // Q_WS_QWS -#if (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) || defined(Q_WS_LITE)) && !defined(QT_NO_FREETYPE) +#if (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) || defined(Q_WS_QPA)) && !defined(QT_NO_FREETYPE) -#if (defined(Q_WS_QWS) || defined(Q_WS_LITE)) && !defined(QT_NO_QWS_QPF2) +#if (defined(Q_WS_QWS) || defined(Q_WS_QPA)) && !defined(QT_NO_QWS_QPF2) if (fontEngine->type() == QFontEngine::QPF2) { QFontEngine *renderingEngine = static_cast(fontEngine)->renderingEngine(); if (renderingEngine) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index c667f84..c57db82 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -1620,7 +1620,7 @@ QT_END_INCLUDE_NAMESPACE QT_BEGIN_INCLUDE_NAMESPACE # include "qregion_win.cpp" QT_END_INCLUDE_NAMESPACE -#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) +#elif defined(Q_WS_QWS) || defined(Q_WS_QPA) static QRegionPrivate qrp; QRegion::QRegionData QRegion::shared_empty = {Q_BASIC_ATOMIC_INITIALIZER(1), &qrp}; #endif @@ -4231,7 +4231,7 @@ QRect QRegion::boundingRect() const Returns true if \a rect is guaranteed to be fully contained in \a region. A false return value does not guarantee the opposite. */ -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) Q_GUI_EXPORT #endif bool qt_region_strictContains(const QRegion ®ion, const QRect &rect) diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index 66a3e7f..463d9ef 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -59,7 +59,7 @@ QT_MODULE(Gui) template class QVector; class QVariant; -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) struct QRegionPrivate; #endif @@ -163,7 +163,7 @@ public: #endif HIMutableShapeRef toHIMutableShape() const; static QRegion fromHIShapeRef(HIShapeRef shape); -#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) +#elif defined(Q_WS_QWS) || defined(Q_WS_QPA) inline void *handle() const { return d->qt_rgn; } #endif #endif @@ -203,7 +203,7 @@ private: #elif defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) mutable RgnHandle unused; // Here for binary compatability reasons. ### Qt 5 remove. #endif -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) QRegionPrivate *qt_rgn; #endif }; diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp index c42ead0..845cf6d 100644 --- a/src/gui/painting/qwindowsurface.cpp +++ b/src/gui/painting/qwindowsurface.cpp @@ -58,11 +58,11 @@ public: } QWidget *window; -#if !defined(Q_WS_LITE) +#if !defined(Q_WS_QPA) QRect geometry; #else QSize size; -#endif //Q_WS_LITE +#endif //Q_WS_QPA QRegion staticContents; QList bufferImages; uint staticContentsSupport : 1; @@ -157,7 +157,7 @@ void QWindowSurface::endPaint(const QRegion &) d_ptr->bufferImages.clear(); } -#if !defined(Q_WS_LITE) +#if !defined(Q_WS_QPA) /*! Sets the currently allocated area to be the given \a rect. @@ -188,7 +188,7 @@ QSize QWindowSurface::size() const { return d_ptr->size; } -#endif //Q_WS_LITE +#endif //Q_WS_QPA /*! Scrolls the given \a area \a dx pixels to the right and \a dy @@ -345,7 +345,7 @@ void QWindowSurface::setPartialUpdateSupport(bool enable) d_ptr->partialUpdateSupport = enable; } -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA #define Q_EXPORT_SCROLLRECT Q_GUI_EXPORT #else #define Q_EXPORT_SCROLLRECT diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h index 512cb97..da02f5a 100644 --- a/src/gui/painting/qwindowsurface_p.h +++ b/src/gui/painting/qwindowsurface_p.h @@ -80,7 +80,7 @@ public: // can be larger than just the offset from the top-level widget as there may also be window // decorations which are painted into the window surface. virtual void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) = 0; -#if !defined(Q_WS_LITE) +#if !defined(Q_WS_QPA) virtual void setGeometry(const QRect &rect); QRect geometry() const; #else diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index bfd4ee9..3861196 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -75,7 +75,7 @@ #ifdef Q_OS_SYMBIAN #include #endif -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA #include #include #endif @@ -176,7 +176,7 @@ Q_GUI_EXPORT int qt_defaultDpiX() if (!subScreens.isEmpty()) screen = subScreens.at(0); dpi = qRound(screen->width() / (screen->physicalWidth() / qreal(25.4))); -#elif defined(Q_WS_LITE) +#elif defined(Q_WS_QPA) QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); if (pi) { QPlatformScreen *screen = QApplicationPrivate::platformIntegration()->screens().at(0); @@ -215,7 +215,7 @@ Q_GUI_EXPORT int qt_defaultDpiY() if (!subScreens.isEmpty()) screen = subScreens.at(0); dpi = qRound(screen->height() / (screen->physicalHeight() / qreal(25.4))); -#elif defined(Q_WS_LITE) +#elif defined(Q_WS_QPA) QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); if (pi) { QPlatformScreen *screen = QApplicationPrivate::platformIntegration()->screens().at(0); diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 0189281..583b4ff 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -46,7 +46,7 @@ #include #include -#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA) typedef struct FT_FaceRec_* FT_Face; #endif @@ -233,7 +233,7 @@ public: #ifdef Q_WS_MAC quint32 macFontID() const; #endif -#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA) FT_Face freetypeFace() const; #endif diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 853eb05..748b271 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -56,7 +56,7 @@ #include #include -#if (defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) +#if (defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) # include # include FT_TRUETYPE_TABLES_H #endif @@ -152,10 +152,10 @@ struct QtFontSize unsigned short count : 16; #endif // Q_WS_X11 -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) QByteArray fileName; int fileIndex; -#endif // defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) +#endif // defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) unsigned short pixelSize : 16; }; @@ -231,14 +231,14 @@ struct QtFontStyle delete [] weightName; delete [] setwidthName; #endif -#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) while (count) { // bitfield count-- in while condition does not work correctly in mwccsym2 count--; #ifdef Q_WS_X11 free(pixelSizes[count].encodings); #endif -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) pixelSizes[count].fileName.~QByteArray(); #endif } @@ -256,7 +256,7 @@ struct QtFontStyle const char *weightName; const char *setwidthName; #endif // Q_WS_X11 -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) bool antialiased; #endif @@ -302,7 +302,7 @@ QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add) pixelSizes[count].count = 0; pixelSizes[count].encodings = 0; #endif -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) new (&pixelSizes[count].fileName) QByteArray; pixelSizes[count].fileIndex = 0; #endif @@ -388,7 +388,7 @@ struct QtFontFamily fixedPitchComputed(false), #endif name(n), count(0), foundries(0) -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) , bogusWritingSystems(false) #endif { @@ -428,7 +428,7 @@ struct QtFontFamily int count; QtFontFoundry **foundries; -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) bool bogusWritingSystems; QStringList fallbackFamilies; #endif @@ -475,7 +475,7 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create) // ### copied to tools/makeqpf/qpf2.cpp -#if ((defined(Q_WS_QWS) || defined(Q_WS_LITE)) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)) +#if ((defined(Q_WS_QWS) || defined(Q_WS_QPA)) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)) // see the Unicode subset bitfields in the MSDN docs static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = { @@ -617,7 +617,7 @@ class QFontDatabasePrivate public: QFontDatabasePrivate() : count(0), families(0), reregisterAppFonts(false) -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) , stream(0) #endif #if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) @@ -665,11 +665,11 @@ public: void invalidate(); -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) bool loadFromCache(const QString &fontPath); void addQPF2File(const QByteArray &file); #endif // Q_WS_QWS -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) void addFont(const QString &familyname, const char *foundryname, int weight, bool italic, int pixelSize, const QByteArray &file, int fileIndex, bool antialiased, @@ -678,7 +678,7 @@ public: QStringList addTTFile(const QByteArray &file, const QByteArray &fontData = QByteArray()); #endif // QT_NO_FREETYPE #endif -#if defined(Q_WS_QWS) || defined (Q_WS_LITE) +#if defined(Q_WS_QWS) || defined (Q_WS_QPA) QDataStream *stream; QStringList fallbackFamilies; #elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) @@ -732,7 +732,7 @@ QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create) return families[pos]; } -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundryname, int weight, bool italic, int pixelSize, const QByteArray &file, int fileIndex, bool antialiased, const QList &writingSystems) @@ -763,7 +763,7 @@ void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundr size->fileName = file; size->fileIndex = fileIndex; -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) if (stream) { *stream << familyname << foundry->name << weight << quint8(italic) << pixelSize << file << fileIndex << quint8(antialiased); @@ -778,7 +778,7 @@ void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundr } #endif -#if (defined(Q_WS_QWS) || defined (Q_WS_LITE) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) +#if (defined(Q_WS_QWS) || defined (Q_WS_QPA) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) QStringList QFontDatabasePrivate::addTTFile(const QByteArray &file, const QByteArray &fontData) { QStringList families; @@ -891,7 +891,7 @@ static const int scriptForWritingSystem[] = { }; -#if defined Q_WS_QWS || defined(Q_WS_LITE) || (defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)) || defined(Q_WS_WIN) +#if defined Q_WS_QWS || defined(Q_WS_QPA) || (defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)) || defined(Q_WS_WIN) static inline bool requiresOpenType(int writingSystem) { return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala) @@ -965,7 +965,7 @@ static void match(int script, const QFontDef &request, const QString &family_name, const QString &foundry_name, int force_encoding_id, QtFontDesc *desc, const QList &blacklistedFamilies = QList(), bool forceXLFD=false); -#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA) static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef) { fontDef->family = desc.family->name; @@ -1053,7 +1053,7 @@ QT_BEGIN_INCLUDE_NAMESPACE # include "qfontdatabase_mac.cpp" #elif defined(Q_WS_WIN) # include "qfontdatabase_win.cpp" -#elif defined(Q_WS_QWS) || defined(Q_WS_LITE) +#elif defined(Q_WS_QWS) || defined(Q_WS_QPA) # include "qfontdatabase_qws.cpp" #elif defined(Q_OS_SYMBIAN) # include "qfontdatabase_s60.cpp" diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h index 1339884..6a09b77 100644 --- a/src/gui/text/qfontdatabase.h +++ b/src/gui/text/qfontdatabase.h @@ -152,7 +152,7 @@ public: private: static void createDatabase(); static void parseFontName(const QString &name, QString &foundry, QString &family); -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) static QFontEngine *findFont(int script, const QFontPrivate *fp, const QFontDef &request); #endif static void load(const QFontPrivate *d, int script); diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 060d9bc..fdb86ce 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -742,7 +742,7 @@ QFontEngineGlyphCache *QFontEngine::glyphCache(void *key, QFontEngineGlyphCache: return 0; } -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) static inline QFixed kerning(int left, int right, const QFontEngine::KernPair *pairs, int numPairs) { uint left_right = (left << 16) + right; @@ -1157,7 +1157,7 @@ glyph_metrics_t QFontEngineBox::boundingBox(const QGlyphLayout &glyphs) return overall; } -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) void QFontEngineBox::draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &ti) { if (!ti.glyphs.numGlyphs) diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 4e86c0d..372ad0c 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -271,7 +271,7 @@ private: QGlyphSet *loadTransformedGlyphSet(const QTransform &matrix); bool loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, GlyphFormat format = Format_Render); -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) virtual void draw(QPaintEngine * /*p*/, qreal /*x*/, qreal /*y*/, const QTextItemInt & /*si*/) {} #endif diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 3e39f89..fb4556b 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -235,7 +235,7 @@ public: bool symbol; mutable HB_FontRec hbFont; mutable HB_Face hbFace; -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_LITE) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) struct KernPair { uint left_right; QFixed adjust; diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index f26b27b..39a160e 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -45,7 +45,7 @@ #include -#if defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) #include "qdesktopservices_qws.cpp" #elif defined(Q_WS_X11) #include "qdesktopservices_x11.cpp" diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index a43f1d4..1241b7a 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -96,7 +96,7 @@ QT_BEGIN_NAMESPACE -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs; #endif @@ -1393,7 +1393,7 @@ QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags() } } -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA hasOpenGL(); // ### I have no idea why this is needed here, but it makes things work for testlite #endif @@ -1642,7 +1642,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) # endif vi = 0; #endif -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) platformContext = 0; #endif #if !defined(QT_NO_EGL) @@ -4049,7 +4049,7 @@ void QGLWidget::resizeOverlayGL(int, int) /*! \fn bool QGLWidget::event(QEvent *e) \reimp */ -#if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS) && !defined(Q_WS_LITE) +#if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS) && !defined(Q_WS_QPA) bool QGLWidget::event(QEvent *e) { Q_D(QGLWidget); diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index a1be68f..6c1e6aa 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -68,7 +68,7 @@ #include #endif -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) #include #endif @@ -359,7 +359,7 @@ public: EGLSurface eglSurfaceForDevice() const; #endif -#if defined(Q_WS_LITE) +#if defined(Q_WS_QPA) QPlatformGLContext *platformContext; #elif defined(Q_WS_X11) || defined(Q_WS_MAC) void* cx; @@ -424,7 +424,7 @@ public: static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *ctx) { return ctx->d_ptr->group->extensionFuncs(); } #endif -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_LITE) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) static QGLExtensionFuncs qt_extensionFuncs; static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *) { return qt_extensionFuncs; } #endif diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h index a7f4159..69678d0 100644 --- a/src/opengl/qglpixelbuffer_p.h +++ b/src/opengl/qglpixelbuffer_p.h @@ -197,10 +197,10 @@ public: EGLSurface pbuf; QEglContext *ctx; int textureFormat; -#elif defined(Q_WS_LITE) - // Stubs - int pbuf; - int ctx; +#elif defined(Q_WS_QPA) + //stubs + void *pbuf; + void *ctx; #endif }; diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 98455e1..b7629c6 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -419,7 +419,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget(); Q_ASSERT(parent); -#if !defined(Q_WS_LITE) +#if !defined(Q_WS_QPA) if (!geometry().isValid()) return; #else @@ -648,7 +648,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & } -#if !defined(Q_WS_LITE) +#if !defined(Q_WS_QPA) void QGLWindowSurface::setGeometry(const QRect &rect) { QWindowSurface::setGeometry(rect); @@ -667,7 +667,7 @@ void QGLWindowSurface::updateGeometry() { return; d_ptr->geometry_updated = false; -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA QSize surfSize = size(); #else QSize surfSize = geometry().size(); diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index 6bff109..10c8658 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -87,7 +87,7 @@ public: QPaintDevice *paintDevice(); void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); -#if !defined(Q_WS_LITE) +#if !defined(Q_WS_QPA) void setGeometry(const QRect &rect); #else virtual void resize(const QSize &size); diff --git a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp index 695050e..e2b9f99 100644 --- a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp +++ b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp @@ -98,7 +98,7 @@ QPaintDevice *QTraceWindowSurface::paintDevice() { if (!buffer) { buffer = new QPaintBuffer; -#ifdef Q_WS_LITE +#ifdef Q_WS_QPA buffer->setBoundingRect(QRect(QPoint(), size())); #else buffer->setBoundingRect(geometry()); diff --git a/tests/auto/qaction/tst_qaction.cpp b/tests/auto/qaction/tst_qaction.cpp index 26a28e7..66a1039 100644 --- a/tests/auto/qaction/tst_qaction.cpp +++ b/tests/auto/qaction/tst_qaction.cpp @@ -242,7 +242,7 @@ void tst_QAction::setStandardKeys() QList expected; #if defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) expected << QKeySequence("CTRL+C"); -#elif defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_LITE) +#elif defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_QPA) expected << QKeySequence("CTRL+C") << QKeySequence("CTRL+INSERT"); #else expected << QKeySequence("CTRL+C") << QKeySequence("F16") << QKeySequence("CTRL+INSERT"); -- cgit v0.12 From 4e27ff09ce4fae4b0af584e1dedb6fa189c6e3d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 24 Jun 2010 11:07:29 +0200 Subject: Renamed files from *_lite* to *_qpa* --- src/gui/egl/egl.pri | 2 +- src/gui/egl/qegl_lite.cpp | 111 --- src/gui/egl/qegl_qpa.cpp | 111 +++ src/gui/image/image.pri | 2 +- src/gui/image/qpixmap_lite.cpp | 49 -- src/gui/image/qpixmap_qpa.cpp | 49 ++ src/gui/kernel/kernel.pri | 52 +- src/gui/kernel/qapplication_lite.cpp | 882 --------------------- src/gui/kernel/qapplication_p.h | 2 +- src/gui/kernel/qapplication_qpa.cpp | 882 +++++++++++++++++++++ src/gui/kernel/qclipboard_lite.cpp | 163 ---- src/gui/kernel/qclipboard_qpa.cpp | 163 ++++ src/gui/kernel/qcursor_lite.cpp | 127 --- src/gui/kernel/qcursor_qpa.cpp | 127 +++ src/gui/kernel/qdesktopwidget_lite.cpp | 180 ----- src/gui/kernel/qdesktopwidget_lite_p.h | 76 -- src/gui/kernel/qdesktopwidget_qpa.cpp | 180 +++++ src/gui/kernel/qdesktopwidget_qpa_p.h | 76 ++ src/gui/kernel/qeventdispatcher_glib_lite.cpp | 139 ---- src/gui/kernel/qeventdispatcher_glib_lite_p.h | 88 -- src/gui/kernel/qeventdispatcher_glib_qpa.cpp | 139 ++++ src/gui/kernel/qeventdispatcher_glib_qpa_p.h | 88 ++ src/gui/kernel/qeventdispatcher_lite.cpp | 144 ---- src/gui/kernel/qeventdispatcher_lite_p.h | 86 -- src/gui/kernel/qeventdispatcher_qpa.cpp | 144 ++++ src/gui/kernel/qeventdispatcher_qpa_p.h | 86 ++ src/gui/kernel/qgenericplugin_lite.cpp | 112 --- src/gui/kernel/qgenericplugin_lite.h | 84 -- src/gui/kernel/qgenericplugin_qpa.cpp | 112 +++ src/gui/kernel/qgenericplugin_qpa.h | 84 ++ src/gui/kernel/qgenericpluginfactory_lite.cpp | 115 --- src/gui/kernel/qgenericpluginfactory_lite.h | 67 -- src/gui/kernel/qgenericpluginfactory_qpa.cpp | 115 +++ src/gui/kernel/qgenericpluginfactory_qpa.h | 67 ++ src/gui/kernel/qplatformglcontext_lite.h | 71 -- src/gui/kernel/qplatformglcontext_qpa.h | 71 ++ src/gui/kernel/qplatformintegration_lite.cpp | 64 -- src/gui/kernel/qplatformintegration_lite.h | 78 -- src/gui/kernel/qplatformintegration_qpa.cpp | 64 ++ src/gui/kernel/qplatformintegration_qpa.h | 78 ++ .../kernel/qplatformintegrationfactory_lite.cpp | 89 --- .../kernel/qplatformintegrationfactory_lite_p.h | 78 -- src/gui/kernel/qplatformintegrationfactory_qpa.cpp | 89 +++ src/gui/kernel/qplatformintegrationfactory_qpa_p.h | 78 ++ src/gui/kernel/qplatformintegrationplugin_lite.cpp | 55 -- src/gui/kernel/qplatformintegrationplugin_lite.h | 92 --- src/gui/kernel/qplatformintegrationplugin_qpa.cpp | 55 ++ src/gui/kernel/qplatformintegrationplugin_qpa.h | 92 +++ src/gui/kernel/qplatformscreen_lite.cpp | 66 -- src/gui/kernel/qplatformscreen_lite.h | 74 -- src/gui/kernel/qplatformscreen_qpa.cpp | 66 ++ src/gui/kernel/qplatformscreen_qpa.h | 74 ++ src/gui/kernel/qplatformwindow_lite.cpp | 85 -- src/gui/kernel/qplatformwindow_lite.h | 90 --- src/gui/kernel/qplatformwindow_qpa.cpp | 85 ++ src/gui/kernel/qplatformwindow_qpa.h | 90 +++ src/gui/kernel/qsound_lite.cpp | 74 -- src/gui/kernel/qsound_qpa.cpp | 74 ++ src/gui/kernel/qwidget.cpp | 2 +- src/gui/kernel/qwidget_lite.cpp | 809 ------------------- src/gui/kernel/qwidget_qpa.cpp | 809 +++++++++++++++++++ src/gui/painting/painting.pri | 8 +- src/gui/painting/qcolormap_lite.cpp | 231 ------ src/gui/painting/qcolormap_qpa.cpp | 231 ++++++ src/gui/painting/qgraphicssystemcursor_lite.cpp | 664 ---------------- src/gui/painting/qgraphicssystemcursor_lite.h | 97 --- src/gui/painting/qgraphicssystemcursor_qpa.cpp | 664 ++++++++++++++++ src/gui/painting/qgraphicssystemcursor_qpa.h | 97 +++ src/gui/painting/qpaintdevice_lite.cpp | 68 -- src/gui/painting/qpaintdevice_qpa.cpp | 68 ++ src/gui/text/qfont.cpp | 2 +- src/opengl/opengl.pro | 2 +- src/opengl/qgl_lite.cpp | 253 ------ src/opengl/qgl_qpa.cpp | 253 ++++++ 74 files changed, 5497 insertions(+), 5497 deletions(-) delete mode 100644 src/gui/egl/qegl_lite.cpp create mode 100644 src/gui/egl/qegl_qpa.cpp delete mode 100644 src/gui/image/qpixmap_lite.cpp create mode 100644 src/gui/image/qpixmap_qpa.cpp delete mode 100644 src/gui/kernel/qapplication_lite.cpp create mode 100644 src/gui/kernel/qapplication_qpa.cpp delete mode 100644 src/gui/kernel/qclipboard_lite.cpp create mode 100644 src/gui/kernel/qclipboard_qpa.cpp delete mode 100644 src/gui/kernel/qcursor_lite.cpp create mode 100644 src/gui/kernel/qcursor_qpa.cpp delete mode 100644 src/gui/kernel/qdesktopwidget_lite.cpp delete mode 100644 src/gui/kernel/qdesktopwidget_lite_p.h create mode 100644 src/gui/kernel/qdesktopwidget_qpa.cpp create mode 100644 src/gui/kernel/qdesktopwidget_qpa_p.h delete mode 100644 src/gui/kernel/qeventdispatcher_glib_lite.cpp delete mode 100644 src/gui/kernel/qeventdispatcher_glib_lite_p.h create mode 100644 src/gui/kernel/qeventdispatcher_glib_qpa.cpp create mode 100644 src/gui/kernel/qeventdispatcher_glib_qpa_p.h delete mode 100644 src/gui/kernel/qeventdispatcher_lite.cpp delete mode 100644 src/gui/kernel/qeventdispatcher_lite_p.h create mode 100644 src/gui/kernel/qeventdispatcher_qpa.cpp create mode 100644 src/gui/kernel/qeventdispatcher_qpa_p.h delete mode 100644 src/gui/kernel/qgenericplugin_lite.cpp delete mode 100644 src/gui/kernel/qgenericplugin_lite.h create mode 100644 src/gui/kernel/qgenericplugin_qpa.cpp create mode 100644 src/gui/kernel/qgenericplugin_qpa.h delete mode 100644 src/gui/kernel/qgenericpluginfactory_lite.cpp delete mode 100644 src/gui/kernel/qgenericpluginfactory_lite.h create mode 100644 src/gui/kernel/qgenericpluginfactory_qpa.cpp create mode 100644 src/gui/kernel/qgenericpluginfactory_qpa.h delete mode 100644 src/gui/kernel/qplatformglcontext_lite.h create mode 100644 src/gui/kernel/qplatformglcontext_qpa.h delete mode 100644 src/gui/kernel/qplatformintegration_lite.cpp delete mode 100644 src/gui/kernel/qplatformintegration_lite.h create mode 100644 src/gui/kernel/qplatformintegration_qpa.cpp create mode 100644 src/gui/kernel/qplatformintegration_qpa.h delete mode 100644 src/gui/kernel/qplatformintegrationfactory_lite.cpp delete mode 100644 src/gui/kernel/qplatformintegrationfactory_lite_p.h create mode 100644 src/gui/kernel/qplatformintegrationfactory_qpa.cpp create mode 100644 src/gui/kernel/qplatformintegrationfactory_qpa_p.h delete mode 100644 src/gui/kernel/qplatformintegrationplugin_lite.cpp delete mode 100644 src/gui/kernel/qplatformintegrationplugin_lite.h create mode 100644 src/gui/kernel/qplatformintegrationplugin_qpa.cpp create mode 100644 src/gui/kernel/qplatformintegrationplugin_qpa.h delete mode 100644 src/gui/kernel/qplatformscreen_lite.cpp delete mode 100644 src/gui/kernel/qplatformscreen_lite.h create mode 100644 src/gui/kernel/qplatformscreen_qpa.cpp create mode 100644 src/gui/kernel/qplatformscreen_qpa.h delete mode 100644 src/gui/kernel/qplatformwindow_lite.cpp delete mode 100644 src/gui/kernel/qplatformwindow_lite.h create mode 100644 src/gui/kernel/qplatformwindow_qpa.cpp create mode 100644 src/gui/kernel/qplatformwindow_qpa.h delete mode 100644 src/gui/kernel/qsound_lite.cpp create mode 100644 src/gui/kernel/qsound_qpa.cpp delete mode 100644 src/gui/kernel/qwidget_lite.cpp create mode 100644 src/gui/kernel/qwidget_qpa.cpp delete mode 100644 src/gui/painting/qcolormap_lite.cpp create mode 100644 src/gui/painting/qcolormap_qpa.cpp delete mode 100644 src/gui/painting/qgraphicssystemcursor_lite.cpp delete mode 100644 src/gui/painting/qgraphicssystemcursor_lite.h create mode 100644 src/gui/painting/qgraphicssystemcursor_qpa.cpp create mode 100644 src/gui/painting/qgraphicssystemcursor_qpa.h delete mode 100644 src/gui/painting/qpaintdevice_lite.cpp create mode 100644 src/gui/painting/qpaintdevice_qpa.cpp delete mode 100644 src/opengl/qgl_lite.cpp create mode 100644 src/opengl/qgl_qpa.cpp diff --git a/src/gui/egl/egl.pri b/src/gui/egl/egl.pri index 253c091..476f1a3 100644 --- a/src/gui/egl/egl.pri +++ b/src/gui/egl/egl.pri @@ -29,7 +29,7 @@ contains(QT_CONFIG, egl): { SOURCES += egl/qegl_qws.cpp } else { embedded_lite { - SOURCES += egl/qegl_lite.cpp + SOURCES += egl/qegl_qpa.cpp } else { symbian { SOURCES += egl/qegl_symbian.cpp diff --git a/src/gui/egl/qegl_lite.cpp b/src/gui/egl/qegl_lite.cpp deleted file mode 100644 index 10caf46..0000000 --- a/src/gui/egl/qegl_lite.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#include "qeglcontext_p.h" - -#if !defined(QT_NO_EGL) - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -EGLNativeDisplayType QEgl::nativeDisplay() -{ - return EGLNativeDisplayType(EGL_DEFAULT_DISPLAY); -} - -EGLNativeWindowType QEgl::nativeWindow(QWidget* widget) -{ - return (EGLNativeWindowType)(widget->winId()); -} - -EGLNativePixmapType QEgl::nativePixmap(QPixmap* pixmap) -{ - Q_UNUSED(pixmap); - return 0; -} - -//EGLDisplay QEglContext::display() -//{ -// return eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY)); -//} - -static QPlatformScreen *screenForDevice(QPaintDevice *device) -{ - QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); - - QList screens = pi->screens(); - - int screenNumber; - if (device && device->devType() == QInternal::Widget) - screenNumber = qApp->desktop()->screenNumber(static_cast(device)); - else - screenNumber = 0; - if (screenNumber < 0 || screenNumber >= screens.size()) - return 0; - return screens[screenNumber]; -} - -// Set pixel format and other properties based on a paint device. -void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev) -{ - if (!dev) - return; - - // Find the QGLScreen for this paint device. - QPlatformScreen *screen = screenForDevice(dev); - if (!screen) - return; - int devType = dev->devType(); - if (devType == QInternal::Image) - setPixelFormat(static_cast(dev)->format()); - else - setPixelFormat(screen->format()); -} - -QT_END_NAMESPACE - -#endif // !QT_NO_EGL diff --git a/src/gui/egl/qegl_qpa.cpp b/src/gui/egl/qegl_qpa.cpp new file mode 100644 index 0000000..10caf46 --- /dev/null +++ b/src/gui/egl/qegl_qpa.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include +#include +#include "qeglcontext_p.h" + +#if !defined(QT_NO_EGL) + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +EGLNativeDisplayType QEgl::nativeDisplay() +{ + return EGLNativeDisplayType(EGL_DEFAULT_DISPLAY); +} + +EGLNativeWindowType QEgl::nativeWindow(QWidget* widget) +{ + return (EGLNativeWindowType)(widget->winId()); +} + +EGLNativePixmapType QEgl::nativePixmap(QPixmap* pixmap) +{ + Q_UNUSED(pixmap); + return 0; +} + +//EGLDisplay QEglContext::display() +//{ +// return eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY)); +//} + +static QPlatformScreen *screenForDevice(QPaintDevice *device) +{ + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + + QList screens = pi->screens(); + + int screenNumber; + if (device && device->devType() == QInternal::Widget) + screenNumber = qApp->desktop()->screenNumber(static_cast(device)); + else + screenNumber = 0; + if (screenNumber < 0 || screenNumber >= screens.size()) + return 0; + return screens[screenNumber]; +} + +// Set pixel format and other properties based on a paint device. +void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev) +{ + if (!dev) + return; + + // Find the QGLScreen for this paint device. + QPlatformScreen *screen = screenForDevice(dev); + if (!screen) + return; + int devType = dev->devType(); + if (devType == QInternal::Image) + setPixelFormat(static_cast(dev)->format()); + else + setPixelFormat(screen->format()); +} + +QT_END_NAMESPACE + +#endif // !QT_NO_EGL diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 1df66a0..064ba32 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -64,7 +64,7 @@ embedded { SOURCES += image/qpixmap_qws.cpp } embedded_lite { - SOURCES += image/qpixmap_lite.cpp + SOURCES += image/qpixmap_qpa.cpp } x11 { HEADERS += image/qpixmap_x11_p.h diff --git a/src/gui/image/qpixmap_lite.cpp b/src/gui/image/qpixmap_lite.cpp deleted file mode 100644 index 61be216..0000000 --- a/src/gui/image/qpixmap_lite.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include - -QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) -{ - return QApplicationPrivate::platformIntegration()->grabWindow(window, x, y, w, h); -} diff --git a/src/gui/image/qpixmap_qpa.cpp b/src/gui/image/qpixmap_qpa.cpp new file mode 100644 index 0000000..61be216 --- /dev/null +++ b/src/gui/image/qpixmap_qpa.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include +#include + +QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) +{ + return QApplicationPrivate::platformIntegration()->grabWindow(window, x, y, w, h); +} diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index f849ad7..dcdfd04 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -51,7 +51,7 @@ HEADERS += \ kernel/qsoftkeymanager_p.h \ kernel/qsoftkeymanager_common_p.h \ kernel/qguiplatformplugin_p.h \ - kernel/qdesktopwidget_lite_p.h + kernel/qdesktopwidget_qpa_p.h SOURCES += \ kernel/qaction.cpp \ @@ -200,41 +200,41 @@ embedded { embedded_lite { HEADERS += \ - kernel/qgenericpluginfactory_lite.h \ - kernel/qgenericplugin_lite.h \ - kernel/qeventdispatcher_lite_p.h \ + kernel/qgenericpluginfactory_qpa.h \ + kernel/qgenericplugin_qpa.h \ + kernel/qeventdispatcher_qpa_p.h \ kernel/qwindowsysteminterface.h \ - kernel/qplatformintegration_lite.h \ - kernel/qplatformscreen_lite.h \ - kernel/qplatformintegrationfactory_lite_p.h \ - kernel/qplatformintegrationplugin_lite.h \ - kernel/qplatformwindow_lite.h \ - kernel/qplatformglcontext_lite.h + kernel/qplatformintegration_qpa.h \ + kernel/qplatformscreen_qpa.h \ + kernel/qplatformintegrationfactory_qpa_p.h \ + kernel/qplatformintegrationplugin_qpa.h \ + kernel/qplatformwindow_qpa.h \ + kernel/qplatformglcontext_qpa.h SOURCES += \ - kernel/qapplication_lite.cpp \ - kernel/qclipboard_lite.cpp \ - kernel/qcursor_lite.cpp \ + kernel/qapplication_qpa.cpp \ + kernel/qclipboard_qpa.cpp \ + kernel/qcursor_qpa.cpp \ kernel/qdnd_qws.cpp \ - kernel/qdesktopwidget_lite.cpp \ - kernel/qgenericpluginfactory_lite.cpp \ - kernel/qgenericplugin_lite.cpp \ + kernel/qdesktopwidget_qpa.cpp \ + kernel/qgenericpluginfactory_qpa.cpp \ + kernel/qgenericplugin_qpa.cpp \ kernel/qkeymapper_qws.cpp \ - kernel/qsound_lite.cpp \ - kernel/qwidget_lite.cpp \ - kernel/qeventdispatcher_lite.cpp \ + kernel/qsound_qpa.cpp \ + kernel/qwidget_qpa.cpp \ + kernel/qeventdispatcher_qpa.cpp \ kernel/qwindowsysteminterface.cpp \ - kernel/qplatformintegration_lite.cpp \ - kernel/qplatformscreen_lite.cpp \ - kernel/qplatformintegrationfactory_lite.cpp \ - kernel/qplatformintegrationplugin_lite.cpp \ - kernel/qplatformwindow_lite.cpp + kernel/qplatformintegration_qpa.cpp \ + kernel/qplatformscreen_qpa.cpp \ + kernel/qplatformintegrationfactory_qpa.cpp \ + kernel/qplatformintegrationplugin_qpa.cpp \ + kernel/qplatformwindow_qpa.cpp contains(QT_CONFIG, glib) { SOURCES += \ - kernel/qeventdispatcher_glib_lite.cpp + kernel/qeventdispatcher_glib_qpa.cpp HEADERS += \ - kernel/qeventdispatcher_glib_lite_p.h + kernel/qeventdispatcher_glib_qpa_p.h QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB LIBS_PRIVATE +=$$QT_LIBS_GLIB } diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp deleted file mode 100644 index 9c36ef5..0000000 --- a/src/gui/kernel/qapplication_lite.cpp +++ /dev/null @@ -1,882 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 "qapplication_p.h" -#include "qcolormap.h" -#include "qpixmapcache.h" -#if !defined(QT_NO_GLIB) -#include "qeventdispatcher_glib_lite_p.h" -#endif -#include "qeventdispatcher_lite_p.h" -#ifndef QT_NO_CURSOR -#include "private/qcursor_p.h" -#endif - -#include "private/qwidget_p.h" - -#include "qgenericpluginfactory_lite.h" -#include "qplatformintegrationfactory_lite_p.h" -#include - -#include -#include -#include -#include -#include - -#include "qdesktopwidget_lite_p.h" - -QT_BEGIN_NAMESPACE - -static QString appName; -static const char *appFont = 0; // application font - -QWidget *qt_button_down = 0; // widget got last button-down - -static bool app_do_modal = false; -extern QWidgetList *qt_modal_stack; // stack of modal widgets - -int qt_last_x = 0; -int qt_last_y = 0; -QPointer qt_last_mouse_receiver = 0; - -static Qt::KeyboardModifiers modifiers = Qt::NoModifier; -static Qt::MouseButtons buttons = Qt::NoButton; -static ulong mousePressTime; -static Qt::MouseButton mousePressButton = Qt::NoButton; -static int mousePressX; -static int mousePressY; -static int mouse_double_click_distance = 5; - -void QApplicationPrivate::processUserEvent(QWindowSystemInterface::UserEvent *e) -{ - switch(e->type) { - case QEvent::MouseButtonDblClick: // if mouse event, calculate appropriate widget and local coordinates - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseMove: - QApplicationPrivate::processMouseEvent(static_cast(e)); - break; - case QEvent::Wheel: - QApplicationPrivate::processWheelEvent(static_cast(e)); - break; - case QEvent::KeyPress: - case QEvent::KeyRelease: - QApplicationPrivate::processKeyEvent(static_cast(e)); - break; - case QEvent::TouchBegin: - case QEvent::TouchUpdate: - case QEvent::TouchEnd: - QApplicationPrivate::processTouchEvent(static_cast(e)); - break; - default: - qWarning() << "Unknown user input event type:" << e->type; - break; - } -} - -QString QApplicationPrivate::appName() const -{ - return QT_PREPEND_NAMESPACE(appName); -} - -void QApplicationPrivate::createEventDispatcher() -{ - Q_Q(QApplication); -#if !defined(QT_NO_GLIB) - if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported()) - eventDispatcher = new QLiteEventDispatcherGlib(q); - else -#endif - eventDispatcher = new QEventDispatcherLite(q); -} - -static bool qt_try_modal(QWidget *widget, QEvent::Type type) -{ - QWidget * top = 0; - - if (QApplicationPrivate::tryModalHelper(widget, &top)) - return true; - - bool block_event = false; - bool paint_event = false; - - switch (type) { -#if 0 - case QEvent::Focus: - if (!static_cast(event)->simpleData.get_focus) - break; - // drop through -#endif - case QEvent::MouseButtonPress: // disallow mouse/key events - case QEvent::MouseButtonRelease: - case QEvent::MouseMove: - case QEvent::KeyPress: - case QEvent::KeyRelease: - block_event = true; - break; - default: - break; - } - - if ((block_event || paint_event) && top->parentWidget() == 0) - top->raise(); - - return !block_event; -} - - - -void QApplicationPrivate::enterModal_sys(QWidget *widget) -{ - if (!qt_modal_stack) - qt_modal_stack = new QWidgetList; - qt_modal_stack->insert(0, widget); - app_do_modal = true; -} - -void QApplicationPrivate::leaveModal_sys(QWidget *widget ) -{ - if (qt_modal_stack && qt_modal_stack->removeAll(widget)) { - if (qt_modal_stack->isEmpty()) { - delete qt_modal_stack; - qt_modal_stack = 0; - } - } - app_do_modal = qt_modal_stack != 0; -} - -bool QApplicationPrivate::modalState() -{ - return app_do_modal; -} - -void QApplicationPrivate::closePopup(QWidget *popup) -{ - Q_Q(QApplication); - if (!popupWidgets) - return; - popupWidgets->removeAll(popup); - -//### -// if (popup == qt_popup_down) { -// qt_button_down = 0; -// qt_popup_down = 0; -// } - - if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup - delete QApplicationPrivate::popupWidgets; - QApplicationPrivate::popupWidgets = 0; - - //### replay mouse event? - - //### transfer/release mouse grab - - //### transfer/release keyboard grab - - //give back focus - - if (active_window) { - if (QWidget *fw = active_window->focusWidget()) { - if (fw != QApplication::focusWidget()) { - fw->setFocus(Qt::PopupFocusReason); - } else { - QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason); - q->sendEvent(fw, &e); - } - } - } - - } else { - // A popup was closed, so the previous popup gets the focus. - - QWidget* aw = QApplicationPrivate::popupWidgets->last(); - if (QWidget *fw = aw->focusWidget()) - fw->setFocus(Qt::PopupFocusReason); - - //### regrab the keyboard and mouse in case 'popup' lost the grab - - - } - -} - -static int openPopupCount = 0; -void QApplicationPrivate::openPopup(QWidget *popup) -{ - openPopupCount++; - if (!popupWidgets) { // create list - popupWidgets = new QWidgetList; - - /* only grab if you are the first/parent popup */ - //#### ->grabMouse(popup,true); - //#### ->grabKeyboard(popup,true); - //### popupGrabOk = true; - } - popupWidgets->append(popup); // add to end of list - - // popups are not focus-handled by the window system (the first - // popup grabbed the keyboard), so we have to do that manually: A - // new popup gets the focus - if (popup->focusWidget()) { - popup->focusWidget()->setFocus(Qt::PopupFocusReason); - } else if (popupWidgets->count() == 1) { // this was the first popup - if (QWidget *fw = QApplication::focusWidget()) { - QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); - QApplication::sendEvent(fw, &e); - } - } -} - -void QApplicationPrivate::initializeMultitouch_sys() -{ -} - -void QApplicationPrivate::cleanupMultitouch_sys() -{ -} - -void QApplicationPrivate::initializeWidgetPaletteHash() -{ -} - -void QApplication::setCursorFlashTime(int msecs) -{ - QApplicationPrivate::cursor_flash_time = msecs; -} - -int QApplication::cursorFlashTime() -{ - return QApplicationPrivate::cursor_flash_time; -} - -void QApplication::setDoubleClickInterval(int ms) -{ - QApplicationPrivate::mouse_double_click_time = ms; -} - -int QApplication::doubleClickInterval() -{ - return QApplicationPrivate::mouse_double_click_time; -} - -void QApplication::setKeyboardInputInterval(int ms) -{ - QApplicationPrivate::keyboard_input_time = ms; -} - -int QApplication::keyboardInputInterval() -{ - return QApplicationPrivate::keyboard_input_time; -} - -#ifndef QT_NO_WHEELEVENT -void QApplication::setWheelScrollLines(int lines) -{ - QApplicationPrivate::wheel_scroll_lines = lines; -} - -int QApplication::wheelScrollLines() -{ - return QApplicationPrivate::wheel_scroll_lines; -} -#endif - -void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable) -{ - switch (effect) { - case Qt::UI_AnimateMenu: - QApplicationPrivate::animate_menu = enable; - break; - case Qt::UI_FadeMenu: - if (enable) - QApplicationPrivate::animate_menu = true; - QApplicationPrivate::fade_menu = enable; - break; - case Qt::UI_AnimateCombo: - QApplicationPrivate::animate_combo = enable; - break; - case Qt::UI_AnimateTooltip: - QApplicationPrivate::animate_tooltip = enable; - break; - case Qt::UI_FadeTooltip: - if (enable) - QApplicationPrivate::animate_tooltip = true; - QApplicationPrivate::fade_tooltip = enable; - break; - case Qt::UI_AnimateToolBox: - QApplicationPrivate::animate_toolbox = enable; - break; - default: - QApplicationPrivate::animate_ui = enable; - break; - } -} - -bool QApplication::isEffectEnabled(Qt::UIEffect effect) -{ - if (QColormap::instance().depth() < 16 || !QApplicationPrivate::animate_ui) - return false; - - switch(effect) { - case Qt::UI_AnimateMenu: - return QApplicationPrivate::animate_menu; - case Qt::UI_FadeMenu: - return QApplicationPrivate::fade_menu; - case Qt::UI_AnimateCombo: - return QApplicationPrivate::animate_combo; - case Qt::UI_AnimateTooltip: - return QApplicationPrivate::animate_tooltip; - case Qt::UI_FadeTooltip: - return QApplicationPrivate::fade_tooltip; - case Qt::UI_AnimateToolBox: - return QApplicationPrivate::animate_toolbox; - default: - return QApplicationPrivate::animate_ui; - } -} - -#ifndef QT_NO_CURSOR -void QApplication::setOverrideCursor(const QCursor &cursor) -{ - qApp->d_func()->cursor_list.prepend(cursor); - qt_lite_set_cursor(0, false); -} - -void QApplication::restoreOverrideCursor() -{ - if (qApp->d_func()->cursor_list.isEmpty()) - return; - qApp->d_func()->cursor_list.removeFirst(); - qt_lite_set_cursor(0, false); -} - -#endif// QT_NO_CURSOR - -QWidget *QApplication::topLevelAt(const QPoint &pos) -{ - QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); - - QList screens = pi->screens(); - QList::const_iterator screen = screens.constBegin(); - QList::const_iterator end = screens.constEnd(); - - // The first screen in a virtual environment should know about all top levels - if (pi->isVirtualDesktop()) { - QWidget *w = (*screen)->topLevelAt(pos); - return w; - } - - while (screen != end) { - if ((*screen)->geometry().contains(pos)) - return (*screen)->topLevelAt(pos); - ++screen; - } - return 0; -} - -void QApplication::beep() -{ -} - -void QApplication::alert(QWidget *, int) -{ -} - -static void init_platform(const QString &name) -{ - QApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name); - if (!QApplicationPrivate::platform_integration) { - QStringList keys = QPlatformIntegrationFactory::keys(); - QString fatalMessage = - QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name); - foreach(QString key, keys) { - fatalMessage.append(key + QString::fromLatin1("\n")); - } - qFatal("%s", fatalMessage.toLocal8Bit().constData()); - - } - -} - - -static void cleanup_platform() -{ - delete QApplicationPrivate::platform_integration; - QApplicationPrivate::platform_integration = 0; -} - -static void init_plugins(const QList pluginList) -{ - for (int i = 0; i < pluginList.count(); ++i) { - QByteArray pluginSpec = pluginList.at(i); - qDebug() << "init_plugins" << i << pluginSpec; - int colonPos = pluginSpec.indexOf(':'); - QObject *plugin; - if (colonPos < 0) - plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString()); - else - plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)), - QLatin1String(pluginSpec.mid(colonPos+1))); - qDebug() << " created" << plugin; - } -} - -#ifndef QT_NO_QWS_INPUTMETHODS -class QDummyInputContext : public QInputContext -{ -public: - explicit QDummyInputContext(QObject* parent = 0) : QInputContext(parent) {} - ~QDummyInputContext() {} - QString identifierName() { return QString(); } - QString language() { return QString(); } - - void reset() {} - bool isComposing() const { return false; } - -}; -#endif // QT_NO_QWS_INPUTMETHODS - -void qt_init(QApplicationPrivate *priv, int type) -{ - Q_UNUSED(type); - - qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); - char *p; - char **argv = priv->argv; - int argc = priv->argc; - - if (argv && *argv) { //apparently, we allow people to pass 0 on the other platforms - p = strrchr(argv[0], '/'); - appName = QString::fromLocal8Bit(p ? p + 1 : argv[0]); - } - - QList pluginList; - QString platformName = qgetenv("QT_LITE_PLATFORM"); - - // Get command line params - - int j = argc ? 1 : 0; - for (int i=1; iargc) { - priv->argv[j] = 0; - priv->argc = j; - } - -#if 0 - QByteArray pluginEnv = qgetenv("QT_LITE_PLUGINS"); - if (!pluginEnv.isEmpty()) { - pluginList.append(pluginEnv.split(';')); - } -#endif - - init_platform(platformName); - init_plugins(pluginList); - - QColormap::initialize(); - QFont::initialize(); -#ifndef QT_NO_CURSOR -// QCursorData::initialize(); -#endif - - qApp->setObjectName(appName); - -#ifndef QT_NO_QWS_INPUTMETHODS - qApp->setInputContext(new QDummyInputContext(qApp)); -#endif -} - -void qt_cleanup() -{ - cleanup_platform(); - - QPixmapCache::clear(); -#ifndef QT_NO_CURSOR - QCursorData::cleanup(); -#endif - QFont::cleanup(); - QColormap::cleanup(); - delete QApplicationPrivate::inputContext; - QApplicationPrivate::inputContext = 0; - - QApplicationPrivate::active_window = 0; //### this should not be necessary -} - - -#ifdef QT3_SUPPORT -void QApplication::setMainWidget(QWidget *mainWidget) -{ - QApplicationPrivate::main_widget = mainWidget; - if (QApplicationPrivate::main_widget && windowIcon().isNull() - && QApplicationPrivate::main_widget->testAttribute(Qt::WA_SetWindowIcon)) - setWindowIcon(QApplicationPrivate::main_widget->windowIcon()); -} -#endif - -void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent *e) -{ - // qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons(); - static QWeakPointer implicit_mouse_grabber; - - QEvent::Type type; - // move first - Qt::MouseButtons stateChange = e->buttons ^ buttons; - if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) { - QWindowSystemInterface::MouseEvent * newMouseEvent = new QWindowSystemInterface::MouseEvent(e->widget.data(), e->timestamp, e->localPos, e->globalPos, e->buttons); - QWindowSystemInterfacePrivate::userEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop - stateChange = Qt::NoButton; - } - - QWidget * tlw = e->widget.data(); - - QPoint localPoint = e->localPos; - QPoint globalPoint = e->globalPos; - QWidget *mouseWindow = tlw; - - Qt::MouseButton button = Qt::NoButton; - - - if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) { - type = QEvent::MouseMove; - qt_last_x = globalPoint.x(); - qt_last_y = globalPoint.y(); - if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance|| - qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance) - mousePressButton = Qt::NoButton; - } - else { // check to see if a new button has been pressed/released - for (int check = Qt::LeftButton; - check <= Qt::XButton2; - check = check << 1) { - if (check & stateChange) { - button = Qt::MouseButton(check); - break; - } - } - if (button == Qt::NoButton) { - // Ignore mouse events that don't change the current state - return; - } - buttons = e->buttons; - if (button & e->buttons) { - if ((e->timestamp - mousePressTime) < static_cast(QApplication::doubleClickInterval()) && button == mousePressButton) { - type = QEvent::MouseButtonDblClick; - mousePressButton = Qt::NoButton; - } - else { - type = QEvent::MouseButtonPress; - mousePressTime = e->timestamp; - mousePressButton = button; - mousePressX = qt_last_x; - mousePressY = qt_last_y; - } - } - else - type = QEvent::MouseButtonRelease; - } - - if (self->inPopupMode()) { - //popup mouse handling is magical... - mouseWindow = qApp->activePopupWidget(); - - implicit_mouse_grabber.clear(); - //### how should popup mode and implicit mouse grab interact? - - } else if (tlw && app_do_modal && !qt_try_modal(tlw, e->type) ) { - //even if we're blocked by modality, we should deliver the mouse release event.. - //### this code is not completely correct: multiple buttons can be pressed simultaneously - if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) { - //qDebug() << "modal blocked mouse event to" << tlw; - return; - } - } - - // find the tlw if we didn't get it from the plugin - if (!mouseWindow) { - mouseWindow = QApplication::topLevelAt(globalPoint); - } - - if (!mouseWindow && !implicit_mouse_grabber) - mouseWindow = QApplication::desktop(); - - if (mouseWindow && mouseWindow != tlw) { - //we did not get a sensible localPoint from the window system, so let's calculate it - localPoint = mouseWindow->mapFromGlobal(globalPoint); - } - - // which child should have it? - QWidget *mouseWidget = mouseWindow; - if (mouseWindow) { - QWidget *w = mouseWindow->childAt(localPoint); - if (w) { - mouseWidget = w; - } - } - - //handle implicit mouse grab - if (type == QEvent::MouseButtonPress && !implicit_mouse_grabber) { - implicit_mouse_grabber = mouseWidget; - - Q_ASSERT(mouseWindow); - mouseWindow->activateWindow(); //focus - } else if (implicit_mouse_grabber) { - mouseWidget = implicit_mouse_grabber.data(); - mouseWindow = mouseWidget->window(); - if (mouseWindow != tlw) - localPoint = mouseWindow->mapFromGlobal(globalPoint); - } - - Q_ASSERT(mouseWidget); - - //localPoint is local to mouseWindow, but it needs to be local to mouseWidget - localPoint = mouseWidget->mapFrom(mouseWindow, localPoint); - - if (buttons == Qt::NoButton) { - //qDebug() << "resetting mouse grabber"; - implicit_mouse_grabber.clear(); - } - - if (mouseWidget != qt_last_mouse_receiver) { - dispatchEnterLeave(mouseWidget, qt_last_mouse_receiver); - qt_last_mouse_receiver = mouseWidget; - } - - // Remember, we might enter a modal event loop when sending the event, - // so think carefully before adding code below this point. - - // qDebug() << "sending mouse ev." << ev.type() << localPoint << globalPoint << ev.button() << ev.buttons() << mouseWidget << "mouse grabber" << implicit_mouse_grabber; - - QMouseEvent ev(type, localPoint, globalPoint, button, buttons, modifiers); - - QList > cursors = QGraphicsSystemCursorPrivate::getInstances(); - foreach (QWeakPointer cursor, cursors) { - if (cursor) - cursor.data()->pointerEvent(ev); - } - - QApplication::sendSpontaneousEvent(mouseWidget, &ev); -} - - -//### there's a lot of duplicated logic here -- refactoring required! - -void QApplicationPrivate::processWheelEvent(QWindowSystemInterface::WheelEvent *e) -{ -// QPoint localPoint = ev.pos(); - QPoint globalPoint = e->globalPos; -// bool trustLocalPoint = !!tlw; //is there something the local point can be local to? - QWidget *mouseWidget; - - qt_last_x = globalPoint.x(); - qt_last_y = globalPoint.y(); - - QWidget *mouseWindow = e->widget.data(); - - // find the tlw if we didn't get it from the plugin - if (!mouseWindow) { - mouseWindow = QApplication::topLevelAt(globalPoint); - } - - if (!mouseWindow) - return; - - mouseWidget = mouseWindow; - - if (app_do_modal && !qt_try_modal(mouseWindow, e->type) ) { - qDebug() << "modal blocked wheel event" << mouseWindow; - return; - } - QPoint p = mouseWindow->mapFromGlobal(globalPoint); - QWidget *w = mouseWindow->childAt(p); - if (w) { - mouseWidget = w; - p = mouseWidget->mapFromGlobal(globalPoint); - } - - QWheelEvent ev(p, globalPoint, e->delta, buttons, modifiers, - e->orient); - QApplication::sendSpontaneousEvent(mouseWidget, &ev); -} - - - -// Remember, Qt convention is: keyboard state is state *before* - -void QApplicationPrivate::processKeyEvent(QWindowSystemInterface::KeyEvent *e) -{ - QWidget *focusW = 0; - if (self->inPopupMode()) { - QWidget *popupW = qApp->activePopupWidget(); - focusW = popupW->focusWidget() ? popupW->focusWidget() : popupW; - } - if (!focusW) - focusW = QApplication::focusWidget(); - if (!focusW) { - focusW = e->widget.data(); - } - if (!focusW) - focusW = QApplication::activeWindow(); - - //qDebug() << "handleKeyEvent" << hex << e->key() << e->modifiers() << e->text() << "widget" << focusW; - - if (!focusW) - return; - if (app_do_modal && !qt_try_modal(focusW, e->type)) - return; - - modifiers = e->modifiers; - QKeyEvent ev(e->type, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount); - QApplication::sendSpontaneousEvent(focusW, &ev); -} - -void QApplicationPrivate::processGeometryChange(QWidget *tlw, const QRect &newRect) -{ - if (!tlw->isWindow()) - return; //geo of native child widgets is controlled by lighthouse - //so we already have sent the events; besides this new rect - //is not mapped to parent - - QRect cr(tlw->geometry()); - - bool isResize = cr.size() != newRect.size(); - bool isMove = cr.topLeft() != newRect.topLeft(); - tlw->data->crect = newRect; - if (isResize) { - QResizeEvent e(tlw->data->crect.size(), cr.size()); - QApplication::sendSpontaneousEvent(tlw, &e); - tlw->update(); - } - - if (isMove) { - //### frame geometry - QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft()); - QApplication::sendSpontaneousEvent(tlw, &e); - } -} - -void QApplicationPrivate::processCloseEvent(QWidget *tlw) -{ - tlw->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent); -} - -void QApplicationPrivate::processTouchEvent(QWindowSystemInterface::TouchEvent *e) -{ - translateRawTouchEvent(e->widget.data(), e->devType, e->points); -} - -void QApplicationPrivate::reportScreenCount(int count) -{ - // This operation only makes sense after the QApplication constructor runs - if (QCoreApplication::startingUp()) - return; - - QApplication::desktop()->d_func()->updateScreenList(); - // signal anything listening for creation or deletion of screens - QDesktopWidget *desktop = QApplication::desktop(); - emit desktop->screenCountChanged(count); -} - -void QApplicationPrivate::reportGeometryChange(int screenIndex) -{ - // This operation only makes sense after the QApplication constructor runs - if (QCoreApplication::startingUp()) - return; - - QApplication::desktop()->d_func()->updateScreenList(); - - // signal anything listening for screen geometry changes - QDesktopWidget *desktop = QApplication::desktop(); - emit desktop->resized(screenIndex); - - // make sure maximized and fullscreen windows are updated - QWidgetList list = QApplication::topLevelWidgets(); - for (int i = list.size() - 1; i >= 0; --i) { - QWidget *w = list.at(i); - if (w->isFullScreen()) - w->d_func()->setFullScreenSize_helper(); - else if (w->isMaximized()) - w->d_func()->setMaxWindowState_helper(); - } -} - -void QApplicationPrivate::reportAvailableGeometryChange(int screenIndex) -{ - // This operation only makes sense after the QApplication constructor runs - if (QCoreApplication::startingUp()) - return; - - QApplication::desktop()->d_func()->updateScreenList(); - - // signal anything listening for screen geometry changes - QDesktopWidget *desktop = QApplication::desktop(); - emit desktop->workAreaResized(screenIndex); - - // make sure maximized and fullscreen windows are updated - QWidgetList list = QApplication::topLevelWidgets(); - for (int i = list.size() - 1; i >= 0; --i) { - QWidget *w = list.at(i); - if (w->isFullScreen()) - w->d_func()->setFullScreenSize_helper(); - else if (w->isMaximized()) - w->d_func()->setMaxWindowState_helper(); - } -} - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index ecfac78..7d98f4d 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -78,7 +78,7 @@ #endif #ifdef Q_WS_QPA #include -#include "QtGui/qplatformintegration_lite.h" +#include "QtGui/qplatformintegration_qpa.h" #endif QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp new file mode 100644 index 0000000..afa069b --- /dev/null +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -0,0 +1,882 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "qapplication_p.h" +#include "qcolormap.h" +#include "qpixmapcache.h" +#if !defined(QT_NO_GLIB) +#include "qeventdispatcher_glib_qpa_p.h" +#endif +#include "qeventdispatcher_qpa_p.h" +#ifndef QT_NO_CURSOR +#include "private/qcursor_p.h" +#endif + +#include "private/qwidget_p.h" + +#include "qgenericpluginfactory_qpa.h" +#include "qplatformintegrationfactory_qpa_p.h" +#include + +#include +#include +#include +#include +#include + +#include "qdesktopwidget_qpa_p.h" + +QT_BEGIN_NAMESPACE + +static QString appName; +static const char *appFont = 0; // application font + +QWidget *qt_button_down = 0; // widget got last button-down + +static bool app_do_modal = false; +extern QWidgetList *qt_modal_stack; // stack of modal widgets + +int qt_last_x = 0; +int qt_last_y = 0; +QPointer qt_last_mouse_receiver = 0; + +static Qt::KeyboardModifiers modifiers = Qt::NoModifier; +static Qt::MouseButtons buttons = Qt::NoButton; +static ulong mousePressTime; +static Qt::MouseButton mousePressButton = Qt::NoButton; +static int mousePressX; +static int mousePressY; +static int mouse_double_click_distance = 5; + +void QApplicationPrivate::processUserEvent(QWindowSystemInterface::UserEvent *e) +{ + switch(e->type) { + case QEvent::MouseButtonDblClick: // if mouse event, calculate appropriate widget and local coordinates + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + QApplicationPrivate::processMouseEvent(static_cast(e)); + break; + case QEvent::Wheel: + QApplicationPrivate::processWheelEvent(static_cast(e)); + break; + case QEvent::KeyPress: + case QEvent::KeyRelease: + QApplicationPrivate::processKeyEvent(static_cast(e)); + break; + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: + QApplicationPrivate::processTouchEvent(static_cast(e)); + break; + default: + qWarning() << "Unknown user input event type:" << e->type; + break; + } +} + +QString QApplicationPrivate::appName() const +{ + return QT_PREPEND_NAMESPACE(appName); +} + +void QApplicationPrivate::createEventDispatcher() +{ + Q_Q(QApplication); +#if !defined(QT_NO_GLIB) + if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported()) + eventDispatcher = new QLiteEventDispatcherGlib(q); + else +#endif + eventDispatcher = new QEventDispatcherLite(q); +} + +static bool qt_try_modal(QWidget *widget, QEvent::Type type) +{ + QWidget * top = 0; + + if (QApplicationPrivate::tryModalHelper(widget, &top)) + return true; + + bool block_event = false; + bool paint_event = false; + + switch (type) { +#if 0 + case QEvent::Focus: + if (!static_cast(event)->simpleData.get_focus) + break; + // drop through +#endif + case QEvent::MouseButtonPress: // disallow mouse/key events + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + case QEvent::KeyPress: + case QEvent::KeyRelease: + block_event = true; + break; + default: + break; + } + + if ((block_event || paint_event) && top->parentWidget() == 0) + top->raise(); + + return !block_event; +} + + + +void QApplicationPrivate::enterModal_sys(QWidget *widget) +{ + if (!qt_modal_stack) + qt_modal_stack = new QWidgetList; + qt_modal_stack->insert(0, widget); + app_do_modal = true; +} + +void QApplicationPrivate::leaveModal_sys(QWidget *widget ) +{ + if (qt_modal_stack && qt_modal_stack->removeAll(widget)) { + if (qt_modal_stack->isEmpty()) { + delete qt_modal_stack; + qt_modal_stack = 0; + } + } + app_do_modal = qt_modal_stack != 0; +} + +bool QApplicationPrivate::modalState() +{ + return app_do_modal; +} + +void QApplicationPrivate::closePopup(QWidget *popup) +{ + Q_Q(QApplication); + if (!popupWidgets) + return; + popupWidgets->removeAll(popup); + +//### +// if (popup == qt_popup_down) { +// qt_button_down = 0; +// qt_popup_down = 0; +// } + + if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup + delete QApplicationPrivate::popupWidgets; + QApplicationPrivate::popupWidgets = 0; + + //### replay mouse event? + + //### transfer/release mouse grab + + //### transfer/release keyboard grab + + //give back focus + + if (active_window) { + if (QWidget *fw = active_window->focusWidget()) { + if (fw != QApplication::focusWidget()) { + fw->setFocus(Qt::PopupFocusReason); + } else { + QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason); + q->sendEvent(fw, &e); + } + } + } + + } else { + // A popup was closed, so the previous popup gets the focus. + + QWidget* aw = QApplicationPrivate::popupWidgets->last(); + if (QWidget *fw = aw->focusWidget()) + fw->setFocus(Qt::PopupFocusReason); + + //### regrab the keyboard and mouse in case 'popup' lost the grab + + + } + +} + +static int openPopupCount = 0; +void QApplicationPrivate::openPopup(QWidget *popup) +{ + openPopupCount++; + if (!popupWidgets) { // create list + popupWidgets = new QWidgetList; + + /* only grab if you are the first/parent popup */ + //#### ->grabMouse(popup,true); + //#### ->grabKeyboard(popup,true); + //### popupGrabOk = true; + } + popupWidgets->append(popup); // add to end of list + + // popups are not focus-handled by the window system (the first + // popup grabbed the keyboard), so we have to do that manually: A + // new popup gets the focus + if (popup->focusWidget()) { + popup->focusWidget()->setFocus(Qt::PopupFocusReason); + } else if (popupWidgets->count() == 1) { // this was the first popup + if (QWidget *fw = QApplication::focusWidget()) { + QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); + QApplication::sendEvent(fw, &e); + } + } +} + +void QApplicationPrivate::initializeMultitouch_sys() +{ +} + +void QApplicationPrivate::cleanupMultitouch_sys() +{ +} + +void QApplicationPrivate::initializeWidgetPaletteHash() +{ +} + +void QApplication::setCursorFlashTime(int msecs) +{ + QApplicationPrivate::cursor_flash_time = msecs; +} + +int QApplication::cursorFlashTime() +{ + return QApplicationPrivate::cursor_flash_time; +} + +void QApplication::setDoubleClickInterval(int ms) +{ + QApplicationPrivate::mouse_double_click_time = ms; +} + +int QApplication::doubleClickInterval() +{ + return QApplicationPrivate::mouse_double_click_time; +} + +void QApplication::setKeyboardInputInterval(int ms) +{ + QApplicationPrivate::keyboard_input_time = ms; +} + +int QApplication::keyboardInputInterval() +{ + return QApplicationPrivate::keyboard_input_time; +} + +#ifndef QT_NO_WHEELEVENT +void QApplication::setWheelScrollLines(int lines) +{ + QApplicationPrivate::wheel_scroll_lines = lines; +} + +int QApplication::wheelScrollLines() +{ + return QApplicationPrivate::wheel_scroll_lines; +} +#endif + +void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable) +{ + switch (effect) { + case Qt::UI_AnimateMenu: + QApplicationPrivate::animate_menu = enable; + break; + case Qt::UI_FadeMenu: + if (enable) + QApplicationPrivate::animate_menu = true; + QApplicationPrivate::fade_menu = enable; + break; + case Qt::UI_AnimateCombo: + QApplicationPrivate::animate_combo = enable; + break; + case Qt::UI_AnimateTooltip: + QApplicationPrivate::animate_tooltip = enable; + break; + case Qt::UI_FadeTooltip: + if (enable) + QApplicationPrivate::animate_tooltip = true; + QApplicationPrivate::fade_tooltip = enable; + break; + case Qt::UI_AnimateToolBox: + QApplicationPrivate::animate_toolbox = enable; + break; + default: + QApplicationPrivate::animate_ui = enable; + break; + } +} + +bool QApplication::isEffectEnabled(Qt::UIEffect effect) +{ + if (QColormap::instance().depth() < 16 || !QApplicationPrivate::animate_ui) + return false; + + switch(effect) { + case Qt::UI_AnimateMenu: + return QApplicationPrivate::animate_menu; + case Qt::UI_FadeMenu: + return QApplicationPrivate::fade_menu; + case Qt::UI_AnimateCombo: + return QApplicationPrivate::animate_combo; + case Qt::UI_AnimateTooltip: + return QApplicationPrivate::animate_tooltip; + case Qt::UI_FadeTooltip: + return QApplicationPrivate::fade_tooltip; + case Qt::UI_AnimateToolBox: + return QApplicationPrivate::animate_toolbox; + default: + return QApplicationPrivate::animate_ui; + } +} + +#ifndef QT_NO_CURSOR +void QApplication::setOverrideCursor(const QCursor &cursor) +{ + qApp->d_func()->cursor_list.prepend(cursor); + qt_lite_set_cursor(0, false); +} + +void QApplication::restoreOverrideCursor() +{ + if (qApp->d_func()->cursor_list.isEmpty()) + return; + qApp->d_func()->cursor_list.removeFirst(); + qt_lite_set_cursor(0, false); +} + +#endif// QT_NO_CURSOR + +QWidget *QApplication::topLevelAt(const QPoint &pos) +{ + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + + QList screens = pi->screens(); + QList::const_iterator screen = screens.constBegin(); + QList::const_iterator end = screens.constEnd(); + + // The first screen in a virtual environment should know about all top levels + if (pi->isVirtualDesktop()) { + QWidget *w = (*screen)->topLevelAt(pos); + return w; + } + + while (screen != end) { + if ((*screen)->geometry().contains(pos)) + return (*screen)->topLevelAt(pos); + ++screen; + } + return 0; +} + +void QApplication::beep() +{ +} + +void QApplication::alert(QWidget *, int) +{ +} + +static void init_platform(const QString &name) +{ + QApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name); + if (!QApplicationPrivate::platform_integration) { + QStringList keys = QPlatformIntegrationFactory::keys(); + QString fatalMessage = + QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name); + foreach(QString key, keys) { + fatalMessage.append(key + QString::fromLatin1("\n")); + } + qFatal("%s", fatalMessage.toLocal8Bit().constData()); + + } + +} + + +static void cleanup_platform() +{ + delete QApplicationPrivate::platform_integration; + QApplicationPrivate::platform_integration = 0; +} + +static void init_plugins(const QList pluginList) +{ + for (int i = 0; i < pluginList.count(); ++i) { + QByteArray pluginSpec = pluginList.at(i); + qDebug() << "init_plugins" << i << pluginSpec; + int colonPos = pluginSpec.indexOf(':'); + QObject *plugin; + if (colonPos < 0) + plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString()); + else + plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)), + QLatin1String(pluginSpec.mid(colonPos+1))); + qDebug() << " created" << plugin; + } +} + +#ifndef QT_NO_QWS_INPUTMETHODS +class QDummyInputContext : public QInputContext +{ +public: + explicit QDummyInputContext(QObject* parent = 0) : QInputContext(parent) {} + ~QDummyInputContext() {} + QString identifierName() { return QString(); } + QString language() { return QString(); } + + void reset() {} + bool isComposing() const { return false; } + +}; +#endif // QT_NO_QWS_INPUTMETHODS + +void qt_init(QApplicationPrivate *priv, int type) +{ + Q_UNUSED(type); + + qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); + char *p; + char **argv = priv->argv; + int argc = priv->argc; + + if (argv && *argv) { //apparently, we allow people to pass 0 on the other platforms + p = strrchr(argv[0], '/'); + appName = QString::fromLocal8Bit(p ? p + 1 : argv[0]); + } + + QList pluginList; + QString platformName = qgetenv("QT_LITE_PLATFORM"); + + // Get command line params + + int j = argc ? 1 : 0; + for (int i=1; iargc) { + priv->argv[j] = 0; + priv->argc = j; + } + +#if 0 + QByteArray pluginEnv = qgetenv("QT_LITE_PLUGINS"); + if (!pluginEnv.isEmpty()) { + pluginList.append(pluginEnv.split(';')); + } +#endif + + init_platform(platformName); + init_plugins(pluginList); + + QColormap::initialize(); + QFont::initialize(); +#ifndef QT_NO_CURSOR +// QCursorData::initialize(); +#endif + + qApp->setObjectName(appName); + +#ifndef QT_NO_QWS_INPUTMETHODS + qApp->setInputContext(new QDummyInputContext(qApp)); +#endif +} + +void qt_cleanup() +{ + cleanup_platform(); + + QPixmapCache::clear(); +#ifndef QT_NO_CURSOR + QCursorData::cleanup(); +#endif + QFont::cleanup(); + QColormap::cleanup(); + delete QApplicationPrivate::inputContext; + QApplicationPrivate::inputContext = 0; + + QApplicationPrivate::active_window = 0; //### this should not be necessary +} + + +#ifdef QT3_SUPPORT +void QApplication::setMainWidget(QWidget *mainWidget) +{ + QApplicationPrivate::main_widget = mainWidget; + if (QApplicationPrivate::main_widget && windowIcon().isNull() + && QApplicationPrivate::main_widget->testAttribute(Qt::WA_SetWindowIcon)) + setWindowIcon(QApplicationPrivate::main_widget->windowIcon()); +} +#endif + +void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent *e) +{ + // qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons(); + static QWeakPointer implicit_mouse_grabber; + + QEvent::Type type; + // move first + Qt::MouseButtons stateChange = e->buttons ^ buttons; + if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) { + QWindowSystemInterface::MouseEvent * newMouseEvent = new QWindowSystemInterface::MouseEvent(e->widget.data(), e->timestamp, e->localPos, e->globalPos, e->buttons); + QWindowSystemInterfacePrivate::userEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop + stateChange = Qt::NoButton; + } + + QWidget * tlw = e->widget.data(); + + QPoint localPoint = e->localPos; + QPoint globalPoint = e->globalPos; + QWidget *mouseWindow = tlw; + + Qt::MouseButton button = Qt::NoButton; + + + if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) { + type = QEvent::MouseMove; + qt_last_x = globalPoint.x(); + qt_last_y = globalPoint.y(); + if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance|| + qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance) + mousePressButton = Qt::NoButton; + } + else { // check to see if a new button has been pressed/released + for (int check = Qt::LeftButton; + check <= Qt::XButton2; + check = check << 1) { + if (check & stateChange) { + button = Qt::MouseButton(check); + break; + } + } + if (button == Qt::NoButton) { + // Ignore mouse events that don't change the current state + return; + } + buttons = e->buttons; + if (button & e->buttons) { + if ((e->timestamp - mousePressTime) < static_cast(QApplication::doubleClickInterval()) && button == mousePressButton) { + type = QEvent::MouseButtonDblClick; + mousePressButton = Qt::NoButton; + } + else { + type = QEvent::MouseButtonPress; + mousePressTime = e->timestamp; + mousePressButton = button; + mousePressX = qt_last_x; + mousePressY = qt_last_y; + } + } + else + type = QEvent::MouseButtonRelease; + } + + if (self->inPopupMode()) { + //popup mouse handling is magical... + mouseWindow = qApp->activePopupWidget(); + + implicit_mouse_grabber.clear(); + //### how should popup mode and implicit mouse grab interact? + + } else if (tlw && app_do_modal && !qt_try_modal(tlw, e->type) ) { + //even if we're blocked by modality, we should deliver the mouse release event.. + //### this code is not completely correct: multiple buttons can be pressed simultaneously + if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) { + //qDebug() << "modal blocked mouse event to" << tlw; + return; + } + } + + // find the tlw if we didn't get it from the plugin + if (!mouseWindow) { + mouseWindow = QApplication::topLevelAt(globalPoint); + } + + if (!mouseWindow && !implicit_mouse_grabber) + mouseWindow = QApplication::desktop(); + + if (mouseWindow && mouseWindow != tlw) { + //we did not get a sensible localPoint from the window system, so let's calculate it + localPoint = mouseWindow->mapFromGlobal(globalPoint); + } + + // which child should have it? + QWidget *mouseWidget = mouseWindow; + if (mouseWindow) { + QWidget *w = mouseWindow->childAt(localPoint); + if (w) { + mouseWidget = w; + } + } + + //handle implicit mouse grab + if (type == QEvent::MouseButtonPress && !implicit_mouse_grabber) { + implicit_mouse_grabber = mouseWidget; + + Q_ASSERT(mouseWindow); + mouseWindow->activateWindow(); //focus + } else if (implicit_mouse_grabber) { + mouseWidget = implicit_mouse_grabber.data(); + mouseWindow = mouseWidget->window(); + if (mouseWindow != tlw) + localPoint = mouseWindow->mapFromGlobal(globalPoint); + } + + Q_ASSERT(mouseWidget); + + //localPoint is local to mouseWindow, but it needs to be local to mouseWidget + localPoint = mouseWidget->mapFrom(mouseWindow, localPoint); + + if (buttons == Qt::NoButton) { + //qDebug() << "resetting mouse grabber"; + implicit_mouse_grabber.clear(); + } + + if (mouseWidget != qt_last_mouse_receiver) { + dispatchEnterLeave(mouseWidget, qt_last_mouse_receiver); + qt_last_mouse_receiver = mouseWidget; + } + + // Remember, we might enter a modal event loop when sending the event, + // so think carefully before adding code below this point. + + // qDebug() << "sending mouse ev." << ev.type() << localPoint << globalPoint << ev.button() << ev.buttons() << mouseWidget << "mouse grabber" << implicit_mouse_grabber; + + QMouseEvent ev(type, localPoint, globalPoint, button, buttons, modifiers); + + QList > cursors = QGraphicsSystemCursorPrivate::getInstances(); + foreach (QWeakPointer cursor, cursors) { + if (cursor) + cursor.data()->pointerEvent(ev); + } + + QApplication::sendSpontaneousEvent(mouseWidget, &ev); +} + + +//### there's a lot of duplicated logic here -- refactoring required! + +void QApplicationPrivate::processWheelEvent(QWindowSystemInterface::WheelEvent *e) +{ +// QPoint localPoint = ev.pos(); + QPoint globalPoint = e->globalPos; +// bool trustLocalPoint = !!tlw; //is there something the local point can be local to? + QWidget *mouseWidget; + + qt_last_x = globalPoint.x(); + qt_last_y = globalPoint.y(); + + QWidget *mouseWindow = e->widget.data(); + + // find the tlw if we didn't get it from the plugin + if (!mouseWindow) { + mouseWindow = QApplication::topLevelAt(globalPoint); + } + + if (!mouseWindow) + return; + + mouseWidget = mouseWindow; + + if (app_do_modal && !qt_try_modal(mouseWindow, e->type) ) { + qDebug() << "modal blocked wheel event" << mouseWindow; + return; + } + QPoint p = mouseWindow->mapFromGlobal(globalPoint); + QWidget *w = mouseWindow->childAt(p); + if (w) { + mouseWidget = w; + p = mouseWidget->mapFromGlobal(globalPoint); + } + + QWheelEvent ev(p, globalPoint, e->delta, buttons, modifiers, + e->orient); + QApplication::sendSpontaneousEvent(mouseWidget, &ev); +} + + + +// Remember, Qt convention is: keyboard state is state *before* + +void QApplicationPrivate::processKeyEvent(QWindowSystemInterface::KeyEvent *e) +{ + QWidget *focusW = 0; + if (self->inPopupMode()) { + QWidget *popupW = qApp->activePopupWidget(); + focusW = popupW->focusWidget() ? popupW->focusWidget() : popupW; + } + if (!focusW) + focusW = QApplication::focusWidget(); + if (!focusW) { + focusW = e->widget.data(); + } + if (!focusW) + focusW = QApplication::activeWindow(); + + //qDebug() << "handleKeyEvent" << hex << e->key() << e->modifiers() << e->text() << "widget" << focusW; + + if (!focusW) + return; + if (app_do_modal && !qt_try_modal(focusW, e->type)) + return; + + modifiers = e->modifiers; + QKeyEvent ev(e->type, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount); + QApplication::sendSpontaneousEvent(focusW, &ev); +} + +void QApplicationPrivate::processGeometryChange(QWidget *tlw, const QRect &newRect) +{ + if (!tlw->isWindow()) + return; //geo of native child widgets is controlled by lighthouse + //so we already have sent the events; besides this new rect + //is not mapped to parent + + QRect cr(tlw->geometry()); + + bool isResize = cr.size() != newRect.size(); + bool isMove = cr.topLeft() != newRect.topLeft(); + tlw->data->crect = newRect; + if (isResize) { + QResizeEvent e(tlw->data->crect.size(), cr.size()); + QApplication::sendSpontaneousEvent(tlw, &e); + tlw->update(); + } + + if (isMove) { + //### frame geometry + QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft()); + QApplication::sendSpontaneousEvent(tlw, &e); + } +} + +void QApplicationPrivate::processCloseEvent(QWidget *tlw) +{ + tlw->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent); +} + +void QApplicationPrivate::processTouchEvent(QWindowSystemInterface::TouchEvent *e) +{ + translateRawTouchEvent(e->widget.data(), e->devType, e->points); +} + +void QApplicationPrivate::reportScreenCount(int count) +{ + // This operation only makes sense after the QApplication constructor runs + if (QCoreApplication::startingUp()) + return; + + QApplication::desktop()->d_func()->updateScreenList(); + // signal anything listening for creation or deletion of screens + QDesktopWidget *desktop = QApplication::desktop(); + emit desktop->screenCountChanged(count); +} + +void QApplicationPrivate::reportGeometryChange(int screenIndex) +{ + // This operation only makes sense after the QApplication constructor runs + if (QCoreApplication::startingUp()) + return; + + QApplication::desktop()->d_func()->updateScreenList(); + + // signal anything listening for screen geometry changes + QDesktopWidget *desktop = QApplication::desktop(); + emit desktop->resized(screenIndex); + + // make sure maximized and fullscreen windows are updated + QWidgetList list = QApplication::topLevelWidgets(); + for (int i = list.size() - 1; i >= 0; --i) { + QWidget *w = list.at(i); + if (w->isFullScreen()) + w->d_func()->setFullScreenSize_helper(); + else if (w->isMaximized()) + w->d_func()->setMaxWindowState_helper(); + } +} + +void QApplicationPrivate::reportAvailableGeometryChange(int screenIndex) +{ + // This operation only makes sense after the QApplication constructor runs + if (QCoreApplication::startingUp()) + return; + + QApplication::desktop()->d_func()->updateScreenList(); + + // signal anything listening for screen geometry changes + QDesktopWidget *desktop = QApplication::desktop(); + emit desktop->workAreaResized(screenIndex); + + // make sure maximized and fullscreen windows are updated + QWidgetList list = QApplication::topLevelWidgets(); + for (int i = list.size() - 1; i >= 0; --i) { + QWidget *w = list.at(i); + if (w->isFullScreen()) + w->d_func()->setFullScreenSize_helper(); + else if (w->isMaximized()) + w->d_func()->setMaxWindowState_helper(); + } +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qclipboard_lite.cpp b/src/gui/kernel/qclipboard_lite.cpp deleted file mode 100644 index 92b9e83..0000000 --- a/src/gui/kernel/qclipboard_lite.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 "qclipboard.h" - -#ifndef QT_NO_CLIPBOARD - -#include "qmimedata.h" -#include "qapplication.h" - -QT_BEGIN_NAMESPACE - -QT_USE_NAMESPACE - - -class QClipboardData -{ -public: - QClipboardData(); - ~QClipboardData(); - - void setSource(QMimeData* s) - { - if (s == src) - return; - delete src; - src = s; - } - QMimeData* source() - { return src; } - - void clear(); - -private: - QMimeData* src; -}; - -QClipboardData::QClipboardData() -{ - src = 0; -} - -QClipboardData::~QClipboardData() -{ - delete src; -} - -void QClipboardData::clear() -{ - delete src; - src = 0; -} - - -static QClipboardData *internalCbData = 0; - -static void cleanupClipboardData() -{ - delete internalCbData; - internalCbData = 0; -} - -static QClipboardData *clipboardData() -{ - if (internalCbData == 0) { - internalCbData = new QClipboardData; - qAddPostRoutine(cleanupClipboardData); - } - return internalCbData; -} - - -void QClipboard::clear(Mode mode) -{ - setText(QString(), mode); -} - - -bool QClipboard::event(QEvent *e) -{ - return QObject::event(e); -} - -const QMimeData* QClipboard::mimeData(Mode mode) const -{ - if (mode != Clipboard) return 0; - - QClipboardData *d = clipboardData(); - return d->source(); -} - -void QClipboard::setMimeData(QMimeData* src, Mode mode) -{ - if (mode != Clipboard) return; - - QClipboardData *d = clipboardData(); - - d->setSource(src); - - emitChanged(QClipboard::Clipboard); -} - -bool QClipboard::supportsMode(Mode mode) const -{ - return (mode == Clipboard); -} - -bool QClipboard::ownsMode(Mode mode) const -{ - if (mode == Clipboard) - qWarning("QClipboard::ownsClipboard: UNIMPLEMENTED!"); - return false; -} - -void QClipboard::connectNotify( const char * ) -{ -} - -void QClipboard::ownerDestroyed() -{ -} - -#endif // QT_NO_CLIPBOARD - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qclipboard_qpa.cpp b/src/gui/kernel/qclipboard_qpa.cpp new file mode 100644 index 0000000..92b9e83 --- /dev/null +++ b/src/gui/kernel/qclipboard_qpa.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "qclipboard.h" + +#ifndef QT_NO_CLIPBOARD + +#include "qmimedata.h" +#include "qapplication.h" + +QT_BEGIN_NAMESPACE + +QT_USE_NAMESPACE + + +class QClipboardData +{ +public: + QClipboardData(); + ~QClipboardData(); + + void setSource(QMimeData* s) + { + if (s == src) + return; + delete src; + src = s; + } + QMimeData* source() + { return src; } + + void clear(); + +private: + QMimeData* src; +}; + +QClipboardData::QClipboardData() +{ + src = 0; +} + +QClipboardData::~QClipboardData() +{ + delete src; +} + +void QClipboardData::clear() +{ + delete src; + src = 0; +} + + +static QClipboardData *internalCbData = 0; + +static void cleanupClipboardData() +{ + delete internalCbData; + internalCbData = 0; +} + +static QClipboardData *clipboardData() +{ + if (internalCbData == 0) { + internalCbData = new QClipboardData; + qAddPostRoutine(cleanupClipboardData); + } + return internalCbData; +} + + +void QClipboard::clear(Mode mode) +{ + setText(QString(), mode); +} + + +bool QClipboard::event(QEvent *e) +{ + return QObject::event(e); +} + +const QMimeData* QClipboard::mimeData(Mode mode) const +{ + if (mode != Clipboard) return 0; + + QClipboardData *d = clipboardData(); + return d->source(); +} + +void QClipboard::setMimeData(QMimeData* src, Mode mode) +{ + if (mode != Clipboard) return; + + QClipboardData *d = clipboardData(); + + d->setSource(src); + + emitChanged(QClipboard::Clipboard); +} + +bool QClipboard::supportsMode(Mode mode) const +{ + return (mode == Clipboard); +} + +bool QClipboard::ownsMode(Mode mode) const +{ + if (mode == Clipboard) + qWarning("QClipboard::ownsClipboard: UNIMPLEMENTED!"); + return false; +} + +void QClipboard::connectNotify( const char * ) +{ +} + +void QClipboard::ownerDestroyed() +{ +} + +#endif // QT_NO_CLIPBOARD + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qcursor_lite.cpp b/src/gui/kernel/qcursor_lite.cpp deleted file mode 100644 index a6ae7d3..0000000 --- a/src/gui/kernel/qcursor_lite.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include - -QT_BEGIN_NAMESPACE - -QT_USE_NAMESPACE - -#ifndef QT_NO_CURSOR - -static int nextCursorId = Qt::BitmapCursor; - -/***************************************************************************** - Internal QCursorData class - *****************************************************************************/ - -QCursorData::QCursorData(Qt::CursorShape s) - : cshape(s), bm(0), bmm(0), hx(0), hy(0), id(s) -{ - ref = 1; -} - -QCursorData::~QCursorData() -{ - delete bm; - delete bmm; -} - - -/***************************************************************************** - Global cursors - *****************************************************************************/ - -extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp - -int QCursor::handle() const -{ - return d->id; -} - - -QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY) -{ - if (!QCursorData::initialized) - QCursorData::initialize(); - if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) { - qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)"); - QCursorData *c = qt_cursorTable[0]; - c->ref.ref(); - return c; - } - QCursorData *d = new QCursorData; - d->bm = new QBitmap(bitmap); - d->bmm = new QBitmap(mask); - d->cshape = Qt::BitmapCursor; - d->id = ++nextCursorId; - d->hx = hotX >= 0 ? hotX : bitmap.width() / 2; - d->hy = hotY >= 0 ? hotY : bitmap.height() / 2; - - return d; -} - -void QCursorData::update() -{ -} - -#endif //QT_NO_CURSOR - -extern int qt_last_x,qt_last_y; - -QPoint QCursor::pos() -{ - return QPoint(qt_last_x, qt_last_y); -} - -void QCursor::setPos(int x, int y) -{ - // Need to check, since some X servers generate null mouse move - // events, causing looping in applications which call setPos() on - // every mouse move event. - // - if (pos() == QPoint(x, y)) - return; -} - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qcursor_qpa.cpp b/src/gui/kernel/qcursor_qpa.cpp new file mode 100644 index 0000000..a6ae7d3 --- /dev/null +++ b/src/gui/kernel/qcursor_qpa.cpp @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include +#include + +QT_BEGIN_NAMESPACE + +QT_USE_NAMESPACE + +#ifndef QT_NO_CURSOR + +static int nextCursorId = Qt::BitmapCursor; + +/***************************************************************************** + Internal QCursorData class + *****************************************************************************/ + +QCursorData::QCursorData(Qt::CursorShape s) + : cshape(s), bm(0), bmm(0), hx(0), hy(0), id(s) +{ + ref = 1; +} + +QCursorData::~QCursorData() +{ + delete bm; + delete bmm; +} + + +/***************************************************************************** + Global cursors + *****************************************************************************/ + +extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp + +int QCursor::handle() const +{ + return d->id; +} + + +QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY) +{ + if (!QCursorData::initialized) + QCursorData::initialize(); + if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) { + qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)"); + QCursorData *c = qt_cursorTable[0]; + c->ref.ref(); + return c; + } + QCursorData *d = new QCursorData; + d->bm = new QBitmap(bitmap); + d->bmm = new QBitmap(mask); + d->cshape = Qt::BitmapCursor; + d->id = ++nextCursorId; + d->hx = hotX >= 0 ? hotX : bitmap.width() / 2; + d->hy = hotY >= 0 ? hotY : bitmap.height() / 2; + + return d; +} + +void QCursorData::update() +{ +} + +#endif //QT_NO_CURSOR + +extern int qt_last_x,qt_last_y; + +QPoint QCursor::pos() +{ + return QPoint(qt_last_x, qt_last_y); +} + +void QCursor::setPos(int x, int y) +{ + // Need to check, since some X servers generate null mouse move + // events, causing looping in applications which call setPos() on + // every mouse move event. + // + if (pos() == QPoint(x, y)) + return; +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qdesktopwidget_lite.cpp b/src/gui/kernel/qdesktopwidget_lite.cpp deleted file mode 100644 index 6ba5dd9..0000000 --- a/src/gui/kernel/qdesktopwidget_lite.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 "qdesktopwidget.h" -#include "private/qapplication_p.h" -#include "private/qgraphicssystem_p.h" -#include -#include "private/qwidget_p.h" -#include "private/qdesktopwidget_lite_p.h" -QT_BEGIN_NAMESPACE - -QT_USE_NAMESPACE - -void QDesktopWidgetPrivate::updateScreenList() -{ - QList screenList = QApplicationPrivate::platformIntegration()->screens(); - int targetLength = screenList.length(); - int currentLength = screens.length(); - - // Add or remove screen widgets as necessary - if(currentLength > targetLength) { - QDesktopScreenWidget *screen; - while (currentLength-- > targetLength) { - screen = screens.takeLast(); - delete screen; - } - } - else if (currentLength < targetLength) { - QDesktopScreenWidget *screen; - while (currentLength < targetLength) { - screen = new QDesktopScreenWidget(currentLength++); - screens.append(screen); - } - } - - QRegion virtualGeometry; - bool doVirtualGeometry = QApplicationPrivate::platformIntegration()->isVirtualDesktop(); - - // update the geometry of each screen widget - for (int i = 0; i < screens.length(); i++) { - QRect screenGeometry = screenList.at(i)->geometry(); - screens.at(i)->setGeometry(screenGeometry); - if (doVirtualGeometry) - virtualGeometry += screenGeometry; - } - - virtualScreen.setGeometry(virtualGeometry.boundingRect()); - Q_Q(QDesktopWidget); - q->setGeometry(virtualScreen.geometry()); -} - -QDesktopWidget::QDesktopWidget() - : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop) -{ - Q_D(QDesktopWidget); - setObjectName(QLatin1String("desktop")); - d->updateScreenList(); -} - -QDesktopWidget::~QDesktopWidget() -{ -} - -bool QDesktopWidget::isVirtualDesktop() const -{ - return QApplicationPrivate::platformIntegration()->isVirtualDesktop(); -} - -int QDesktopWidget::primaryScreen() const -{ - return 0; -} - -int QDesktopWidget::numScreens() const -{ - QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); - return qMax(pi->screens().size(), 1); -} - -QWidget *QDesktopWidget::screen(int screen) -{ - Q_D(QDesktopWidget); - if (QApplicationPrivate::platformIntegration()->isVirtualDesktop()) - return &d->virtualScreen; - if (screen < 0 || screen >= d->screens.length()) - return d->screens.at(0); - return d->screens.at(screen); -} - -const QRect QDesktopWidget::availableGeometry(int screenNo) const -{ - QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); - QList screens = pi->screens(); - if (screenNo == -1) - screenNo = 0; - if (screenNo < 0 || screenNo >= screens.size()) - return QRect(); - else - return screens[screenNo]->availableGeometry(); -} - -const QRect QDesktopWidget::screenGeometry(int screenNo) const -{ - QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); - QList screens = pi->screens(); - if (screenNo == -1) - screenNo = 0; - if (screenNo < 0 || screenNo >= screens.size()) - return QRect(); - else - return screens[screenNo]->geometry(); -} - -int QDesktopWidget::screenNumber(const QWidget *w) const -{ - if (!w) - return 0; - - QRect frame = w->frameGeometry(); - if (!w->isWindow()) - frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0))); - const QPoint midpoint = (frame.topLeft() + frame.bottomRight()) / 2; - return screenNumber(midpoint); -} - -int QDesktopWidget::screenNumber(const QPoint &p) const -{ - QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); - QList screens = pi->screens(); - - for (int i = 0; i < screens.size(); ++i) - if (screens[i]->geometry().contains(p)) - return i; - - return primaryScreen(); //even better would be closest screen -} - -void QDesktopWidget::resizeEvent(QResizeEvent *) -{ -} - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qdesktopwidget_lite_p.h b/src/gui/kernel/qdesktopwidget_lite_p.h deleted file mode 100644 index 33e4c98..0000000 --- a/src/gui/kernel/qdesktopwidget_lite_p.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -// -// 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. -// - -#ifndef QDESKTOPWIDGET_LITE_P_H -#define QDESKTOPWIDGET_LITE_P_H - -#include "QDesktopWidget" -#include "private/qwidget_p.h" - -class QDesktopScreenWidget : public QWidget { - Q_OBJECT -public: - QDesktopScreenWidget(int screenNumber = -1) { setWindowFlags(Qt::Desktop); setVisible(false); d_func()->screenNumber = screenNumber; } -}; - -class QDesktopWidgetPrivate : public QWidgetPrivate { - Q_DECLARE_PUBLIC(QDesktopWidget) - -public: - ~QDesktopWidgetPrivate() {foreach(QDesktopScreenWidget *s, screens) delete s; } - void updateScreenList(); - - QList screens; - QDesktopScreenWidget virtualScreen; -}; - -#endif // QDESKTOPWIDGET_LITE_P_H diff --git a/src/gui/kernel/qdesktopwidget_qpa.cpp b/src/gui/kernel/qdesktopwidget_qpa.cpp new file mode 100644 index 0000000..cff05f5 --- /dev/null +++ b/src/gui/kernel/qdesktopwidget_qpa.cpp @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "qdesktopwidget.h" +#include "private/qapplication_p.h" +#include "private/qgraphicssystem_p.h" +#include +#include "private/qwidget_p.h" +#include "private/qdesktopwidget_qpa_p.h" +QT_BEGIN_NAMESPACE + +QT_USE_NAMESPACE + +void QDesktopWidgetPrivate::updateScreenList() +{ + QList screenList = QApplicationPrivate::platformIntegration()->screens(); + int targetLength = screenList.length(); + int currentLength = screens.length(); + + // Add or remove screen widgets as necessary + if(currentLength > targetLength) { + QDesktopScreenWidget *screen; + while (currentLength-- > targetLength) { + screen = screens.takeLast(); + delete screen; + } + } + else if (currentLength < targetLength) { + QDesktopScreenWidget *screen; + while (currentLength < targetLength) { + screen = new QDesktopScreenWidget(currentLength++); + screens.append(screen); + } + } + + QRegion virtualGeometry; + bool doVirtualGeometry = QApplicationPrivate::platformIntegration()->isVirtualDesktop(); + + // update the geometry of each screen widget + for (int i = 0; i < screens.length(); i++) { + QRect screenGeometry = screenList.at(i)->geometry(); + screens.at(i)->setGeometry(screenGeometry); + if (doVirtualGeometry) + virtualGeometry += screenGeometry; + } + + virtualScreen.setGeometry(virtualGeometry.boundingRect()); + Q_Q(QDesktopWidget); + q->setGeometry(virtualScreen.geometry()); +} + +QDesktopWidget::QDesktopWidget() + : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop) +{ + Q_D(QDesktopWidget); + setObjectName(QLatin1String("desktop")); + d->updateScreenList(); +} + +QDesktopWidget::~QDesktopWidget() +{ +} + +bool QDesktopWidget::isVirtualDesktop() const +{ + return QApplicationPrivate::platformIntegration()->isVirtualDesktop(); +} + +int QDesktopWidget::primaryScreen() const +{ + return 0; +} + +int QDesktopWidget::numScreens() const +{ + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + return qMax(pi->screens().size(), 1); +} + +QWidget *QDesktopWidget::screen(int screen) +{ + Q_D(QDesktopWidget); + if (QApplicationPrivate::platformIntegration()->isVirtualDesktop()) + return &d->virtualScreen; + if (screen < 0 || screen >= d->screens.length()) + return d->screens.at(0); + return d->screens.at(screen); +} + +const QRect QDesktopWidget::availableGeometry(int screenNo) const +{ + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList screens = pi->screens(); + if (screenNo == -1) + screenNo = 0; + if (screenNo < 0 || screenNo >= screens.size()) + return QRect(); + else + return screens[screenNo]->availableGeometry(); +} + +const QRect QDesktopWidget::screenGeometry(int screenNo) const +{ + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList screens = pi->screens(); + if (screenNo == -1) + screenNo = 0; + if (screenNo < 0 || screenNo >= screens.size()) + return QRect(); + else + return screens[screenNo]->geometry(); +} + +int QDesktopWidget::screenNumber(const QWidget *w) const +{ + if (!w) + return 0; + + QRect frame = w->frameGeometry(); + if (!w->isWindow()) + frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0))); + const QPoint midpoint = (frame.topLeft() + frame.bottomRight()) / 2; + return screenNumber(midpoint); +} + +int QDesktopWidget::screenNumber(const QPoint &p) const +{ + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList screens = pi->screens(); + + for (int i = 0; i < screens.size(); ++i) + if (screens[i]->geometry().contains(p)) + return i; + + return primaryScreen(); //even better would be closest screen +} + +void QDesktopWidget::resizeEvent(QResizeEvent *) +{ +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qdesktopwidget_qpa_p.h b/src/gui/kernel/qdesktopwidget_qpa_p.h new file mode 100644 index 0000000..33e4c98 --- /dev/null +++ b/src/gui/kernel/qdesktopwidget_qpa_p.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +// +// 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. +// + +#ifndef QDESKTOPWIDGET_LITE_P_H +#define QDESKTOPWIDGET_LITE_P_H + +#include "QDesktopWidget" +#include "private/qwidget_p.h" + +class QDesktopScreenWidget : public QWidget { + Q_OBJECT +public: + QDesktopScreenWidget(int screenNumber = -1) { setWindowFlags(Qt::Desktop); setVisible(false); d_func()->screenNumber = screenNumber; } +}; + +class QDesktopWidgetPrivate : public QWidgetPrivate { + Q_DECLARE_PUBLIC(QDesktopWidget) + +public: + ~QDesktopWidgetPrivate() {foreach(QDesktopScreenWidget *s, screens) delete s; } + void updateScreenList(); + + QList screens; + QDesktopScreenWidget virtualScreen; +}; + +#endif // QDESKTOPWIDGET_LITE_P_H diff --git a/src/gui/kernel/qeventdispatcher_glib_lite.cpp b/src/gui/kernel/qeventdispatcher_glib_lite.cpp deleted file mode 100644 index 744925c..0000000 --- a/src/gui/kernel/qeventdispatcher_glib_lite.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -** -** 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 QtCore 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 "qeventdispatcher_glib_lite_p.h" - -#include "qapplication.h" - -#include "qplatformdefs.h" -#include "qapplication.h" - -#include -#include "qapplication_p.h" - -#include - -QT_BEGIN_NAMESPACE - -struct GUserEventSource -{ - GSource source; - QLiteEventDispatcherGlib *q; -}; - -static gboolean userEventSourcePrepare(GSource *s, gint *timeout) -{ - Q_UNUSED(s) - Q_UNUSED(timeout) - - return QWindowSystemInterfacePrivate::userEventsQueued() > 0; -} - -static gboolean userEventSourceCheck(GSource *source) -{ - return userEventSourcePrepare(source, 0); -} - -static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer) -{ - GUserEventSource * source = reinterpret_cast(s); - - QWindowSystemInterface::UserEvent * event; - while (QWindowSystemInterfacePrivate::userEventsQueued()) { - event = QWindowSystemInterfacePrivate::getUserEvent(); - if (!event) - break; - - // send through event filter - if (source->q->filterEvent(event)) { - delete event; - continue; - } - QApplicationPrivate::processUserEvent(event); - delete event; - } - - return true; -} - - -static GSourceFuncs userEventSourceFuncs = { - userEventSourcePrepare, - userEventSourceCheck, - userEventSourceDispatch, - NULL, - NULL, - NULL -}; - -QLiteEventDispatcherGlibPrivate::QLiteEventDispatcherGlibPrivate(GMainContext *context) - : QEventDispatcherGlibPrivate(context) -{ - userEventSource = reinterpret_cast(g_source_new(&userEventSourceFuncs, - sizeof(GUserEventSource))); - userEventSource->q = 0; - g_source_set_can_recurse(&userEventSource->source, true); - g_source_attach(&userEventSource->source, mainContext); -} - - -QLiteEventDispatcherGlib::QLiteEventDispatcherGlib(QObject *parent) - : QEventDispatcherGlib(*new QLiteEventDispatcherGlibPrivate, parent) -{ - Q_D(QLiteEventDispatcherGlib); - d->userEventSource->q = this; -} - -QLiteEventDispatcherGlib::~QLiteEventDispatcherGlib() -{ - Q_D(QLiteEventDispatcherGlib); - - g_source_destroy(&d->userEventSource->source); - g_source_unref(&d->userEventSource->source); - d->userEventSource = 0; -} - -bool QLiteEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags) -{ - return QEventDispatcherGlib::processEvents(flags); -} - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qeventdispatcher_glib_lite_p.h b/src/gui/kernel/qeventdispatcher_glib_lite_p.h deleted file mode 100644 index 6ebdb25..0000000 --- a/src/gui/kernel/qeventdispatcher_glib_lite_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** 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 QtCore 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 QLITEEVENTDISPATCHER_GLIB_P_H -#define QLITEEVENTDISPATCHER_GLIB_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of the QLibrary class. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// - -#include - -typedef struct _GMainContext GMainContext; - -QT_BEGIN_NAMESPACE -class QLiteEventDispatcherGlibPrivate; - -class QLiteEventDispatcherGlib : public QEventDispatcherGlib -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QLiteEventDispatcherGlib) - -public: - explicit QLiteEventDispatcherGlib(QObject *parent = 0); - ~QLiteEventDispatcherGlib(); - - bool processEvents(QEventLoop::ProcessEventsFlags flags); -}; - -struct GUserEventSource; - -class QLiteEventDispatcherGlibPrivate : public QEventDispatcherGlibPrivate -{ - Q_DECLARE_PUBLIC(QLiteEventDispatcherGlib) -public: - QLiteEventDispatcherGlibPrivate(GMainContext *context = 0); - GUserEventSource *userEventSource; -}; - - -QT_END_NAMESPACE - -#endif // QLITEEVENTDISPATCHER_GLIB_P_H diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp new file mode 100644 index 0000000..f45902c --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** 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 QtCore 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 "qeventdispatcher_glib_qpa_p.h" + +#include "qapplication.h" + +#include "qplatformdefs.h" +#include "qapplication.h" + +#include +#include "qapplication_p.h" + +#include + +QT_BEGIN_NAMESPACE + +struct GUserEventSource +{ + GSource source; + QLiteEventDispatcherGlib *q; +}; + +static gboolean userEventSourcePrepare(GSource *s, gint *timeout) +{ + Q_UNUSED(s) + Q_UNUSED(timeout) + + return QWindowSystemInterfacePrivate::userEventsQueued() > 0; +} + +static gboolean userEventSourceCheck(GSource *source) +{ + return userEventSourcePrepare(source, 0); +} + +static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer) +{ + GUserEventSource * source = reinterpret_cast(s); + + QWindowSystemInterface::UserEvent * event; + while (QWindowSystemInterfacePrivate::userEventsQueued()) { + event = QWindowSystemInterfacePrivate::getUserEvent(); + if (!event) + break; + + // send through event filter + if (source->q->filterEvent(event)) { + delete event; + continue; + } + QApplicationPrivate::processUserEvent(event); + delete event; + } + + return true; +} + + +static GSourceFuncs userEventSourceFuncs = { + userEventSourcePrepare, + userEventSourceCheck, + userEventSourceDispatch, + NULL, + NULL, + NULL +}; + +QLiteEventDispatcherGlibPrivate::QLiteEventDispatcherGlibPrivate(GMainContext *context) + : QEventDispatcherGlibPrivate(context) +{ + userEventSource = reinterpret_cast(g_source_new(&userEventSourceFuncs, + sizeof(GUserEventSource))); + userEventSource->q = 0; + g_source_set_can_recurse(&userEventSource->source, true); + g_source_attach(&userEventSource->source, mainContext); +} + + +QLiteEventDispatcherGlib::QLiteEventDispatcherGlib(QObject *parent) + : QEventDispatcherGlib(*new QLiteEventDispatcherGlibPrivate, parent) +{ + Q_D(QLiteEventDispatcherGlib); + d->userEventSource->q = this; +} + +QLiteEventDispatcherGlib::~QLiteEventDispatcherGlib() +{ + Q_D(QLiteEventDispatcherGlib); + + g_source_destroy(&d->userEventSource->source); + g_source_unref(&d->userEventSource->source); + d->userEventSource = 0; +} + +bool QLiteEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags) +{ + return QEventDispatcherGlib::processEvents(flags); +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa_p.h b/src/gui/kernel/qeventdispatcher_glib_qpa_p.h new file mode 100644 index 0000000..6ebdb25 --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_glib_qpa_p.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 QtCore 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 QLITEEVENTDISPATCHER_GLIB_P_H +#define QLITEEVENTDISPATCHER_GLIB_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include + +typedef struct _GMainContext GMainContext; + +QT_BEGIN_NAMESPACE +class QLiteEventDispatcherGlibPrivate; + +class QLiteEventDispatcherGlib : public QEventDispatcherGlib +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QLiteEventDispatcherGlib) + +public: + explicit QLiteEventDispatcherGlib(QObject *parent = 0); + ~QLiteEventDispatcherGlib(); + + bool processEvents(QEventLoop::ProcessEventsFlags flags); +}; + +struct GUserEventSource; + +class QLiteEventDispatcherGlibPrivate : public QEventDispatcherGlibPrivate +{ + Q_DECLARE_PUBLIC(QLiteEventDispatcherGlib) +public: + QLiteEventDispatcherGlibPrivate(GMainContext *context = 0); + GUserEventSource *userEventSource; +}; + + +QT_END_NAMESPACE + +#endif // QLITEEVENTDISPATCHER_GLIB_P_H diff --git a/src/gui/kernel/qeventdispatcher_lite.cpp b/src/gui/kernel/qeventdispatcher_lite.cpp deleted file mode 100644 index 5b99a2f..0000000 --- a/src/gui/kernel/qeventdispatcher_lite.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** 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 "qplatformdefs.h" -#include "qapplication.h" -#include "qeventdispatcher_lite_p.h" -#include "private/qeventdispatcher_unix_p.h" -#include "qapplication_p.h" -#ifndef QT_NO_THREAD -# include "qmutex.h" -#endif -#include - -#include -QT_BEGIN_NAMESPACE - -QT_USE_NAMESPACE - -class QEventDispatcherLitePrivate : public QEventDispatcherUNIXPrivate -{ - Q_DECLARE_PUBLIC(QEventDispatcherLite) -public: - inline QEventDispatcherLitePrivate() - { } -}; - - -QEventDispatcherLite::QEventDispatcherLite(QObject *parent) - : QEventDispatcherUNIX(*new QEventDispatcherLitePrivate, parent) -{ } - -QEventDispatcherLite::~QEventDispatcherLite() -{ } - - - -//#define ZERO_FOR_THE_MOMENT - -bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags) -{ - Q_D(QEventDispatcherLite); - int nevents = 0; - - // handle gui and posted events - d->interrupt = false; - QApplication::sendPostedEvents(); - - while (!d->interrupt) { // also flushes output buffer ###can be optimized - QWindowSystemInterface::UserEvent *event; - if (!(flags & QEventLoop::ExcludeUserInputEvents) - && QWindowSystemInterfacePrivate::userEventsQueued() > 0) { - // process a pending user input event - event = QWindowSystemInterfacePrivate::getUserEvent(); - if (!event) - break; - } else { - break; - } - - if (filterEvent(event)) { - delete event; - continue; - } - nevents++; - - QApplicationPrivate::processUserEvent(event); - delete event; - } - - if (!d->interrupt) { - if (QEventDispatcherUNIX::processEvents(flags)) - return true; - } - return (nevents > 0); -} - -bool QEventDispatcherLite::hasPendingEvents() -{ - extern uint qGlobalPostedEventsCount(); // from qapplication.cpp - return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::userEventsQueued();; -} - -void QEventDispatcherLite::startingUp() -{ - -} - -void QEventDispatcherLite::closingDown() -{ - -} - -void QEventDispatcherLite::flush() -{ - if(qApp) - qApp->sendPostedEvents(); -} - - -int QEventDispatcherLite::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - timeval *timeout) -{ - return QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout); -} - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qeventdispatcher_lite_p.h b/src/gui/kernel/qeventdispatcher_lite_p.h deleted file mode 100644 index c098e6c..0000000 --- a/src/gui/kernel/qeventdispatcher_lite_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** 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 QEVENTDISPATCHER_LITE_P_H -#define QEVENTDISPATCHER_LITE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qeventdispatcher_unix_p.h" - -QT_BEGIN_NAMESPACE - -class QEventDispatcherLitePrivate; - -class QEventDispatcherLite : public QEventDispatcherUNIX -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QEventDispatcherLite) - -public: - explicit QEventDispatcherLite(QObject *parent = 0); - ~QEventDispatcherLite(); - - bool processEvents(QEventLoop::ProcessEventsFlags flags); - bool hasPendingEvents(); - - void flush(); - - void startingUp(); - void closingDown(); - -protected: - int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - timeval *timeout); -}; - -QT_END_NAMESPACE - -#endif // QEVENTDISPATCHER_LITE_P_H diff --git a/src/gui/kernel/qeventdispatcher_qpa.cpp b/src/gui/kernel/qeventdispatcher_qpa.cpp new file mode 100644 index 0000000..c6b5636 --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_qpa.cpp @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** 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 "qplatformdefs.h" +#include "qapplication.h" +#include "qeventdispatcher_qpa_p.h" +#include "private/qeventdispatcher_unix_p.h" +#include "qapplication_p.h" +#ifndef QT_NO_THREAD +# include "qmutex.h" +#endif +#include + +#include +QT_BEGIN_NAMESPACE + +QT_USE_NAMESPACE + +class QEventDispatcherLitePrivate : public QEventDispatcherUNIXPrivate +{ + Q_DECLARE_PUBLIC(QEventDispatcherLite) +public: + inline QEventDispatcherLitePrivate() + { } +}; + + +QEventDispatcherLite::QEventDispatcherLite(QObject *parent) + : QEventDispatcherUNIX(*new QEventDispatcherLitePrivate, parent) +{ } + +QEventDispatcherLite::~QEventDispatcherLite() +{ } + + + +//#define ZERO_FOR_THE_MOMENT + +bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags) +{ + Q_D(QEventDispatcherLite); + int nevents = 0; + + // handle gui and posted events + d->interrupt = false; + QApplication::sendPostedEvents(); + + while (!d->interrupt) { // also flushes output buffer ###can be optimized + QWindowSystemInterface::UserEvent *event; + if (!(flags & QEventLoop::ExcludeUserInputEvents) + && QWindowSystemInterfacePrivate::userEventsQueued() > 0) { + // process a pending user input event + event = QWindowSystemInterfacePrivate::getUserEvent(); + if (!event) + break; + } else { + break; + } + + if (filterEvent(event)) { + delete event; + continue; + } + nevents++; + + QApplicationPrivate::processUserEvent(event); + delete event; + } + + if (!d->interrupt) { + if (QEventDispatcherUNIX::processEvents(flags)) + return true; + } + return (nevents > 0); +} + +bool QEventDispatcherLite::hasPendingEvents() +{ + extern uint qGlobalPostedEventsCount(); // from qapplication.cpp + return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::userEventsQueued();; +} + +void QEventDispatcherLite::startingUp() +{ + +} + +void QEventDispatcherLite::closingDown() +{ + +} + +void QEventDispatcherLite::flush() +{ + if(qApp) + qApp->sendPostedEvents(); +} + + +int QEventDispatcherLite::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + timeval *timeout) +{ + return QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout); +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qeventdispatcher_qpa_p.h b/src/gui/kernel/qeventdispatcher_qpa_p.h new file mode 100644 index 0000000..c098e6c --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_qpa_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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 QEVENTDISPATCHER_LITE_P_H +#define QEVENTDISPATCHER_LITE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qeventdispatcher_unix_p.h" + +QT_BEGIN_NAMESPACE + +class QEventDispatcherLitePrivate; + +class QEventDispatcherLite : public QEventDispatcherUNIX +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QEventDispatcherLite) + +public: + explicit QEventDispatcherLite(QObject *parent = 0); + ~QEventDispatcherLite(); + + bool processEvents(QEventLoop::ProcessEventsFlags flags); + bool hasPendingEvents(); + + void flush(); + + void startingUp(); + void closingDown(); + +protected: + int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + timeval *timeout); +}; + +QT_END_NAMESPACE + +#endif // QEVENTDISPATCHER_LITE_P_H diff --git a/src/gui/kernel/qgenericplugin_lite.cpp b/src/gui/kernel/qgenericplugin_lite.cpp deleted file mode 100644 index 6a0fdb6..0000000 --- a/src/gui/kernel/qgenericplugin_lite.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 "qgenericplugin_lite.h" - -#ifndef QT_NO_LIBRARY - -QT_BEGIN_NAMESPACE - -/*! - \class QGenericPlugin - \ingroup plugins - \ingroup lite - - \brief The QGenericPlugin class is an abstract base class for - window-system related plugins in Qt for Embedded Linux LITE. - - Note that this class is only available in \l{Qt for Embedded Linux LITE}. - - A mouse plugin can be created by subclassing - QGenericPlugin and reimplementing the pure virtual keys() and - create() functions. By exporting the derived class using the - Q_EXPORT_PLUGIN2() macro, The default implementation of the - QGenericPluginFactory class will automatically detect the plugin and - load the driver into the server application at run-time. See \l - {How to Create Qt Plugins} for details. - - \sa QGenericPluginFactory -*/ - -/*! - \fn QStringList QGenericPlugin::keys() const - - Implement this function to return the list of valid keys, i.e. the - drivers supported by this plugin. - - \sa create() -*/ - -/*! - Constructs a plugin with the given \a parent. - - Note that this constructor is invoked automatically by the - Q_EXPORT_PLUGIN2() macro, so there is no need for calling it - explicitly. -*/ -QGenericPlugin::QGenericPlugin(QObject *parent) - : QObject(parent) -{ -} - -/*! - Destroys the plugin. - - Note that Qt destroys a plugin automatically when it is no longer - used, so there is no need for calling the destructor explicitly. -*/ -QGenericPlugin::~QGenericPlugin() -{ -} - -/*! - \fn QObject* QGenericPlugin::create(const QString &key, const QString& specification) - - Implement this function to create a driver matching the type - specified by the given \a key and \a specification parameters. Note that - keys are case-insensitive. - - \sa keys() -*/ - -QT_END_NAMESPACE - -#endif // QT_NO_LIBRARY diff --git a/src/gui/kernel/qgenericplugin_lite.h b/src/gui/kernel/qgenericplugin_lite.h deleted file mode 100644 index a468a9f..0000000 --- a/src/gui/kernel/qgenericplugin_lite.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 QGENERICPLUGIN_LITE_H -#define QGENERICPLUGIN_LITE_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#ifndef QT_NO_LIBRARY - -//class QGenericObject; ????? - - struct Q_GUI_EXPORT QGenericPluginFactoryInterface : public QFactoryInterface -{ - virtual QObject* create(const QString &name, const QString &spec) = 0; -}; - -#define QGenericPluginFactoryInterface_iid "com.trolltech.Qt.QGenericPluginFactoryInterface" -Q_DECLARE_INTERFACE(QGenericPluginFactoryInterface, QGenericPluginFactoryInterface_iid) - -class Q_GUI_EXPORT QGenericPlugin : public QObject, public QGenericPluginFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QGenericPluginFactoryInterface:QFactoryInterface) -public: - explicit QGenericPlugin(QObject *parent = 0); - ~QGenericPlugin(); - - virtual QStringList keys() const = 0; - virtual QObject* create(const QString& name, const QString &spec) = 0; -}; - -#endif // QT_NO_LIBRARY - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMOUSEDRIVERPLUGIN_QWS_H diff --git a/src/gui/kernel/qgenericplugin_qpa.cpp b/src/gui/kernel/qgenericplugin_qpa.cpp new file mode 100644 index 0000000..6290b40 --- /dev/null +++ b/src/gui/kernel/qgenericplugin_qpa.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "qgenericplugin_qpa.h" + +#ifndef QT_NO_LIBRARY + +QT_BEGIN_NAMESPACE + +/*! + \class QGenericPlugin + \ingroup plugins + \ingroup lite + + \brief The QGenericPlugin class is an abstract base class for + window-system related plugins in Qt for Embedded Linux LITE. + + Note that this class is only available in \l{Qt for Embedded Linux LITE}. + + A mouse plugin can be created by subclassing + QGenericPlugin and reimplementing the pure virtual keys() and + create() functions. By exporting the derived class using the + Q_EXPORT_PLUGIN2() macro, The default implementation of the + QGenericPluginFactory class will automatically detect the plugin and + load the driver into the server application at run-time. See \l + {How to Create Qt Plugins} for details. + + \sa QGenericPluginFactory +*/ + +/*! + \fn QStringList QGenericPlugin::keys() const + + Implement this function to return the list of valid keys, i.e. the + drivers supported by this plugin. + + \sa create() +*/ + +/*! + Constructs a plugin with the given \a parent. + + Note that this constructor is invoked automatically by the + Q_EXPORT_PLUGIN2() macro, so there is no need for calling it + explicitly. +*/ +QGenericPlugin::QGenericPlugin(QObject *parent) + : QObject(parent) +{ +} + +/*! + Destroys the plugin. + + Note that Qt destroys a plugin automatically when it is no longer + used, so there is no need for calling the destructor explicitly. +*/ +QGenericPlugin::~QGenericPlugin() +{ +} + +/*! + \fn QObject* QGenericPlugin::create(const QString &key, const QString& specification) + + Implement this function to create a driver matching the type + specified by the given \a key and \a specification parameters. Note that + keys are case-insensitive. + + \sa keys() +*/ + +QT_END_NAMESPACE + +#endif // QT_NO_LIBRARY diff --git a/src/gui/kernel/qgenericplugin_qpa.h b/src/gui/kernel/qgenericplugin_qpa.h new file mode 100644 index 0000000..a468a9f --- /dev/null +++ b/src/gui/kernel/qgenericplugin_qpa.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 QGENERICPLUGIN_LITE_H +#define QGENERICPLUGIN_LITE_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +#ifndef QT_NO_LIBRARY + +//class QGenericObject; ????? + + struct Q_GUI_EXPORT QGenericPluginFactoryInterface : public QFactoryInterface +{ + virtual QObject* create(const QString &name, const QString &spec) = 0; +}; + +#define QGenericPluginFactoryInterface_iid "com.trolltech.Qt.QGenericPluginFactoryInterface" +Q_DECLARE_INTERFACE(QGenericPluginFactoryInterface, QGenericPluginFactoryInterface_iid) + +class Q_GUI_EXPORT QGenericPlugin : public QObject, public QGenericPluginFactoryInterface +{ + Q_OBJECT + Q_INTERFACES(QGenericPluginFactoryInterface:QFactoryInterface) +public: + explicit QGenericPlugin(QObject *parent = 0); + ~QGenericPlugin(); + + virtual QStringList keys() const = 0; + virtual QObject* create(const QString& name, const QString &spec) = 0; +}; + +#endif // QT_NO_LIBRARY + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QMOUSEDRIVERPLUGIN_QWS_H diff --git a/src/gui/kernel/qgenericpluginfactory_lite.cpp b/src/gui/kernel/qgenericpluginfactory_lite.cpp deleted file mode 100644 index 76accbe..0000000 --- a/src/gui/kernel/qgenericpluginfactory_lite.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 "qgenericpluginfactory_lite.h" - -#include "qapplication.h" -#include "private/qfactoryloader_p.h" -#include "qgenericplugin_lite.h" -#include "qdebug.h" - -QT_BEGIN_NAMESPACE - -#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) -#ifndef QT_NO_LIBRARY - -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, - (QGenericPluginFactoryInterface_iid, - QLatin1String("/generic"), Qt::CaseInsensitive)) - -#endif //QT_NO_LIBRARY -#endif //QT_MAKEDLL - -/*! - \class QGenericPluginFactory - \ingroup qws - - \brief The QGenericPluginFactory class creates window-system - related plugin drivers in Qt for Embedded Linux LITE. - - Note that this class is only available in \l{Qt for Embedded Linux LITE}. - - - \sa QGenericPlugin -*/ - -/*! - Creates the driver specified by \a key, using the given \a specification. - - Note that the keys are case-insensitive. - - \sa keys() -*/ -QObject *QGenericPluginFactory::create(const QString& key, const QString &specification) -{ - QString driver = key.toLower(); - -#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) -#ifndef QT_NO_LIBRARY - if (QGenericPluginFactoryInterface *factory = qobject_cast(loader()->instance(driver))) - return factory->create(driver, specification); -#endif -#endif - return 0; -} - -/*! - Returns the list of valid keys, i.e. the available mouse drivers. - - \sa create() -*/ -QStringList QGenericPluginFactory::keys() -{ - QStringList list; - -#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) -#ifndef QT_NO_LIBRARY - QStringList plugins = loader()->keys(); - for (int i = 0; i < plugins.size(); ++i) { - if (!list.contains(plugins.at(i))) - list += plugins.at(i); - } -#endif //QT_NO_LIBRARY -#endif //QT_MAKEDLL - return list; -} - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qgenericpluginfactory_lite.h b/src/gui/kernel/qgenericpluginfactory_lite.h deleted file mode 100644 index 86886f1..0000000 --- a/src/gui/kernel/qgenericpluginfactory_lite.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 QGENERICPLUGINFACTORY_LITE_H -#define QGENERICPLUGINFACTORY_LITE_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class QString; -class QObject; - -class Q_GUI_EXPORT QGenericPluginFactory -{ -public: - static QStringList keys(); - static QObject *create(const QString&, const QString &); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGENERICPLUGINFACTORY_QWS_H diff --git a/src/gui/kernel/qgenericpluginfactory_qpa.cpp b/src/gui/kernel/qgenericpluginfactory_qpa.cpp new file mode 100644 index 0000000..dcc7cc7 --- /dev/null +++ b/src/gui/kernel/qgenericpluginfactory_qpa.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "qgenericpluginfactory_qpa.h" + +#include "qapplication.h" +#include "private/qfactoryloader_p.h" +#include "qgenericplugin_qpa.h" +#include "qdebug.h" + +QT_BEGIN_NAMESPACE + +#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) +#ifndef QT_NO_LIBRARY + +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, + (QGenericPluginFactoryInterface_iid, + QLatin1String("/generic"), Qt::CaseInsensitive)) + +#endif //QT_NO_LIBRARY +#endif //QT_MAKEDLL + +/*! + \class QGenericPluginFactory + \ingroup qws + + \brief The QGenericPluginFactory class creates window-system + related plugin drivers in Qt for Embedded Linux LITE. + + Note that this class is only available in \l{Qt for Embedded Linux LITE}. + + + \sa QGenericPlugin +*/ + +/*! + Creates the driver specified by \a key, using the given \a specification. + + Note that the keys are case-insensitive. + + \sa keys() +*/ +QObject *QGenericPluginFactory::create(const QString& key, const QString &specification) +{ + QString driver = key.toLower(); + +#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) +#ifndef QT_NO_LIBRARY + if (QGenericPluginFactoryInterface *factory = qobject_cast(loader()->instance(driver))) + return factory->create(driver, specification); +#endif +#endif + return 0; +} + +/*! + Returns the list of valid keys, i.e. the available mouse drivers. + + \sa create() +*/ +QStringList QGenericPluginFactory::keys() +{ + QStringList list; + +#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) +#ifndef QT_NO_LIBRARY + QStringList plugins = loader()->keys(); + for (int i = 0; i < plugins.size(); ++i) { + if (!list.contains(plugins.at(i))) + list += plugins.at(i); + } +#endif //QT_NO_LIBRARY +#endif //QT_MAKEDLL + return list; +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qgenericpluginfactory_qpa.h b/src/gui/kernel/qgenericpluginfactory_qpa.h new file mode 100644 index 0000000..86886f1 --- /dev/null +++ b/src/gui/kernel/qgenericpluginfactory_qpa.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 QGENERICPLUGINFACTORY_LITE_H +#define QGENERICPLUGINFACTORY_LITE_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QString; +class QObject; + +class Q_GUI_EXPORT QGenericPluginFactory +{ +public: + static QStringList keys(); + static QObject *create(const QString&, const QString &); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QGENERICPLUGINFACTORY_QWS_H diff --git a/src/gui/kernel/qplatformglcontext_lite.h b/src/gui/kernel/qplatformglcontext_lite.h deleted file mode 100644 index 8aeb635..0000000 --- a/src/gui/kernel/qplatformglcontext_lite.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** 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 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$ -** -****************************************************************************/ - -#ifndef QPLATFORM_GL_CONTEXT_H -#define QPLATFORM_GL_CONTEXT_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class Q_OPENGL_EXPORT QPlatformGLContext -{ -public: - //QPlatformGLContext(); - //virtual ~QPlatformGLContext(); - - //virtual bool create(QPaintDevice* device, QPlatformGLContext* shareContext) = 0; - - virtual void makeCurrent() = 0; - virtual void doneCurrent() = 0; - virtual void swapBuffers() = 0; - virtual void* getProcAddress(const QString& procName) = 0; - -}; - -QT_END_NAMESPACE - -QT_END_HEADER - - -#endif // QPLATFORM_GL_INTEGRATION_P_H diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h new file mode 100644 index 0000000..8aeb635 --- /dev/null +++ b/src/gui/kernel/qplatformglcontext_qpa.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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 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$ +** +****************************************************************************/ + +#ifndef QPLATFORM_GL_CONTEXT_H +#define QPLATFORM_GL_CONTEXT_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class Q_OPENGL_EXPORT QPlatformGLContext +{ +public: + //QPlatformGLContext(); + //virtual ~QPlatformGLContext(); + + //virtual bool create(QPaintDevice* device, QPlatformGLContext* shareContext) = 0; + + virtual void makeCurrent() = 0; + virtual void doneCurrent() = 0; + virtual void swapBuffers() = 0; + virtual void* getProcAddress(const QString& procName) = 0; + +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QPLATFORM_GL_INTEGRATION_P_H diff --git a/src/gui/kernel/qplatformintegration_lite.cpp b/src/gui/kernel/qplatformintegration_lite.cpp deleted file mode 100644 index 6499570..0000000 --- a/src/gui/kernel/qplatformintegration_lite.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** 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 "qplatformintegration_lite.h" - -QT_BEGIN_NAMESPACE - -QBlittable *QPlatformIntegration::createBlittable(const QSize &) const -{ return 0; } - -QPixmap QPlatformIntegration::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 QPlatformIntegration::hasOpenGL() const -{ - return false; -} - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h deleted file mode 100644 index 88c3049..0000000 --- a/src/gui/kernel/qplatformintegration_lite.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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 QPLATFORMINTEGRATION_H -#define QPLATFORMINTEGRATION_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class Q_GUI_EXPORT QPlatformIntegration -{ -public: - virtual ~QPlatformIntegration() { }; - -// GraphicsSystem functions - virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; - virtual QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const = 0; - virtual QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const = 0; - virtual QBlittable *createBlittable(const QSize &size) const; - virtual void moveToScreen(QWidget *window, int screen) {Q_UNUSED(window); Q_UNUSED(screen);} - -// Window System functions - virtual QList screens() const = 0; - virtual bool isVirtualDesktop() { return false; } - virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; - - virtual bool hasOpenGL() const; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QPLATFORMINTEGRATION_H diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp new file mode 100644 index 0000000..8666911 --- /dev/null +++ b/src/gui/kernel/qplatformintegration_qpa.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** 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 "qplatformintegration_qpa.h" + +QT_BEGIN_NAMESPACE + +QBlittable *QPlatformIntegration::createBlittable(const QSize &) const +{ return 0; } + +QPixmap QPlatformIntegration::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 QPlatformIntegration::hasOpenGL() const +{ + return false; +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h new file mode 100644 index 0000000..f80b0ae --- /dev/null +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 QPLATFORMINTEGRATION_H +#define QPLATFORMINTEGRATION_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class Q_GUI_EXPORT QPlatformIntegration +{ +public: + virtual ~QPlatformIntegration() { }; + +// GraphicsSystem functions + virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; + virtual QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const = 0; + virtual QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const = 0; + virtual QBlittable *createBlittable(const QSize &size) const; + virtual void moveToScreen(QWidget *window, int screen) {Q_UNUSED(window); Q_UNUSED(screen);} + +// Window System functions + virtual QList screens() const = 0; + virtual bool isVirtualDesktop() { return false; } + virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; + + virtual bool hasOpenGL() const; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMINTEGRATION_H diff --git a/src/gui/kernel/qplatformintegrationfactory_lite.cpp b/src/gui/kernel/qplatformintegrationfactory_lite.cpp deleted file mode 100644 index cd7d171..0000000 --- a/src/gui/kernel/qplatformintegrationfactory_lite.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** 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 "qplatformintegrationfactory_lite_p.h" -#include -#include "private/qfactoryloader_p.h" -#include "qmutex.h" - -#include "qapplication.h" -#include "qdebug.h" - -QT_BEGIN_NAMESPACE - -#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, - (QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive)) -#endif - -QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key) -{ - QPlatformIntegration *ret = 0; - QStringList paramList = key.split(QLatin1Char(':')); - QString platform = paramList.takeFirst().toLower(); - -#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) - qDebug() << loader()->keys(); - if (QPlatformIntegrationFactoryInterface *factory = qobject_cast(loader()->instance(platform))) - ret = factory->create(platform, paramList); -#endif - - return ret; -} - -/*! - Returns the list of valid keys, i.e. the keys this factory can - create styles for. - - \sa create() -*/ -QStringList QPlatformIntegrationFactory::keys() -{ -#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) - QStringList list = loader()->keys(); -#else - QStringList list; -#endif - return list; -} - -QT_END_NAMESPACE - diff --git a/src/gui/kernel/qplatformintegrationfactory_lite_p.h b/src/gui/kernel/qplatformintegrationfactory_lite_p.h deleted file mode 100644 index ba02d2c..0000000 --- a/src/gui/kernel/qplatformintegrationfactory_lite_p.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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 QPLATFORMINTEGRATIONFACTORY_H -#define QPLATFORMINTEGRATIONFACTORY_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class QPlatformIntegration; - -class QPlatformIntegrationFactory -{ -public: - static QStringList keys(); - static QPlatformIntegration *create(const QString&); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QPLATFORMINTEGRATIONFACTORY_H - diff --git a/src/gui/kernel/qplatformintegrationfactory_qpa.cpp b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp new file mode 100644 index 0000000..4f2bfa5 --- /dev/null +++ b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** 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 "qplatformintegrationfactory_qpa_p.h" +#include +#include "private/qfactoryloader_p.h" +#include "qmutex.h" + +#include "qapplication.h" +#include "qdebug.h" + +QT_BEGIN_NAMESPACE + +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, + (QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive)) +#endif + +QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key) +{ + QPlatformIntegration *ret = 0; + QStringList paramList = key.split(QLatin1Char(':')); + QString platform = paramList.takeFirst().toLower(); + +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + qDebug() << loader()->keys(); + if (QPlatformIntegrationFactoryInterface *factory = qobject_cast(loader()->instance(platform))) + ret = factory->create(platform, paramList); +#endif + + return ret; +} + +/*! + Returns the list of valid keys, i.e. the keys this factory can + create styles for. + + \sa create() +*/ +QStringList QPlatformIntegrationFactory::keys() +{ +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + QStringList list = loader()->keys(); +#else + QStringList list; +#endif + return list; +} + +QT_END_NAMESPACE + diff --git a/src/gui/kernel/qplatformintegrationfactory_qpa_p.h b/src/gui/kernel/qplatformintegrationfactory_qpa_p.h new file mode 100644 index 0000000..ba02d2c --- /dev/null +++ b/src/gui/kernel/qplatformintegrationfactory_qpa_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 QPLATFORMINTEGRATIONFACTORY_H +#define QPLATFORMINTEGRATIONFACTORY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QPlatformIntegration; + +class QPlatformIntegrationFactory +{ +public: + static QStringList keys(); + static QPlatformIntegration *create(const QString&); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMINTEGRATIONFACTORY_H + diff --git a/src/gui/kernel/qplatformintegrationplugin_lite.cpp b/src/gui/kernel/qplatformintegrationplugin_lite.cpp deleted file mode 100644 index cb1ed83..0000000 --- a/src/gui/kernel/qplatformintegrationplugin_lite.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** 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 "qplatformintegrationplugin_lite.h" - -QT_BEGIN_NAMESPACE - -QPlatformIntegrationPlugin::QPlatformIntegrationPlugin(QObject *parent) - : QObject(parent) -{ -} - -QPlatformIntegrationPlugin::~QPlatformIntegrationPlugin() -{ -} - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegrationplugin_lite.h b/src/gui/kernel/qplatformintegrationplugin_lite.h deleted file mode 100644 index 9c37cf7..0000000 --- a/src/gui/kernel/qplatformintegrationplugin_lite.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** 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 QPLATFORMINTEGRATIONPLUGIN_H -#define QPLATFORMINTEGRATIONPLUGIN_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class QPlatformIntegration; - -struct QPlatformIntegrationFactoryInterface : public QFactoryInterface -{ - virtual QPlatformIntegration *create(const QString &key, const QStringList ¶mList) = 0; -}; - -#define QPlatformIntegrationFactoryInterface_iid "com.nokia.Qt.QPlatformIntegrationFactoryInterface" - -Q_DECLARE_INTERFACE(QPlatformIntegrationFactoryInterface, QPlatformIntegrationFactoryInterface_iid) - -class Q_GUI_EXPORT QPlatformIntegrationPlugin : public QObject, public QPlatformIntegrationFactoryInterface -{ - Q_OBJECT - Q_INTERFACES(QPlatformIntegrationFactoryInterface:QFactoryInterface) -public: - explicit QPlatformIntegrationPlugin(QObject *parent = 0); - ~QPlatformIntegrationPlugin(); - - virtual QStringList keys() const = 0; - virtual QPlatformIntegration *create(const QString &key, const QStringList ¶mList) = 0; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QPLATFORMINTEGRATIONPLUGIN_H diff --git a/src/gui/kernel/qplatformintegrationplugin_qpa.cpp b/src/gui/kernel/qplatformintegrationplugin_qpa.cpp new file mode 100644 index 0000000..3bf2474 --- /dev/null +++ b/src/gui/kernel/qplatformintegrationplugin_qpa.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** 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 "qplatformintegrationplugin_qpa.h" + +QT_BEGIN_NAMESPACE + +QPlatformIntegrationPlugin::QPlatformIntegrationPlugin(QObject *parent) + : QObject(parent) +{ +} + +QPlatformIntegrationPlugin::~QPlatformIntegrationPlugin() +{ +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegrationplugin_qpa.h b/src/gui/kernel/qplatformintegrationplugin_qpa.h new file mode 100644 index 0000000..9c37cf7 --- /dev/null +++ b/src/gui/kernel/qplatformintegrationplugin_qpa.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** 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 QPLATFORMINTEGRATIONPLUGIN_H +#define QPLATFORMINTEGRATIONPLUGIN_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QPlatformIntegration; + +struct QPlatformIntegrationFactoryInterface : public QFactoryInterface +{ + virtual QPlatformIntegration *create(const QString &key, const QStringList ¶mList) = 0; +}; + +#define QPlatformIntegrationFactoryInterface_iid "com.nokia.Qt.QPlatformIntegrationFactoryInterface" + +Q_DECLARE_INTERFACE(QPlatformIntegrationFactoryInterface, QPlatformIntegrationFactoryInterface_iid) + +class Q_GUI_EXPORT QPlatformIntegrationPlugin : public QObject, public QPlatformIntegrationFactoryInterface +{ + Q_OBJECT + Q_INTERFACES(QPlatformIntegrationFactoryInterface:QFactoryInterface) +public: + explicit QPlatformIntegrationPlugin(QObject *parent = 0); + ~QPlatformIntegrationPlugin(); + + virtual QStringList keys() const = 0; + virtual QPlatformIntegration *create(const QString &key, const QStringList ¶mList) = 0; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMINTEGRATIONPLUGIN_H diff --git a/src/gui/kernel/qplatformscreen_lite.cpp b/src/gui/kernel/qplatformscreen_lite.cpp deleted file mode 100644 index 4c0a02b..0000000 --- a/src/gui/kernel/qplatformscreen_lite.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** 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 "qplatformscreen_lite.h" -#include -#include - -QWidget *QPlatformScreen::topLevelAt(const QPoint & pos) const -{ - QWidgetList list = QApplication::topLevelWidgets(); - for (int i = list.size()-1; i >= 0; --i) { - QWidget *w = list[i]; - //### mask is ignored - if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos)) - return w; - } - - return 0; -} - -QSize QPlatformScreen::physicalSize() const -{ - static const int dpi = 100; - int width = geometry().width() / dpi * qreal(25.4) ; - int height = geometry().height() / dpi * qreal(25.4) ; - return QSize(width,height); -} - diff --git a/src/gui/kernel/qplatformscreen_lite.h b/src/gui/kernel/qplatformscreen_lite.h deleted file mode 100644 index 7d0e28d..0000000 --- a/src/gui/kernel/qplatformscreen_lite.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** 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 QPLATFORMSCREEN_H -#define QPLATFORMSCREEN_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class Q_GUI_EXPORT QPlatformScreen : public QObject -{ - Q_OBJECT -public: - virtual ~QPlatformScreen() { } - - virtual QRect geometry() const = 0; - virtual QRect availableGeometry() const {return geometry();}; - virtual int depth() const = 0; - virtual QImage::Format format() const = 0; - virtual QSize physicalSize() const; - virtual void setDirty(const QRect &) {} - virtual QWidget *topLevelAt(const QPoint &point) const; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QPLATFORMSCREEN_H diff --git a/src/gui/kernel/qplatformscreen_qpa.cpp b/src/gui/kernel/qplatformscreen_qpa.cpp new file mode 100644 index 0000000..478d2d6 --- /dev/null +++ b/src/gui/kernel/qplatformscreen_qpa.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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 "qplatformscreen_qpa.h" +#include +#include + +QWidget *QPlatformScreen::topLevelAt(const QPoint & pos) const +{ + QWidgetList list = QApplication::topLevelWidgets(); + for (int i = list.size()-1; i >= 0; --i) { + QWidget *w = list[i]; + //### mask is ignored + if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos)) + return w; + } + + return 0; +} + +QSize QPlatformScreen::physicalSize() const +{ + static const int dpi = 100; + int width = geometry().width() / dpi * qreal(25.4) ; + int height = geometry().height() / dpi * qreal(25.4) ; + return QSize(width,height); +} + diff --git a/src/gui/kernel/qplatformscreen_qpa.h b/src/gui/kernel/qplatformscreen_qpa.h new file mode 100644 index 0000000..7d0e28d --- /dev/null +++ b/src/gui/kernel/qplatformscreen_qpa.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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 QPLATFORMSCREEN_H +#define QPLATFORMSCREEN_H + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class Q_GUI_EXPORT QPlatformScreen : public QObject +{ + Q_OBJECT +public: + virtual ~QPlatformScreen() { } + + virtual QRect geometry() const = 0; + virtual QRect availableGeometry() const {return geometry();}; + virtual int depth() const = 0; + virtual QImage::Format format() const = 0; + virtual QSize physicalSize() const; + virtual void setDirty(const QRect &) {} + virtual QWidget *topLevelAt(const QPoint &point) const; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMSCREEN_H diff --git a/src/gui/kernel/qplatformwindow_lite.cpp b/src/gui/kernel/qplatformwindow_lite.cpp deleted file mode 100644 index 9efbf8b..0000000 --- a/src/gui/kernel/qplatformwindow_lite.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "qplatformwindow_lite.h" - -#include - -class QPlatformWindowPrivate -{ - QWidget *tlw; - QRect rect; - friend class QPlatformWindow; -}; - -QPlatformWindow::QPlatformWindow(QWidget *tlw) - : d_ptr(new QPlatformWindowPrivate) -{ - Q_D(QPlatformWindow); - d->tlw = tlw; - tlw->setPlatformWindow(this); -} - -QPlatformWindow::~QPlatformWindow() -{ -} - -QWidget *QPlatformWindow::widget() const -{ - Q_D(const QPlatformWindow); - return d->tlw; -} - -void QPlatformWindow::setGeometry(const QRect &rect) -{ - Q_D(QPlatformWindow); - d->rect = rect; -} - -QRect QPlatformWindow::geometry() const -{ - Q_D(const QPlatformWindow); - return d->rect; -} - -/*! -Reimplemented in subclasses to show the surface if \a visible is \c true, and hide it if \a visible is \c false. -*/ -void QPlatformWindow::setVisible(bool visible) -{ - Q_UNUSED(visible); -} -/*! -Requests setting the window flags of this surface to \a type. Returns the actual flags set. -*/ -Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags) -{ - Q_UNUSED(flags); - return Qt::Window; -} - -/*! - Returns the effective window flags for this surface. -*/ -Qt::WindowFlags QPlatformWindow::windowFlags() const -{ - return Qt::Window; -} - -WId QPlatformWindow::winId() const { return WId(0); } - -void QPlatformWindow::setParent(const QPlatformWindow *) { qWarning("This plugin does not support setParent!"); } - -void QPlatformWindow::setWindowTitle(const QString &) {} - -void QPlatformWindow::raise() { qWarning("This plugin does not support raise()"); } - -void QPlatformWindow::lower() { qWarning("This plugin does not support lower()"); } - -void QPlatformWindow::setOpacity(qreal level) -{ - Q_UNUSED(level); - qWarning("This plugin does not support setting window opacity"); -} - -QPlatformGLContext *QPlatformWindow::glContext() -{ - return 0; -} diff --git a/src/gui/kernel/qplatformwindow_lite.h b/src/gui/kernel/qplatformwindow_lite.h deleted file mode 100644 index 5f8d259..0000000 --- a/src/gui/kernel/qplatformwindow_lite.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** 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 QPLATFORMWINDOW_H -#define QPLATFORMWINDOW_H - - -#include -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QPlatformWindowPrivate; -class QWidget; -class QPlatformGLContext; - -class Q_GUI_EXPORT QPlatformWindow -{ - Q_DECLARE_PRIVATE(QPlatformWindow); -public: - QPlatformWindow(QWidget *tlw); - virtual ~QPlatformWindow(); - - QWidget *widget() const; - virtual void setGeometry(const QRect &rect); - virtual QRect geometry() const; - - virtual void setVisible(bool visible); - virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); - virtual Qt::WindowFlags windowFlags() const; - virtual WId winId() const; - virtual void setParent(const QPlatformWindow *window); - - virtual void setWindowTitle(const QString &); - virtual void raise(); - virtual void lower(); - - virtual void setOpacity(qreal level); - - virtual QPlatformGLContext *glContext(); -protected: - QScopedPointer d_ptr; -}; - -QT_END_NAMESPACE - -QT_END_HEADER -#endif //QPLATFORMWINDOW_H diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp new file mode 100644 index 0000000..c0e642c --- /dev/null +++ b/src/gui/kernel/qplatformwindow_qpa.cpp @@ -0,0 +1,85 @@ +#include "qplatformwindow_qpa.h" + +#include + +class QPlatformWindowPrivate +{ + QWidget *tlw; + QRect rect; + friend class QPlatformWindow; +}; + +QPlatformWindow::QPlatformWindow(QWidget *tlw) + : d_ptr(new QPlatformWindowPrivate) +{ + Q_D(QPlatformWindow); + d->tlw = tlw; + tlw->setPlatformWindow(this); +} + +QPlatformWindow::~QPlatformWindow() +{ +} + +QWidget *QPlatformWindow::widget() const +{ + Q_D(const QPlatformWindow); + return d->tlw; +} + +void QPlatformWindow::setGeometry(const QRect &rect) +{ + Q_D(QPlatformWindow); + d->rect = rect; +} + +QRect QPlatformWindow::geometry() const +{ + Q_D(const QPlatformWindow); + return d->rect; +} + +/*! +Reimplemented in subclasses to show the surface if \a visible is \c true, and hide it if \a visible is \c false. +*/ +void QPlatformWindow::setVisible(bool visible) +{ + Q_UNUSED(visible); +} +/*! +Requests setting the window flags of this surface to \a type. Returns the actual flags set. +*/ +Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags) +{ + Q_UNUSED(flags); + return Qt::Window; +} + +/*! + Returns the effective window flags for this surface. +*/ +Qt::WindowFlags QPlatformWindow::windowFlags() const +{ + return Qt::Window; +} + +WId QPlatformWindow::winId() const { return WId(0); } + +void QPlatformWindow::setParent(const QPlatformWindow *) { qWarning("This plugin does not support setParent!"); } + +void QPlatformWindow::setWindowTitle(const QString &) {} + +void QPlatformWindow::raise() { qWarning("This plugin does not support raise()"); } + +void QPlatformWindow::lower() { qWarning("This plugin does not support lower()"); } + +void QPlatformWindow::setOpacity(qreal level) +{ + Q_UNUSED(level); + qWarning("This plugin does not support setting window opacity"); +} + +QPlatformGLContext *QPlatformWindow::glContext() +{ + return 0; +} diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h new file mode 100644 index 0000000..5f8d259 --- /dev/null +++ b/src/gui/kernel/qplatformwindow_qpa.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** 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 QPLATFORMWINDOW_H +#define QPLATFORMWINDOW_H + + +#include +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QPlatformWindowPrivate; +class QWidget; +class QPlatformGLContext; + +class Q_GUI_EXPORT QPlatformWindow +{ + Q_DECLARE_PRIVATE(QPlatformWindow); +public: + QPlatformWindow(QWidget *tlw); + virtual ~QPlatformWindow(); + + QWidget *widget() const; + virtual void setGeometry(const QRect &rect); + virtual QRect geometry() const; + + virtual void setVisible(bool visible); + virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags); + virtual Qt::WindowFlags windowFlags() const; + virtual WId winId() const; + virtual void setParent(const QPlatformWindow *window); + + virtual void setWindowTitle(const QString &); + virtual void raise(); + virtual void lower(); + + virtual void setOpacity(qreal level); + + virtual QPlatformGLContext *glContext(); +protected: + QScopedPointer d_ptr; +}; + +QT_END_NAMESPACE + +QT_END_HEADER +#endif //QPLATFORMWINDOW_H diff --git a/src/gui/kernel/qsound_lite.cpp b/src/gui/kernel/qsound_lite.cpp deleted file mode 100644 index a4c74a8..0000000 --- a/src/gui/kernel/qsound_lite.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 "qapplication.h" - -#ifndef QT_NO_SOUND - -#include "qsound.h" -#include "qsound_p.h" - -class QAuServerLite : public QAuServer -{ - Q_OBJECT -public: - QAuServerLite( QObject* parent ); - - void play( QSound* s ) {} - void stop( QSound* s ) {} - bool okay() { return false; } -}; - -QAuServerLite::QAuServerLite(QObject* parent) : - QAuServer(parent) -{ -} - -QAuServer* qt_new_audio_server() -{ - return new QAuServerLite(qApp); -} - -#include "qsound_lite.moc" - -#endif // QT_NO_SOUND - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qsound_qpa.cpp b/src/gui/kernel/qsound_qpa.cpp new file mode 100644 index 0000000..0714185 --- /dev/null +++ b/src/gui/kernel/qsound_qpa.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "qapplication.h" + +#ifndef QT_NO_SOUND + +#include "qsound.h" +#include "qsound_p.h" + +class QAuServerLite : public QAuServer +{ + Q_OBJECT +public: + QAuServerLite( QObject* parent ); + + void play( QSound* s ) {} + void stop( QSound* s ) {} + bool okay() { return false; } +}; + +QAuServerLite::QAuServerLite(QObject* parent) : + QAuServer(parent) +{ +} + +QAuServer* qt_new_audio_server() +{ + return new QAuServerLite(qApp); +} + +#include "qsound_qpa.moc" + +#endif // QT_NO_SOUND + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 57e3a31..53b35dd 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -76,7 +76,7 @@ # include "private/qwindowsurface_qws_p.h" #endif #if defined(Q_WS_QPA) -#include "qplatformwindow_lite.h" +#include "qplatformwindow_qpa.h" #endif #include "qpainter.h" #include "qtooltip.h" diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp deleted file mode 100644 index f92eb61..0000000 --- a/src/gui/kernel/qwidget_lite.cpp +++ /dev/null @@ -1,809 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 "QtGui/qwidget.h" -#include "QtGui/qevent.h" -#include "QtGui/qapplication.h" -#include "QtGui/private/qbackingstore_p.h" -#include "QtGui/private/qwidget_p.h" -#include "QtGui/private/qgraphicssystem_p.h" -#include "QtGui/private/qapplication_p.h" -#include "QtGui/qdesktopwidget.h" -#include "QtGui/qplatformwindow_lite.h" - -#include - -QT_BEGIN_NAMESPACE -static QPlatformScreen *qt_screenForWidget(const QWidget *w); - -void setParentForChildrenOfWidget(QPlatformWindow *window, const QWidget *widget) -{ - QObjectList children = widget->children(); - for (int i = 0; i < children.size(); i++) { - if (children.at(i)->isWidgetType()) { - const QWidget *childWidget = qobject_cast(children.at(i)); - if (childWidget) { // should not be nessesary - if (childWidget->platformWindow()) { - childWidget->platformWindow()->setParent(window); - } else { - setParentForChildrenOfWidget(window,childWidget); - } - } - } - } -} - -void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) -{ - Q_Q(QWidget); - - Q_UNUSED(window); - Q_UNUSED(initializeWindow); - Q_UNUSED(destroyOldWindow); - // XXX - - Qt::WindowFlags flags = data.window_flags; - - if ((!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow()) || q->windowType() == Qt::Desktop ) - return; // we only care about real toplevels - - QWindowSurface *surface = q->windowSurface(); - QPlatformWindow *platformWindow = q->platformWindow(); - - if (!platformWindow) { - platformWindow = QApplicationPrivate::platformIntegration()->createPlatformWindow(q); - } - Q_ASSERT(platformWindow); - - if (!surface) { - surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId()); - } - - data.window_flags = q->platformWindow()->setWindowFlags(data.window_flags); - - setWinId(q->platformWindow()->winId()); - - //first check children. then find who for parent. - setParentForChildrenOfWidget(platformWindow,q); - if (QWidget *nativeParent = q->nativeParentWidget()) { - if (nativeParent->platformWindow()) { - platformWindow->setParent(nativeParent->platformWindow()); - } - } - - QApplicationPrivate::platformIntegration()->moveToScreen(q, screenNumber); -// qDebug() << "create_sys" << q << q->internalWinId(); -} - -void QWidget::destroy(bool destroyWindow, bool destroySubWindows) -{ - Q_D(QWidget); - //### jl: subwindows now enabled - Q_UNUSED(destroySubWindows); - - if ((windowType() == Qt::Popup)) - qApp->d_func()->closePopup(this); - - //### we don't have proper focus event handling yet - if (this == QApplicationPrivate::active_window) - QApplication::setActiveWindow(0); - - if (windowType() != Qt::Desktop) { - if (destroyWindow && isWindow()) { - QTLWExtra *topData = d->maybeTopData(); - if (topData) { - delete topData->platformWindow; - topData->platformWindow = 0; - } - } else { - if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) { - d->hide_sys(); - } - } - } -} - -void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) -{ - Q_Q(QWidget); - - // QWidget *oldParent = q->parentWidget(); - Qt::WindowFlags oldFlags = data.window_flags; - - int targetScreen = -1; - // Handle a request to move the widget to a particular screen - if (newparent && newparent->windowType() == Qt::Desktop) { - // make sure the widget is created on the same screen as the - // programmer specified desktop widget - - // get the desktop's screen number - targetScreen = newparent->d_func()->screenNumber; - newparent = 0; - } - - if (parent != newparent) { - QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? - if (q->platformWindow()) { - QWidget * parentWithWindow = newparent->platformWindow()? newparent : newparent->nativeParentWidget(); - if (parentWithWindow && parentWithWindow->platformWindow()) { - q->platformWindow()->setParent(parentWithWindow->platformWindow()); - } - } - - } - - if (!newparent) { - f |= Qt::Window; - if (targetScreen == -1) { - if (parent) - targetScreen = qobject_cast(parent)->d_func()->screenNumber; - } - } - - bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); - - data.window_flags = f; - q->setAttribute(Qt::WA_WState_Created, false); - q->setAttribute(Qt::WA_WState_Visible, false); - q->setAttribute(Qt::WA_WState_Hidden, false); - - if (f & Qt::Window) { - //qDebug() << "setParent_sys" << q << newparent << hex << f; - if (QPlatformWindow *window = q->platformWindow()) - data.window_flags = window->setWindowFlags(data.window_flags); - } - // XXX Reparenting child to toplevel or vice versa ### - if ((f&Qt::Window) && !(oldFlags&Qt::Window)) { - //qDebug() << "setParent_sys() change to toplevel"; - q->create(); //### this cannot be right - } else if ((f&Qt::Window) && !(oldFlags&Qt::Window)) { - qDebug() << "######## setParent_sys() change from toplevel not implemented ########"; - } - - - if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden) - q->setAttribute(Qt::WA_WState_Hidden); - q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); - - // move the window to the selected screen - if (!newparent && targetScreen != -1) { - screenNumber = targetScreen; - // only if it is already created - if (q->testAttribute(Qt::WA_WState_Created)) { - QPlatformIntegration *platform = QApplicationPrivate::platformIntegration(); - platform->moveToScreen(q, targetScreen); - } - } -} - -QPoint QWidget::mapToGlobal(const QPoint &pos) const -{ - int x=pos.x(), y=pos.y(); - const QWidget* w = this; - while (w) { - x += w->data->crect.x(); - y += w->data->crect.y(); - w = w->isWindow() ? 0 : w->parentWidget(); - } - return QPoint(x, y); -} - -QPoint QWidget::mapFromGlobal(const QPoint &pos) const -{ - int x=pos.x(), y=pos.y(); - const QWidget* w = this; - while (w) { - x -= w->data->crect.x(); - y -= w->data->crect.y(); - w = w->isWindow() ? 0 : w->parentWidget(); - } - return QPoint(x, y); -} - -void QWidgetPrivate::updateSystemBackground() {} - -#ifndef QT_NO_CURSOR -void QWidgetPrivate::setCursor_sys(const QCursor &cursor) -{ - Q_UNUSED(cursor); - Q_Q(QWidget); - if (q->isVisible()) - qt_lite_set_cursor(q, false); -} - -void QWidgetPrivate::unsetCursor_sys() -{ - Q_Q(QWidget); - if (q->isVisible()) - qt_lite_set_cursor(q, false); -} - -void QWidgetPrivate::updateCursor() const -{ - // XXX -} - -#endif //QT_NO_CURSOR - -void QWidgetPrivate::setWindowTitle_sys(const QString &caption) -{ - Q_Q(QWidget); - if (!q->isWindow()) - return; - - if (QPlatformWindow *window = q->platformWindow()) - window->setWindowTitle(caption); - -} - -void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/) -{ -} - -void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) -{ - Q_UNUSED(iconText); -} - -QWidget *qt_pressGrab = 0; -QWidget *qt_mouseGrb = 0; -static QWidget *keyboardGrb = 0; - -void QWidget::grabMouse() -{ - if (qt_mouseGrb) - qt_mouseGrb->releaseMouse(); - - // XXX - //qwsDisplay()->grabMouse(this,true); - - qt_mouseGrb = this; - qt_pressGrab = 0; -} - -#ifndef QT_NO_CURSOR -void QWidget::grabMouse(const QCursor &cursor) -{ - Q_UNUSED(cursor); - - if (qt_mouseGrb) - qt_mouseGrb->releaseMouse(); - - // XXX - //qwsDisplay()->grabMouse(this,true); - //qwsDisplay()->selectCursor(this, cursor.handle()); - qt_mouseGrb = this; - qt_pressGrab = 0; -} -#endif - -void QWidget::releaseMouse() -{ - if (qt_mouseGrb == this) { - // XXX - //qwsDisplay()->grabMouse(this,false); - qt_mouseGrb = 0; - } -} - -void QWidget::grabKeyboard() -{ - if (keyboardGrb) - keyboardGrb->releaseKeyboard(); - // XXX - //qwsDisplay()->grabKeyboard(this, true); - keyboardGrb = this; -} - -void QWidget::releaseKeyboard() -{ - if (keyboardGrb == this) { - // XXX - //qwsDisplay()->grabKeyboard(this, false); - keyboardGrb = 0; - } -} - -QWidget *QWidget::mouseGrabber() -{ - if (qt_mouseGrb) - return qt_mouseGrb; - return qt_pressGrab; -} - -QWidget *QWidget::keyboardGrabber() -{ - return keyboardGrb; -} - -void QWidget::activateWindow() -{ - // XXX -// qDebug() << "QWidget::activateWindow" << this; - QApplication::setActiveWindow(this); //##### -} - -void QWidgetPrivate::show_sys() -{ - Q_Q(QWidget); - q->setAttribute(Qt::WA_Mapped); - if (q->testAttribute(Qt::WA_DontShowOnScreen)) { - invalidateBuffer(q->rect()); - return; - } - - QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); - - QPlatformWindow *window = q->platformWindow(); - if (window) { - const QRect geomRect = q->geometry(); - const QRect windowRect = window->geometry(); - if (windowRect != geomRect) { - window->setGeometry(geomRect); - } - if (q->isWindow()) { - if (QWindowSurface *surface = q->windowSurface()) - if (windowRect.size() != geomRect.size()) { - surface->resize(geomRect.size()); - } - - if (window) - window->setVisible(true); - - if (q->windowType() != Qt::Popup && q->windowType() != Qt::ToolTip && !(q->windowFlags() & Qt::X11BypassWindowManagerHint)) - q->activateWindow(); //### - } - } -} - - -void QWidgetPrivate::hide_sys() -{ - Q_Q(QWidget); - q->setAttribute(Qt::WA_Mapped, false); - if (!q->isWindow()) { - QWidget *p = q->parentWidget(); - if (p &&p->isVisible()) { - invalidateBuffer(q->rect()); - } - return; - } - if (QPlatformWindow *window = q->platformWindow()) { - window->setVisible(false); - } - - //### we don't yet have proper focus event handling - if (q == QApplicationPrivate::active_window) - QApplication::setActiveWindow(0); - -} - -void QWidgetPrivate::setMaxWindowState_helper() -{ - setFullScreenSize_helper(); //### decoration size -} - -void QWidgetPrivate::setFullScreenSize_helper() -{ - Q_Q(QWidget); - - const uint old_state = data.in_set_window_state; - data.in_set_window_state = 1; - - const QRect screen = qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(q)); - q->move(screen.topLeft()); - q->resize(screen.size()); - - data.in_set_window_state = old_state; -} - -static Qt::WindowStates effectiveState(Qt::WindowStates state) - { - if (state & Qt::WindowMinimized) - return Qt::WindowMinimized; - else if (state & Qt::WindowFullScreen) - return Qt::WindowFullScreen; - else if (state & Qt::WindowMaximized) - return Qt::WindowMaximized; - return Qt::WindowNoState; - } - -void QWidget::setWindowState(Qt::WindowStates newstate) -{ - Q_D(QWidget); - Qt::WindowStates oldstate = windowState(); - if (oldstate == newstate) - return; - if (isWindow() && !testAttribute(Qt::WA_WState_Created)) - create(); - - data->window_state = newstate; - data->in_set_window_state = 1; - bool needShow = false; - Qt::WindowStates newEffectiveState = effectiveState(newstate); - Qt::WindowStates oldEffectiveState = effectiveState(oldstate); - if (isWindow() && newEffectiveState != oldEffectiveState) { - d->createTLExtra(); - if (oldEffectiveState == Qt::WindowNoState) { //normal - d->topData()->normalGeometry = geometry(); - } else if (oldEffectiveState == Qt::WindowFullScreen) { - setParent(0, d->topData()->savedFlags); - needShow = true; - } else if (oldEffectiveState == Qt::WindowMinimized) { - needShow = true; - } - - if (newEffectiveState == Qt::WindowMinimized) { - //### not ideal... - hide(); - needShow = false; - } else if (newEffectiveState == Qt::WindowFullScreen) { - d->topData()->savedFlags = windowFlags(); - setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint)); - d->setFullScreenSize_helper(); - raise(); - needShow = true; - } else if (newEffectiveState == Qt::WindowMaximized) { - createWinId(); - d->setMaxWindowState_helper(); - } else { //normal - QRect r = d->topData()->normalGeometry; - if (r.width() >= 0) { - d->topData()->normalGeometry = QRect(0,0,-1,-1); - setGeometry(r); - } - } - } - data->in_set_window_state = 0; - - if (needShow) - show(); - - if (newstate & Qt::WindowActive) - activateWindow(); - - QWindowStateChangeEvent e(oldstate); - QApplication::sendEvent(this, &e); -} - -void QWidgetPrivate::setFocus_sys() -{ - -} - -void QWidgetPrivate::raise_sys() -{ - Q_Q(QWidget); - if (q->isWindow()) { - q->platformWindow()->raise(); - } -} - -void QWidgetPrivate::lower_sys() -{ - Q_Q(QWidget); - if (q->isWindow()) { - Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - q->platformWindow()->lower(); - } else if (QWidget *p = q->parentWidget()) { - setDirtyOpaqueRegion(); - p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); - } -} - -void QWidgetPrivate::stackUnder_sys(QWidget*) -{ - Q_Q(QWidget); - if (QWidget *p = q->parentWidget()) { - setDirtyOpaqueRegion(); - p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); - } -} - -void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) -{ - Q_Q(QWidget); - if (extra) { // any size restrictions? - w = qMin(w,extra->maxw); - h = qMin(h,extra->maxh); - w = qMax(w,extra->minw); - h = qMax(h,extra->minh); - } - - QPoint oldp = q->geometry().topLeft(); - QSize olds = q->size(); - QRect r(x, y, w, h); - - bool isResize = olds != r.size(); - isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter? - - - // We only care about stuff that changes the geometry, or may - // cause the window manager to change its state - if (r.size() == olds && oldp == r.topLeft()) - return; - - if (!data.in_set_window_state) { - q->data->window_state &= ~Qt::WindowMaximized; - q->data->window_state &= ~Qt::WindowFullScreen; - if (q->isWindow()) - topData()->normalGeometry = QRect(0, 0, -1, -1); - } - - QPoint oldPos = q->pos(); - data.crect = r; - - if (q->isVisible()) { - if (q->platformWindow()) { - if (q->isWindow()) { - q->platformWindow()->setGeometry(q->frameGeometry()); - } else { - QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint()); - q->platformWindow()->setGeometry(QRect(posInNativeParent,r.size())); - } - const QWidgetBackingStore *bs = maybeBackingStore(); - if (bs->windowSurface) { - if (isResize) - bs->windowSurface->resize(r.size()); - } - } else { - if (isMove && !isResize) - moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y()); - else - invalidateBuffer_resizeHelper(oldPos, olds); - } - - if (isMove) { - QMoveEvent e(q->pos(), oldPos); - QApplication::sendEvent(q, &e); - } - if (isResize) { - QResizeEvent e(r.size(), olds); - QApplication::sendEvent(q, &e); - if (q->isWindow()) - q->update(); - } - } else { // not visible - if (isMove && q->pos() != oldPos) - q->setAttribute(Qt::WA_PendingMoveEvent, true); - if (isResize) - q->setAttribute(Qt::WA_PendingResizeEvent, true); - } - -} - -void QWidgetPrivate::setConstraints_sys() -{ -} - -void QWidgetPrivate::scroll_sys(int dx, int dy) -{ - Q_Q(QWidget); - scrollChildren(dx, dy); - scrollRect(q->rect(), dx, dy); -} - -void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) -{ - scrollRect(r, dx, dy); -} - -static QPlatformScreen *qt_screenForWidget(const QWidget *w) -{ - if (!w) - return 0; - QRect frame = w->frameGeometry(); - if (!w->isWindow()) - frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0))); - const QPoint p = (frame.topLeft() + frame.bottomRight()) / 2; - - QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); - QList screens = pi->screens(); - - for (int i = 0; i < screens.size(); ++i) { - if (screens[i]->geometry().contains(p)) - return screens[i]; - } - - // Assume screen zero if we have it. - if (!screens.isEmpty()) - return screens[0]; - else - qWarning("qt_screenForWidget: no screens"); - - return 0; -} - -int QWidget::metric(PaintDeviceMetric m) const -{ - Q_D(const QWidget); - - QPlatformScreen *screen = qt_screenForWidget(this); - if (!screen) { - if (m == PdmDpiX || m == PdmDpiY) - return 72; - return QPaintDevice::metric(m); - } - int val; - if (m == PdmWidth) { - val = data->crect.width(); - } else if (m == PdmWidthMM) { - val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width(); - } else if (m == PdmHeight) { - val = data->crect.height(); - } else if (m == PdmHeightMM) { - val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height(); - } else if (m == PdmDepth) { - return screen->depth(); - } else if (m == PdmDpiX || m == PdmPhysicalDpiX) { - if (d->extra && d->extra->customDpiX) - return d->extra->customDpiX; - else if (d->parent) - return static_cast(d->parent)->metric(m); - return qRound(screen->geometry().width() / double(screen->physicalSize().width() / 25.4)); - } else if (m == PdmDpiY || m == PdmPhysicalDpiY) { - if (d->extra && d->extra->customDpiY) - return d->extra->customDpiY; - else if (d->parent) - return static_cast(d->parent)->metric(m); - return qRound(screen->geometry().height() / double(screen->physicalSize().height() / 25.4)); - } else { - val = QPaintDevice::metric(m);// XXX - } - return val; -} - -void QWidgetPrivate::createSysExtra() -{ -} - -void QWidgetPrivate::deleteSysExtra() -{ -} - -void QWidgetPrivate::createTLSysExtra() -{ -} - -void QWidgetPrivate::deleteTLSysExtra() -{ -} - -void QWidgetPrivate::registerDropSite(bool on) -{ - Q_UNUSED(on); -} - -void QWidgetPrivate::setMask_sys(const QRegion ®ion) -{ - Q_UNUSED(region); - // XXX -} - -void QWidgetPrivate::updateFrameStrut() -{ - // XXX -} - -void QWidgetPrivate::setWindowOpacity_sys(qreal level) -{ - Q_Q(QWidget); - q->platformWindow()->setOpacity(level); -} - -void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect) -{ - Q_UNUSED(dontShow); - Q_UNUSED(oldRect); - // XXX -} - -QPaintEngine *QWidget::paintEngine() const -{ - qWarning("QWidget::paintEngine: Should no longer be called"); - return 0; //##### @@@ -} - -QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys() -{ - Q_Q(QWidget); - return QApplicationPrivate::platformIntegration()->createWindowSurface(q,0); -} - -void QWidgetPrivate::setModal_sys() -{ -} - -#ifndef QT_NO_CURSOR -void qt_lite_set_cursor(QWidget * w, bool force) -{ - static QCursor arrowCursor(Qt::ArrowCursor); - static QPointer lastUnderMouse = 0; - - QCursor * override = QApplication::overrideCursor(); - - if (override && w != 0) - return; - - QWidget *cursorWidget; - QCursor cursorCursor; - - do { - if (w == 0) { - if (override) { - cursorCursor = *override; - cursorWidget = QApplication::topLevelAt(QCursor::pos()); - break; - } - w = QApplication::widgetAt(QCursor::pos()); - if (w == 0) // clear the override cursor while over empty space - w = QApplication::desktop(); - } else if (force) { - lastUnderMouse = w; - } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse - && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) { - w = lastUnderMouse; - } - if (w == QApplication::desktop() && !override) { - cursorCursor = arrowCursor; - cursorWidget = w; - break; - } - - QWidget * curWin = QApplication::activeWindow(); - if (!curWin && w && w->internalWinId()) - return; - QWidget* cW = w && !w->internalWinId() ? w : curWin; - - if (!cW || cW->window() != w->window() || - !cW->isVisible() || !cW->underMouse() || override) - return; - - cursorCursor = w->cursor(); - cursorWidget = w; - } while (0); - foreach (QWeakPointer cursor, QGraphicsSystemCursorPrivate::getInstances()) - if (cursor) - cursor.data()->changeCursor(&cursorCursor, cursorWidget); -} -#endif //QT_NO_CURSOR - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp new file mode 100644 index 0000000..11fa211 --- /dev/null +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -0,0 +1,809 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "QtGui/qwidget.h" +#include "QtGui/qevent.h" +#include "QtGui/qapplication.h" +#include "QtGui/private/qbackingstore_p.h" +#include "QtGui/private/qwidget_p.h" +#include "QtGui/private/qgraphicssystem_p.h" +#include "QtGui/private/qapplication_p.h" +#include "QtGui/qdesktopwidget.h" +#include "QtGui/qplatformwindow_qpa.h" + +#include + +QT_BEGIN_NAMESPACE +static QPlatformScreen *qt_screenForWidget(const QWidget *w); + +void setParentForChildrenOfWidget(QPlatformWindow *window, const QWidget *widget) +{ + QObjectList children = widget->children(); + for (int i = 0; i < children.size(); i++) { + if (children.at(i)->isWidgetType()) { + const QWidget *childWidget = qobject_cast(children.at(i)); + if (childWidget) { // should not be nessesary + if (childWidget->platformWindow()) { + childWidget->platformWindow()->setParent(window); + } else { + setParentForChildrenOfWidget(window,childWidget); + } + } + } + } +} + +void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) +{ + Q_Q(QWidget); + + Q_UNUSED(window); + Q_UNUSED(initializeWindow); + Q_UNUSED(destroyOldWindow); + // XXX + + Qt::WindowFlags flags = data.window_flags; + + if ((!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow()) || q->windowType() == Qt::Desktop ) + return; // we only care about real toplevels + + QWindowSurface *surface = q->windowSurface(); + QPlatformWindow *platformWindow = q->platformWindow(); + + if (!platformWindow) { + platformWindow = QApplicationPrivate::platformIntegration()->createPlatformWindow(q); + } + Q_ASSERT(platformWindow); + + if (!surface) { + surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId()); + } + + data.window_flags = q->platformWindow()->setWindowFlags(data.window_flags); + + setWinId(q->platformWindow()->winId()); + + //first check children. then find who for parent. + setParentForChildrenOfWidget(platformWindow,q); + if (QWidget *nativeParent = q->nativeParentWidget()) { + if (nativeParent->platformWindow()) { + platformWindow->setParent(nativeParent->platformWindow()); + } + } + + QApplicationPrivate::platformIntegration()->moveToScreen(q, screenNumber); +// qDebug() << "create_sys" << q << q->internalWinId(); +} + +void QWidget::destroy(bool destroyWindow, bool destroySubWindows) +{ + Q_D(QWidget); + //### jl: subwindows now enabled + Q_UNUSED(destroySubWindows); + + if ((windowType() == Qt::Popup)) + qApp->d_func()->closePopup(this); + + //### we don't have proper focus event handling yet + if (this == QApplicationPrivate::active_window) + QApplication::setActiveWindow(0); + + if (windowType() != Qt::Desktop) { + if (destroyWindow && isWindow()) { + QTLWExtra *topData = d->maybeTopData(); + if (topData) { + delete topData->platformWindow; + topData->platformWindow = 0; + } + } else { + if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) { + d->hide_sys(); + } + } + } +} + +void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) +{ + Q_Q(QWidget); + + // QWidget *oldParent = q->parentWidget(); + Qt::WindowFlags oldFlags = data.window_flags; + + int targetScreen = -1; + // Handle a request to move the widget to a particular screen + if (newparent && newparent->windowType() == Qt::Desktop) { + // make sure the widget is created on the same screen as the + // programmer specified desktop widget + + // get the desktop's screen number + targetScreen = newparent->d_func()->screenNumber; + newparent = 0; + } + + if (parent != newparent) { + QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? + if (q->platformWindow()) { + QWidget * parentWithWindow = newparent->platformWindow()? newparent : newparent->nativeParentWidget(); + if (parentWithWindow && parentWithWindow->platformWindow()) { + q->platformWindow()->setParent(parentWithWindow->platformWindow()); + } + } + + } + + if (!newparent) { + f |= Qt::Window; + if (targetScreen == -1) { + if (parent) + targetScreen = qobject_cast(parent)->d_func()->screenNumber; + } + } + + bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); + + data.window_flags = f; + q->setAttribute(Qt::WA_WState_Created, false); + q->setAttribute(Qt::WA_WState_Visible, false); + q->setAttribute(Qt::WA_WState_Hidden, false); + + if (f & Qt::Window) { + //qDebug() << "setParent_sys" << q << newparent << hex << f; + if (QPlatformWindow *window = q->platformWindow()) + data.window_flags = window->setWindowFlags(data.window_flags); + } + // XXX Reparenting child to toplevel or vice versa ### + if ((f&Qt::Window) && !(oldFlags&Qt::Window)) { + //qDebug() << "setParent_sys() change to toplevel"; + q->create(); //### this cannot be right + } else if ((f&Qt::Window) && !(oldFlags&Qt::Window)) { + qDebug() << "######## setParent_sys() change from toplevel not implemented ########"; + } + + + if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden) + q->setAttribute(Qt::WA_WState_Hidden); + q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); + + // move the window to the selected screen + if (!newparent && targetScreen != -1) { + screenNumber = targetScreen; + // only if it is already created + if (q->testAttribute(Qt::WA_WState_Created)) { + QPlatformIntegration *platform = QApplicationPrivate::platformIntegration(); + platform->moveToScreen(q, targetScreen); + } + } +} + +QPoint QWidget::mapToGlobal(const QPoint &pos) const +{ + int x=pos.x(), y=pos.y(); + const QWidget* w = this; + while (w) { + x += w->data->crect.x(); + y += w->data->crect.y(); + w = w->isWindow() ? 0 : w->parentWidget(); + } + return QPoint(x, y); +} + +QPoint QWidget::mapFromGlobal(const QPoint &pos) const +{ + int x=pos.x(), y=pos.y(); + const QWidget* w = this; + while (w) { + x -= w->data->crect.x(); + y -= w->data->crect.y(); + w = w->isWindow() ? 0 : w->parentWidget(); + } + return QPoint(x, y); +} + +void QWidgetPrivate::updateSystemBackground() {} + +#ifndef QT_NO_CURSOR +void QWidgetPrivate::setCursor_sys(const QCursor &cursor) +{ + Q_UNUSED(cursor); + Q_Q(QWidget); + if (q->isVisible()) + qt_lite_set_cursor(q, false); +} + +void QWidgetPrivate::unsetCursor_sys() +{ + Q_Q(QWidget); + if (q->isVisible()) + qt_lite_set_cursor(q, false); +} + +void QWidgetPrivate::updateCursor() const +{ + // XXX +} + +#endif //QT_NO_CURSOR + +void QWidgetPrivate::setWindowTitle_sys(const QString &caption) +{ + Q_Q(QWidget); + if (!q->isWindow()) + return; + + if (QPlatformWindow *window = q->platformWindow()) + window->setWindowTitle(caption); + +} + +void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/) +{ +} + +void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) +{ + Q_UNUSED(iconText); +} + +QWidget *qt_pressGrab = 0; +QWidget *qt_mouseGrb = 0; +static QWidget *keyboardGrb = 0; + +void QWidget::grabMouse() +{ + if (qt_mouseGrb) + qt_mouseGrb->releaseMouse(); + + // XXX + //qwsDisplay()->grabMouse(this,true); + + qt_mouseGrb = this; + qt_pressGrab = 0; +} + +#ifndef QT_NO_CURSOR +void QWidget::grabMouse(const QCursor &cursor) +{ + Q_UNUSED(cursor); + + if (qt_mouseGrb) + qt_mouseGrb->releaseMouse(); + + // XXX + //qwsDisplay()->grabMouse(this,true); + //qwsDisplay()->selectCursor(this, cursor.handle()); + qt_mouseGrb = this; + qt_pressGrab = 0; +} +#endif + +void QWidget::releaseMouse() +{ + if (qt_mouseGrb == this) { + // XXX + //qwsDisplay()->grabMouse(this,false); + qt_mouseGrb = 0; + } +} + +void QWidget::grabKeyboard() +{ + if (keyboardGrb) + keyboardGrb->releaseKeyboard(); + // XXX + //qwsDisplay()->grabKeyboard(this, true); + keyboardGrb = this; +} + +void QWidget::releaseKeyboard() +{ + if (keyboardGrb == this) { + // XXX + //qwsDisplay()->grabKeyboard(this, false); + keyboardGrb = 0; + } +} + +QWidget *QWidget::mouseGrabber() +{ + if (qt_mouseGrb) + return qt_mouseGrb; + return qt_pressGrab; +} + +QWidget *QWidget::keyboardGrabber() +{ + return keyboardGrb; +} + +void QWidget::activateWindow() +{ + // XXX +// qDebug() << "QWidget::activateWindow" << this; + QApplication::setActiveWindow(this); //##### +} + +void QWidgetPrivate::show_sys() +{ + Q_Q(QWidget); + q->setAttribute(Qt::WA_Mapped); + if (q->testAttribute(Qt::WA_DontShowOnScreen)) { + invalidateBuffer(q->rect()); + return; + } + + QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); + + QPlatformWindow *window = q->platformWindow(); + if (window) { + const QRect geomRect = q->geometry(); + const QRect windowRect = window->geometry(); + if (windowRect != geomRect) { + window->setGeometry(geomRect); + } + if (q->isWindow()) { + if (QWindowSurface *surface = q->windowSurface()) + if (windowRect.size() != geomRect.size()) { + surface->resize(geomRect.size()); + } + + if (window) + window->setVisible(true); + + if (q->windowType() != Qt::Popup && q->windowType() != Qt::ToolTip && !(q->windowFlags() & Qt::X11BypassWindowManagerHint)) + q->activateWindow(); //### + } + } +} + + +void QWidgetPrivate::hide_sys() +{ + Q_Q(QWidget); + q->setAttribute(Qt::WA_Mapped, false); + if (!q->isWindow()) { + QWidget *p = q->parentWidget(); + if (p &&p->isVisible()) { + invalidateBuffer(q->rect()); + } + return; + } + if (QPlatformWindow *window = q->platformWindow()) { + window->setVisible(false); + } + + //### we don't yet have proper focus event handling + if (q == QApplicationPrivate::active_window) + QApplication::setActiveWindow(0); + +} + +void QWidgetPrivate::setMaxWindowState_helper() +{ + setFullScreenSize_helper(); //### decoration size +} + +void QWidgetPrivate::setFullScreenSize_helper() +{ + Q_Q(QWidget); + + const uint old_state = data.in_set_window_state; + data.in_set_window_state = 1; + + const QRect screen = qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(q)); + q->move(screen.topLeft()); + q->resize(screen.size()); + + data.in_set_window_state = old_state; +} + +static Qt::WindowStates effectiveState(Qt::WindowStates state) + { + if (state & Qt::WindowMinimized) + return Qt::WindowMinimized; + else if (state & Qt::WindowFullScreen) + return Qt::WindowFullScreen; + else if (state & Qt::WindowMaximized) + return Qt::WindowMaximized; + return Qt::WindowNoState; + } + +void QWidget::setWindowState(Qt::WindowStates newstate) +{ + Q_D(QWidget); + Qt::WindowStates oldstate = windowState(); + if (oldstate == newstate) + return; + if (isWindow() && !testAttribute(Qt::WA_WState_Created)) + create(); + + data->window_state = newstate; + data->in_set_window_state = 1; + bool needShow = false; + Qt::WindowStates newEffectiveState = effectiveState(newstate); + Qt::WindowStates oldEffectiveState = effectiveState(oldstate); + if (isWindow() && newEffectiveState != oldEffectiveState) { + d->createTLExtra(); + if (oldEffectiveState == Qt::WindowNoState) { //normal + d->topData()->normalGeometry = geometry(); + } else if (oldEffectiveState == Qt::WindowFullScreen) { + setParent(0, d->topData()->savedFlags); + needShow = true; + } else if (oldEffectiveState == Qt::WindowMinimized) { + needShow = true; + } + + if (newEffectiveState == Qt::WindowMinimized) { + //### not ideal... + hide(); + needShow = false; + } else if (newEffectiveState == Qt::WindowFullScreen) { + d->topData()->savedFlags = windowFlags(); + setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint)); + d->setFullScreenSize_helper(); + raise(); + needShow = true; + } else if (newEffectiveState == Qt::WindowMaximized) { + createWinId(); + d->setMaxWindowState_helper(); + } else { //normal + QRect r = d->topData()->normalGeometry; + if (r.width() >= 0) { + d->topData()->normalGeometry = QRect(0,0,-1,-1); + setGeometry(r); + } + } + } + data->in_set_window_state = 0; + + if (needShow) + show(); + + if (newstate & Qt::WindowActive) + activateWindow(); + + QWindowStateChangeEvent e(oldstate); + QApplication::sendEvent(this, &e); +} + +void QWidgetPrivate::setFocus_sys() +{ + +} + +void QWidgetPrivate::raise_sys() +{ + Q_Q(QWidget); + if (q->isWindow()) { + q->platformWindow()->raise(); + } +} + +void QWidgetPrivate::lower_sys() +{ + Q_Q(QWidget); + if (q->isWindow()) { + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); + q->platformWindow()->lower(); + } else if (QWidget *p = q->parentWidget()) { + setDirtyOpaqueRegion(); + p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); + } +} + +void QWidgetPrivate::stackUnder_sys(QWidget*) +{ + Q_Q(QWidget); + if (QWidget *p = q->parentWidget()) { + setDirtyOpaqueRegion(); + p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); + } +} + +void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) +{ + Q_Q(QWidget); + if (extra) { // any size restrictions? + w = qMin(w,extra->maxw); + h = qMin(h,extra->maxh); + w = qMax(w,extra->minw); + h = qMax(h,extra->minh); + } + + QPoint oldp = q->geometry().topLeft(); + QSize olds = q->size(); + QRect r(x, y, w, h); + + bool isResize = olds != r.size(); + isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter? + + + // We only care about stuff that changes the geometry, or may + // cause the window manager to change its state + if (r.size() == olds && oldp == r.topLeft()) + return; + + if (!data.in_set_window_state) { + q->data->window_state &= ~Qt::WindowMaximized; + q->data->window_state &= ~Qt::WindowFullScreen; + if (q->isWindow()) + topData()->normalGeometry = QRect(0, 0, -1, -1); + } + + QPoint oldPos = q->pos(); + data.crect = r; + + if (q->isVisible()) { + if (q->platformWindow()) { + if (q->isWindow()) { + q->platformWindow()->setGeometry(q->frameGeometry()); + } else { + QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint()); + q->platformWindow()->setGeometry(QRect(posInNativeParent,r.size())); + } + const QWidgetBackingStore *bs = maybeBackingStore(); + if (bs->windowSurface) { + if (isResize) + bs->windowSurface->resize(r.size()); + } + } else { + if (isMove && !isResize) + moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y()); + else + invalidateBuffer_resizeHelper(oldPos, olds); + } + + if (isMove) { + QMoveEvent e(q->pos(), oldPos); + QApplication::sendEvent(q, &e); + } + if (isResize) { + QResizeEvent e(r.size(), olds); + QApplication::sendEvent(q, &e); + if (q->isWindow()) + q->update(); + } + } else { // not visible + if (isMove && q->pos() != oldPos) + q->setAttribute(Qt::WA_PendingMoveEvent, true); + if (isResize) + q->setAttribute(Qt::WA_PendingResizeEvent, true); + } + +} + +void QWidgetPrivate::setConstraints_sys() +{ +} + +void QWidgetPrivate::scroll_sys(int dx, int dy) +{ + Q_Q(QWidget); + scrollChildren(dx, dy); + scrollRect(q->rect(), dx, dy); +} + +void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) +{ + scrollRect(r, dx, dy); +} + +static QPlatformScreen *qt_screenForWidget(const QWidget *w) +{ + if (!w) + return 0; + QRect frame = w->frameGeometry(); + if (!w->isWindow()) + frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0))); + const QPoint p = (frame.topLeft() + frame.bottomRight()) / 2; + + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList screens = pi->screens(); + + for (int i = 0; i < screens.size(); ++i) { + if (screens[i]->geometry().contains(p)) + return screens[i]; + } + + // Assume screen zero if we have it. + if (!screens.isEmpty()) + return screens[0]; + else + qWarning("qt_screenForWidget: no screens"); + + return 0; +} + +int QWidget::metric(PaintDeviceMetric m) const +{ + Q_D(const QWidget); + + QPlatformScreen *screen = qt_screenForWidget(this); + if (!screen) { + if (m == PdmDpiX || m == PdmDpiY) + return 72; + return QPaintDevice::metric(m); + } + int val; + if (m == PdmWidth) { + val = data->crect.width(); + } else if (m == PdmWidthMM) { + val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width(); + } else if (m == PdmHeight) { + val = data->crect.height(); + } else if (m == PdmHeightMM) { + val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height(); + } else if (m == PdmDepth) { + return screen->depth(); + } else if (m == PdmDpiX || m == PdmPhysicalDpiX) { + if (d->extra && d->extra->customDpiX) + return d->extra->customDpiX; + else if (d->parent) + return static_cast(d->parent)->metric(m); + return qRound(screen->geometry().width() / double(screen->physicalSize().width() / 25.4)); + } else if (m == PdmDpiY || m == PdmPhysicalDpiY) { + if (d->extra && d->extra->customDpiY) + return d->extra->customDpiY; + else if (d->parent) + return static_cast(d->parent)->metric(m); + return qRound(screen->geometry().height() / double(screen->physicalSize().height() / 25.4)); + } else { + val = QPaintDevice::metric(m);// XXX + } + return val; +} + +void QWidgetPrivate::createSysExtra() +{ +} + +void QWidgetPrivate::deleteSysExtra() +{ +} + +void QWidgetPrivate::createTLSysExtra() +{ +} + +void QWidgetPrivate::deleteTLSysExtra() +{ +} + +void QWidgetPrivate::registerDropSite(bool on) +{ + Q_UNUSED(on); +} + +void QWidgetPrivate::setMask_sys(const QRegion ®ion) +{ + Q_UNUSED(region); + // XXX +} + +void QWidgetPrivate::updateFrameStrut() +{ + // XXX +} + +void QWidgetPrivate::setWindowOpacity_sys(qreal level) +{ + Q_Q(QWidget); + q->platformWindow()->setOpacity(level); +} + +void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect) +{ + Q_UNUSED(dontShow); + Q_UNUSED(oldRect); + // XXX +} + +QPaintEngine *QWidget::paintEngine() const +{ + qWarning("QWidget::paintEngine: Should no longer be called"); + return 0; //##### @@@ +} + +QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys() +{ + Q_Q(QWidget); + return QApplicationPrivate::platformIntegration()->createWindowSurface(q,0); +} + +void QWidgetPrivate::setModal_sys() +{ +} + +#ifndef QT_NO_CURSOR +void qt_lite_set_cursor(QWidget * w, bool force) +{ + static QCursor arrowCursor(Qt::ArrowCursor); + static QPointer lastUnderMouse = 0; + + QCursor * override = QApplication::overrideCursor(); + + if (override && w != 0) + return; + + QWidget *cursorWidget; + QCursor cursorCursor; + + do { + if (w == 0) { + if (override) { + cursorCursor = *override; + cursorWidget = QApplication::topLevelAt(QCursor::pos()); + break; + } + w = QApplication::widgetAt(QCursor::pos()); + if (w == 0) // clear the override cursor while over empty space + w = QApplication::desktop(); + } else if (force) { + lastUnderMouse = w; + } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse + && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) { + w = lastUnderMouse; + } + if (w == QApplication::desktop() && !override) { + cursorCursor = arrowCursor; + cursorWidget = w; + break; + } + + QWidget * curWin = QApplication::activeWindow(); + if (!curWin && w && w->internalWinId()) + return; + QWidget* cW = w && !w->internalWinId() ? w : curWin; + + if (!cW || cW->window() != w->window() || + !cW->isVisible() || !cW->underMouse() || override) + return; + + cursorCursor = w->cursor(); + cursorWidget = w; + } while (0); + foreach (QWeakPointer cursor, QGraphicsSystemCursorPrivate::getInstances()) + if (cursor) + cursor.data()->changeCursor(&cursorCursor, cursorWidget); +} +#endif //QT_NO_CURSOR + +QT_END_NAMESPACE diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 46be728..07017ec 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -189,11 +189,11 @@ embedded { embedded_lite { SOURCES += \ - painting/qcolormap_lite.cpp \ - painting/qpaintdevice_lite.cpp \ - painting/qgraphicssystemcursor_lite.cpp + painting/qcolormap_qpa.cpp \ + painting/qpaintdevice_qpa.cpp \ + painting/qgraphicssystemcursor_qpa.cpp HEADERS += \ - painting/qgraphicssystemcursor_lite.h + painting/qgraphicssystemcursor_qpa.h } symbian { diff --git a/src/gui/painting/qcolormap_lite.cpp b/src/gui/painting/qcolormap_lite.cpp deleted file mode 100644 index 1f4fea8..0000000 --- a/src/gui/painting/qcolormap_lite.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 "qcolormap.h" -#include "qcolor.h" -#include "qpaintdevice.h" -#include "private/qapplication_p.h" -#include "private/qgraphicssystem_p.h" - -QT_BEGIN_NAMESPACE - -class QColormapPrivate -{ -public: - inline QColormapPrivate() - : ref(1), mode(QColormap::Direct), depth(0), numcolors(0) - { } - - QAtomicInt ref; - - QColormap::Mode mode; - int depth; - int numcolors; -}; - -static QColormapPrivate *screenMap = 0; - -void QColormap::initialize() -{ - screenMap = new QColormapPrivate; - - QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); - QList screens = pi->screens(); - - screenMap->depth = screens[0]->depth(); - if (screenMap->depth < 8) { - screenMap->mode = QColormap::Indexed; - screenMap->numcolors = 256; - } else { - screenMap->mode = QColormap::Direct; - screenMap->numcolors = -1; - } -} - -void QColormap::cleanup() -{ - delete screenMap; - screenMap = 0; -} - -QColormap QColormap::instance(int /*screen*/) -{ - return QColormap(); -} - -QColormap::QColormap() - : d(screenMap) -{ d->ref.ref(); } - -QColormap::QColormap(const QColormap &colormap) - :d (colormap.d) -{ d->ref.ref(); } - -QColormap::~QColormap() -{ - if (!d->ref.deref()) - delete d; -} - -QColormap::Mode QColormap::mode() const -{ return d->mode; } - - -int QColormap::depth() const -{ return d->depth; } - - -int QColormap::size() const -{ - return d->numcolors; -} - -#ifndef QT_QWS_DEPTH16_RGB -#define QT_QWS_DEPTH16_RGB 565 -#endif -static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100); -static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10); -static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10); -static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits); -static const int qt_green_shift = qt_bbits-(8-qt_gbits); -static const int qt_neg_blue_shift = 8-qt_bbits; -static const int qt_blue_mask = (1<> qt_neg_blue_shift; - - return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask); -} - -inline QRgb qt_conv16ToRgb(ushort c) -{ - const int r=(c & qt_red_mask); - const int g=(c & qt_green_mask); - const int b=(c & qt_blue_mask); - const int tr = r >> qt_red_shift | r >> qt_red_rounding_shift; - const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift; - const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift; - - return qRgb(tr,tg,tb); -} - -uint QColormap::pixel(const QColor &color) const -{ - QRgb rgb = color.rgba(); - if (d->mode == QColormap::Direct) { - switch(d->depth) { - case 16: - return qt_convRgbTo16(rgb); - case 24: - case 32: - { - const int r = qRed(rgb); - const int g = qGreen(rgb); - const int b = qBlue(rgb); - const int red_shift = 16; - const int green_shift = 8; - const int red_mask = 0xff0000; - const int green_mask = 0x00ff00; - const int blue_mask = 0x0000ff; - const int tg = g << green_shift; -#ifdef QT_QWS_DEPTH_32_BGR - if (qt_screen->pixelType() == QScreen::BGRPixel) { - const int tb = b << red_shift; - return 0xff000000 | (r & blue_mask) | (tg & green_mask) | (tb & red_mask); - } -#endif - const int tr = r << red_shift; - return 0xff000000 | (b & blue_mask) | (tg & green_mask) | (tr & red_mask); - } - } - } - //XXX - //return qt_screen->alloc(qRed(rgb), qGreen(rgb), qBlue(rgb)); - return 0; -} - -const QColor QColormap::colorAt(uint pixel) const -{ - if (d->mode == Direct) { - if (d->depth == 16) { - pixel = qt_conv16ToRgb(pixel); - } - const int red_shift = 16; - const int green_shift = 8; - const int red_mask = 0xff0000; - const int green_mask = 0x00ff00; - const int blue_mask = 0x0000ff; -#ifdef QT_QWS_DEPTH_32_BGR - if (qt_screen->pixelType() == QScreen::BGRPixel) { - return QColor((pixel & blue_mask), - (pixel & green_mask) >> green_shift, - (pixel & red_mask) >> red_shift); - } -#endif - return QColor((pixel & red_mask) >> red_shift, - (pixel & green_mask) >> green_shift, - (pixel & blue_mask)); - } -#if 0 // XXX - Q_ASSERT_X(int(pixel) < qt_screen->numCols(), "QColormap::colorAt", "pixel out of bounds of palette"); - return QColor(qt_screen->clut()[pixel]); -#endif - return QColor(); -} - -const QVector QColormap::colormap() const -{ - return QVector(); -} - -QColormap &QColormap::operator=(const QColormap &colormap) -{ qAtomicAssign(d, colormap.d); return *this; } - -QT_END_NAMESPACE diff --git a/src/gui/painting/qcolormap_qpa.cpp b/src/gui/painting/qcolormap_qpa.cpp new file mode 100644 index 0000000..1f4fea8 --- /dev/null +++ b/src/gui/painting/qcolormap_qpa.cpp @@ -0,0 +1,231 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "qcolormap.h" +#include "qcolor.h" +#include "qpaintdevice.h" +#include "private/qapplication_p.h" +#include "private/qgraphicssystem_p.h" + +QT_BEGIN_NAMESPACE + +class QColormapPrivate +{ +public: + inline QColormapPrivate() + : ref(1), mode(QColormap::Direct), depth(0), numcolors(0) + { } + + QAtomicInt ref; + + QColormap::Mode mode; + int depth; + int numcolors; +}; + +static QColormapPrivate *screenMap = 0; + +void QColormap::initialize() +{ + screenMap = new QColormapPrivate; + + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList screens = pi->screens(); + + screenMap->depth = screens[0]->depth(); + if (screenMap->depth < 8) { + screenMap->mode = QColormap::Indexed; + screenMap->numcolors = 256; + } else { + screenMap->mode = QColormap::Direct; + screenMap->numcolors = -1; + } +} + +void QColormap::cleanup() +{ + delete screenMap; + screenMap = 0; +} + +QColormap QColormap::instance(int /*screen*/) +{ + return QColormap(); +} + +QColormap::QColormap() + : d(screenMap) +{ d->ref.ref(); } + +QColormap::QColormap(const QColormap &colormap) + :d (colormap.d) +{ d->ref.ref(); } + +QColormap::~QColormap() +{ + if (!d->ref.deref()) + delete d; +} + +QColormap::Mode QColormap::mode() const +{ return d->mode; } + + +int QColormap::depth() const +{ return d->depth; } + + +int QColormap::size() const +{ + return d->numcolors; +} + +#ifndef QT_QWS_DEPTH16_RGB +#define QT_QWS_DEPTH16_RGB 565 +#endif +static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100); +static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10); +static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10); +static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits); +static const int qt_green_shift = qt_bbits-(8-qt_gbits); +static const int qt_neg_blue_shift = 8-qt_bbits; +static const int qt_blue_mask = (1<> qt_neg_blue_shift; + + return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask); +} + +inline QRgb qt_conv16ToRgb(ushort c) +{ + const int r=(c & qt_red_mask); + const int g=(c & qt_green_mask); + const int b=(c & qt_blue_mask); + const int tr = r >> qt_red_shift | r >> qt_red_rounding_shift; + const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift; + const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift; + + return qRgb(tr,tg,tb); +} + +uint QColormap::pixel(const QColor &color) const +{ + QRgb rgb = color.rgba(); + if (d->mode == QColormap::Direct) { + switch(d->depth) { + case 16: + return qt_convRgbTo16(rgb); + case 24: + case 32: + { + const int r = qRed(rgb); + const int g = qGreen(rgb); + const int b = qBlue(rgb); + const int red_shift = 16; + const int green_shift = 8; + const int red_mask = 0xff0000; + const int green_mask = 0x00ff00; + const int blue_mask = 0x0000ff; + const int tg = g << green_shift; +#ifdef QT_QWS_DEPTH_32_BGR + if (qt_screen->pixelType() == QScreen::BGRPixel) { + const int tb = b << red_shift; + return 0xff000000 | (r & blue_mask) | (tg & green_mask) | (tb & red_mask); + } +#endif + const int tr = r << red_shift; + return 0xff000000 | (b & blue_mask) | (tg & green_mask) | (tr & red_mask); + } + } + } + //XXX + //return qt_screen->alloc(qRed(rgb), qGreen(rgb), qBlue(rgb)); + return 0; +} + +const QColor QColormap::colorAt(uint pixel) const +{ + if (d->mode == Direct) { + if (d->depth == 16) { + pixel = qt_conv16ToRgb(pixel); + } + const int red_shift = 16; + const int green_shift = 8; + const int red_mask = 0xff0000; + const int green_mask = 0x00ff00; + const int blue_mask = 0x0000ff; +#ifdef QT_QWS_DEPTH_32_BGR + if (qt_screen->pixelType() == QScreen::BGRPixel) { + return QColor((pixel & blue_mask), + (pixel & green_mask) >> green_shift, + (pixel & red_mask) >> red_shift); + } +#endif + return QColor((pixel & red_mask) >> red_shift, + (pixel & green_mask) >> green_shift, + (pixel & blue_mask)); + } +#if 0 // XXX + Q_ASSERT_X(int(pixel) < qt_screen->numCols(), "QColormap::colorAt", "pixel out of bounds of palette"); + return QColor(qt_screen->clut()[pixel]); +#endif + return QColor(); +} + +const QVector QColormap::colormap() const +{ + return QVector(); +} + +QColormap &QColormap::operator=(const QColormap &colormap) +{ qAtomicAssign(d, colormap.d); return *this; } + +QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystemcursor_lite.cpp b/src/gui/painting/qgraphicssystemcursor_lite.cpp deleted file mode 100644 index 752b406..0000000 --- a/src/gui/painting/qgraphicssystemcursor_lite.cpp +++ /dev/null @@ -1,664 +0,0 @@ -/**************************************************************************** -** -** 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 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 "qgraphicssystemcursor_lite.h" - -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -QList > QGraphicsSystemCursorPrivate::instances; - -/*! - \class QGraphicsSystemCursor - - \brief The QGraphicsSystemCursor class provides information about - pointer device events (movement, buttons), and requests to change - the currently displayed cursor. - - Note that QGraphicsSystemCursor does not include any graphics for - display. An application that sets a QCursor may provide its own - graphics. - - \sa QGraphicsSystemCursorImage -*/ - -/*! - \fn virtual void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & event) - - This method is called by Qt whenever a QMouseEvent is generated by the - underlying pointer input. \a event is a reference to the QMouseEvent in - question. A default do-nothing implementation is provided. - - \sa QApplicationPrivate::handleMouseEvent() -*/ - -/*! - \fn virtual void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) - - \brief This method is called by Qt whenever the cursor graphic should be changed. - - Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor. - - \a widgetCursor is a pointer to the QCursor that should be displayed. - - \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note - that this may be 0 if the current position is not occupied by a displayed widget. - - \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos() -*/ - -/*! - \fn QGraphicsSystemCursor::QGraphicsSystemCursor() - - \brief Constructs a QGraphicsSystemCursor -*/ -QGraphicsSystemCursor::QGraphicsSystemCursor(QPlatformScreen *scr ) - : screen(scr) -{ - QGraphicsSystemCursorPrivate::instances.append(this); -} - -// End of display and pointer event handling code -// Beginning of built-in cursor graphics -// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp - -/*! - \class QGraphicsSystemCursorImage - - \brief The QGraphicsSystemCursorImage class provides a set of graphics - intended to be used as cursors. - - \sa QGraphicsSystemCursor -*/ - -static QGraphicsSystemCursorImage *systemCursorTable[Qt::LastCursor+1]; -static bool systemCursorTableInit = false; - -// 16 x 16 -static const uchar cur_arrow_bits[] = { - 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08, - 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22, - 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 }; -static const uchar mcur_arrow_bits[] = { - 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f, - 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e, - 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 }; - -static const unsigned char cur_up_arrow_bits[] = { - 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, - 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01}; -static const unsigned char mcur_up_arrow_bits[] = { - 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07, - 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01}; - -static const unsigned char cur_cross_bits[] = { - 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00}; -static const unsigned char mcur_cross_bits[] = { - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; - -static const uchar cur_ibeam_bits[] = { - 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, - 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, - 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_ibeam_bits[] = { - 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 }; - -static const uchar cur_ver_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, - 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, - 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; -static const uchar mcur_ver_bits[] = { - 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, - 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, - 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; - -static const uchar cur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, - 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, - 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, - 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; -static const uchar cur_bdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, - 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, - 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_bdiag_bits[] = { - 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, - 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, - 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; -static const uchar cur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, - 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, - 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, - 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, - 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; -static const uchar cur_blank_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -// 20 x 20 -static const uchar forbidden_bits[] = { - 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, - 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, - 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, - 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; - -static const uchar forbiddenm_bits[] = { - 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, - 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, - 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, - 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; - -// 32 x 32 -static const uchar wait_data_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00, - 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, - 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00, - 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, - 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00, - 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar wait_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, - 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00, - 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar hsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, - 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar hsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, - 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, - 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, - 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar vsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar vsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar phand_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, - 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00, - 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, - 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar phandm_bits[] = { - 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, - 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, - 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, - 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, - 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar size_all_data_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00, - 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar size_all_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00, - 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01, - 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00, - 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar whatsthis_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, - 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, - 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, - 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, - 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, - 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -static const uchar whatsthism_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, - 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, - 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, - 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, - 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, - 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - -static const uchar busy_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, - 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, - 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, - 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, - 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static const uchar busym_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, - 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, - 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, - 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, - 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, - 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -// 16 x 16 -static const uchar openhand_bits[] = { - 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, - 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, - 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; -static const uchar openhandm_bits[] = { - 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, - 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, - 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; -static const uchar closedhand_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, - 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, - 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; -static const uchar closedhandm_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, - 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, - 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; - -void QGraphicsSystemCursorImage::createSystemCursor(int id) -{ - if (!systemCursorTableInit) { - for (int i = 0; i <= Qt::LastCursor; i++) - systemCursorTable[i] = 0; - systemCursorTableInit = true; - } - switch (id) { - // 16x16 cursors - case Qt::ArrowCursor: - systemCursorTable[Qt::ArrowCursor] = - new QGraphicsSystemCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0); - break; - - case Qt::UpArrowCursor: - systemCursorTable[Qt::UpArrowCursor] = - new QGraphicsSystemCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0); - break; - - case Qt::CrossCursor: - systemCursorTable[Qt::CrossCursor] = - new QGraphicsSystemCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7); - break; - - case Qt::IBeamCursor: - systemCursorTable[Qt::IBeamCursor] = - new QGraphicsSystemCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7); - break; - - case Qt::SizeVerCursor: - systemCursorTable[Qt::SizeVerCursor] = - new QGraphicsSystemCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7); - break; - - case Qt::SizeHorCursor: - systemCursorTable[Qt::SizeHorCursor] = - new QGraphicsSystemCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7); - break; - - case Qt::SizeBDiagCursor: - systemCursorTable[Qt::SizeBDiagCursor] = - new QGraphicsSystemCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7); - break; - - case Qt::SizeFDiagCursor: - systemCursorTable[Qt::SizeFDiagCursor] = - new QGraphicsSystemCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7); - break; - - case Qt::BlankCursor: - systemCursorTable[Qt::BlankCursor] = - new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); - break; - - // 20x20 cursors - case Qt::ForbiddenCursor: - systemCursorTable[Qt::ForbiddenCursor] = - new QGraphicsSystemCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10); - break; - - // 32x32 cursors - case Qt::WaitCursor: - systemCursorTable[Qt::WaitCursor] = - new QGraphicsSystemCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15); - break; - - case Qt::SplitVCursor: - systemCursorTable[Qt::SplitVCursor] = - new QGraphicsSystemCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15); - break; - - case Qt::SplitHCursor: - systemCursorTable[Qt::SplitHCursor] = - new QGraphicsSystemCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15); - break; - - case Qt::SizeAllCursor: - systemCursorTable[Qt::SizeAllCursor] = - new QGraphicsSystemCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15); - break; - - case Qt::PointingHandCursor: - systemCursorTable[Qt::PointingHandCursor] = - new QGraphicsSystemCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0); - break; - - case Qt::WhatsThisCursor: - systemCursorTable[Qt::WhatsThisCursor] = - new QGraphicsSystemCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0); - break; - case Qt::BusyCursor: - systemCursorTable[Qt::BusyCursor] = - new QGraphicsSystemCursorImage(busy_bits, busym_bits, 32, 32, 0, 0); - break; - - case Qt::OpenHandCursor: - systemCursorTable[Qt::OpenHandCursor] = - new QGraphicsSystemCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8); - break; - case Qt::ClosedHandCursor: - systemCursorTable[Qt::ClosedHandCursor] = - new QGraphicsSystemCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8); - break; - default: - qWarning("Unknown system cursor %d", id); - } -} - -/*! - \fn void QGraphicsSystemCursorImage::set(Qt::CursorShape id) - - \brief Calling this method sets the cursor image to the specified shape - - \a id is one of the defined Qt::CursorShape values. - - If id is invalid, Qt::BitmapCursor, or unknown by the implementation, - Qt::ArrowCursor is used instead. -*/ - -void QGraphicsSystemCursorImage::set(Qt::CursorShape id) -{ - QGraphicsSystemCursorImage *cursor = 0; - if (id >= 0 && id <= Qt::LastCursor) { - if (!systemCursorTable[id]) - createSystemCursor(id); - cursor = systemCursorTable[id]; - } - - if (cursor == 0) { - if (!systemCursorTable[Qt::ArrowCursor]) - createSystemCursor(Qt::ArrowCursor); - cursor = systemCursorTable[Qt::ArrowCursor]; - } - cursorImage = cursor->cursorImage; - hot = cursor->hot; -} - -/*! - \fn void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) - - \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy) - - \a image A pointer to a QImage - - \a hx The x coordinate of the cursor's hotspot - - \a hy the y coordinate of the cursor's hotspot -*/ - -void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) -{ - hot.setX(hx); - hot.setY(hy); - cursorImage = *image; -} - -/*! - \fn void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) - - \brief set the cursor image to the graphic represented by the combination of data, mask, - width, and height - - \a data The pixel data of the graphic - - \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn - - \a width The width of the graphic in pixels - - \a height The height of the graphic in pixels - - \a hx The X hotspot of the cursor graphic - - \a hy The Y hotspot of the cursor graphic -*/ -void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, - int width, int height, int hx, int hy) -{ - hot.setX(hx); - hot.setY(hy); - - cursorImage = QImage(width,height, QImage::Format_Indexed8); - - if (!width || !height || !data || !mask || cursorImage.isNull()) - return; - - cursorImage.setNumColors(3); - cursorImage.setColor(0, 0xff000000); - cursorImage.setColor(1, 0xffffffff); - cursorImage.setColor(2, 0x00000000); - - int bytesPerLine = (width + 7) / 8; - int p = 0; - int d, m; - - int x = -1, w = 0; - - uchar *cursor_data = cursorImage.bits(); - int bpl = cursorImage.bytesPerLine(); - for (int i = 0; i < height; i++) - { - for (int j = 0; j < bytesPerLine; j++, data++, mask++) - { - for (int b = 0; b < 8 && j*8+b < width; b++) - { - d = *data & (1 << b); - m = *mask & (1 << b); - if (d && m) p = 0; - else if (!d && m) p = 1; - else p = 2; - cursor_data[j*8+b] = p; - - // calc region - if (x < 0 && m) - x = j*8+b; - else if (x >= 0 && !m) { - x = -1; - w = 0; - } - if (m) - w++; - } - } - if (x >= 0) { - x = -1; - w = 0; - } - cursor_data += bpl; - } - -} - -/*! - \fn QGraphicsSystemCursorImage::QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) - - \brief set the cursor image to the graphic represented by the combination of data, mask, - width, and height - - \a data The pixel data of the graphic - - \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn - - \a width The width of the graphic in pixels - - \a height The height of the graphic in pixels - - \a hotX The X hotspot of the cursor graphic - - \a hotY The Y hotspot of the cursor graphic - - \sa set -*/ - -/*! - \fn QImage *QGraphicsSystemCursorImage::image() - - \brief Return the cursor graphic as a pointer to a QImage -*/ - -/*! - \fn QPoint QGraphicsSystemCursorImage::hotspot() - - \brief Return the cursor's hotspot -*/ - -QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystemcursor_lite.h b/src/gui/painting/qgraphicssystemcursor_lite.h deleted file mode 100644 index 9c65f7f..0000000 --- a/src/gui/painting/qgraphicssystemcursor_lite.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QGRAPHICSSYSTEMCURSOR_H -#define QGRAPHICSSYSTEMCURSOR_H - -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -// Cursor graphics management -class Q_GUI_EXPORT QGraphicsSystemCursorImage { -public: - QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) - { set(data, mask, width, height, hotX, hotY); } - QImage * image() { return &cursorImage; } - QPoint hotspot() { return hot; } - void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); - void set(const QImage * image, int hx, int hy); - void set(Qt::CursorShape); -private: - static void createSystemCursor(int id); - QImage cursorImage; - QPoint hot; -}; - -class QGraphicsSystemCursor; - -class QGraphicsSystemCursorPrivate { -public: - static QList > getInstances() { return instances; } - static QList > instances; -}; - -class Q_GUI_EXPORT QGraphicsSystemCursor : public QObject { -public: - QGraphicsSystemCursor(QPlatformScreen *); - - // input methods - virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } - virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0; - -protected: - QPlatformScreen* screen; // Where to request an update - -private: - Q_DECLARE_PRIVATE(QGraphicsSystemCursor); - friend void qt_lite_set_cursor(QWidget * w, bool force); - friend class QApplicationPrivate; -}; - -QT_END_NAMESPACE - -#endif // QGRAPHICSSYSTEMCURSOR_H diff --git a/src/gui/painting/qgraphicssystemcursor_qpa.cpp b/src/gui/painting/qgraphicssystemcursor_qpa.cpp new file mode 100644 index 0000000..24376f9 --- /dev/null +++ b/src/gui/painting/qgraphicssystemcursor_qpa.cpp @@ -0,0 +1,664 @@ +/**************************************************************************** +** +** 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 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 "qgraphicssystemcursor_qpa.h" + +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +QList > QGraphicsSystemCursorPrivate::instances; + +/*! + \class QGraphicsSystemCursor + + \brief The QGraphicsSystemCursor class provides information about + pointer device events (movement, buttons), and requests to change + the currently displayed cursor. + + Note that QGraphicsSystemCursor does not include any graphics for + display. An application that sets a QCursor may provide its own + graphics. + + \sa QGraphicsSystemCursorImage +*/ + +/*! + \fn virtual void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & event) + + This method is called by Qt whenever a QMouseEvent is generated by the + underlying pointer input. \a event is a reference to the QMouseEvent in + question. A default do-nothing implementation is provided. + + \sa QApplicationPrivate::handleMouseEvent() +*/ + +/*! + \fn virtual void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) + + \brief This method is called by Qt whenever the cursor graphic should be changed. + + Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor. + + \a widgetCursor is a pointer to the QCursor that should be displayed. + + \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note + that this may be 0 if the current position is not occupied by a displayed widget. + + \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos() +*/ + +/*! + \fn QGraphicsSystemCursor::QGraphicsSystemCursor() + + \brief Constructs a QGraphicsSystemCursor +*/ +QGraphicsSystemCursor::QGraphicsSystemCursor(QPlatformScreen *scr ) + : screen(scr) +{ + QGraphicsSystemCursorPrivate::instances.append(this); +} + +// End of display and pointer event handling code +// Beginning of built-in cursor graphics +// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp + +/*! + \class QGraphicsSystemCursorImage + + \brief The QGraphicsSystemCursorImage class provides a set of graphics + intended to be used as cursors. + + \sa QGraphicsSystemCursor +*/ + +static QGraphicsSystemCursorImage *systemCursorTable[Qt::LastCursor+1]; +static bool systemCursorTableInit = false; + +// 16 x 16 +static const uchar cur_arrow_bits[] = { + 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08, + 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22, + 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 }; +static const uchar mcur_arrow_bits[] = { + 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f, + 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e, + 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 }; + +static const unsigned char cur_up_arrow_bits[] = { + 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, + 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01}; +static const unsigned char mcur_up_arrow_bits[] = { + 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07, + 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01}; + +static const unsigned char cur_cross_bits[] = { + 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00}; +static const unsigned char mcur_cross_bits[] = { + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; + +static const uchar cur_ibeam_bits[] = { + 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, + 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, + 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_ibeam_bits[] = { + 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 }; + +static const uchar cur_ver_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, + 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, + 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; +static const uchar mcur_ver_bits[] = { + 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, + 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, + 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; + +static const uchar cur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, + 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, + 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, + 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; +static const uchar cur_bdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, + 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, + 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_bdiag_bits[] = { + 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, + 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, + 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; +static const uchar cur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, + 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, + 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, + 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, + 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; +static const uchar cur_blank_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +// 20 x 20 +static const uchar forbidden_bits[] = { + 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, + 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, + 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, + 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; + +static const uchar forbiddenm_bits[] = { + 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, + 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, + 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, + 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; + +// 32 x 32 +static const uchar wait_data_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00, + 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, + 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00, + 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, + 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00, + 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar wait_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, + 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00, + 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar hsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, + 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar hsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, + 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, + 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, + 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar vsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar vsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar phand_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, + 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00, + 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, + 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar phandm_bits[] = { + 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, + 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, + 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, + 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, + 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar size_all_data_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00, + 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar size_all_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00, + 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01, + 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00, + 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar whatsthis_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, + 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, + 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, + 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, + 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, + 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; +static const uchar whatsthism_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, + 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, + 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, + 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, + 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, + 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + +static const uchar busy_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, + 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, + 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, + 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, + 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static const uchar busym_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, + 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, + 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, + 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, + 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +// 16 x 16 +static const uchar openhand_bits[] = { + 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, + 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, + 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; +static const uchar openhandm_bits[] = { + 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, + 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, + 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; +static const uchar closedhand_bits[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, + 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, + 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; +static const uchar closedhandm_bits[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, + 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, + 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; + +void QGraphicsSystemCursorImage::createSystemCursor(int id) +{ + if (!systemCursorTableInit) { + for (int i = 0; i <= Qt::LastCursor; i++) + systemCursorTable[i] = 0; + systemCursorTableInit = true; + } + switch (id) { + // 16x16 cursors + case Qt::ArrowCursor: + systemCursorTable[Qt::ArrowCursor] = + new QGraphicsSystemCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0); + break; + + case Qt::UpArrowCursor: + systemCursorTable[Qt::UpArrowCursor] = + new QGraphicsSystemCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0); + break; + + case Qt::CrossCursor: + systemCursorTable[Qt::CrossCursor] = + new QGraphicsSystemCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7); + break; + + case Qt::IBeamCursor: + systemCursorTable[Qt::IBeamCursor] = + new QGraphicsSystemCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7); + break; + + case Qt::SizeVerCursor: + systemCursorTable[Qt::SizeVerCursor] = + new QGraphicsSystemCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7); + break; + + case Qt::SizeHorCursor: + systemCursorTable[Qt::SizeHorCursor] = + new QGraphicsSystemCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7); + break; + + case Qt::SizeBDiagCursor: + systemCursorTable[Qt::SizeBDiagCursor] = + new QGraphicsSystemCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7); + break; + + case Qt::SizeFDiagCursor: + systemCursorTable[Qt::SizeFDiagCursor] = + new QGraphicsSystemCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7); + break; + + case Qt::BlankCursor: + systemCursorTable[Qt::BlankCursor] = + new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); + break; + + // 20x20 cursors + case Qt::ForbiddenCursor: + systemCursorTable[Qt::ForbiddenCursor] = + new QGraphicsSystemCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10); + break; + + // 32x32 cursors + case Qt::WaitCursor: + systemCursorTable[Qt::WaitCursor] = + new QGraphicsSystemCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15); + break; + + case Qt::SplitVCursor: + systemCursorTable[Qt::SplitVCursor] = + new QGraphicsSystemCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15); + break; + + case Qt::SplitHCursor: + systemCursorTable[Qt::SplitHCursor] = + new QGraphicsSystemCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15); + break; + + case Qt::SizeAllCursor: + systemCursorTable[Qt::SizeAllCursor] = + new QGraphicsSystemCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15); + break; + + case Qt::PointingHandCursor: + systemCursorTable[Qt::PointingHandCursor] = + new QGraphicsSystemCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0); + break; + + case Qt::WhatsThisCursor: + systemCursorTable[Qt::WhatsThisCursor] = + new QGraphicsSystemCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0); + break; + case Qt::BusyCursor: + systemCursorTable[Qt::BusyCursor] = + new QGraphicsSystemCursorImage(busy_bits, busym_bits, 32, 32, 0, 0); + break; + + case Qt::OpenHandCursor: + systemCursorTable[Qt::OpenHandCursor] = + new QGraphicsSystemCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8); + break; + case Qt::ClosedHandCursor: + systemCursorTable[Qt::ClosedHandCursor] = + new QGraphicsSystemCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8); + break; + default: + qWarning("Unknown system cursor %d", id); + } +} + +/*! + \fn void QGraphicsSystemCursorImage::set(Qt::CursorShape id) + + \brief Calling this method sets the cursor image to the specified shape + + \a id is one of the defined Qt::CursorShape values. + + If id is invalid, Qt::BitmapCursor, or unknown by the implementation, + Qt::ArrowCursor is used instead. +*/ + +void QGraphicsSystemCursorImage::set(Qt::CursorShape id) +{ + QGraphicsSystemCursorImage *cursor = 0; + if (id >= 0 && id <= Qt::LastCursor) { + if (!systemCursorTable[id]) + createSystemCursor(id); + cursor = systemCursorTable[id]; + } + + if (cursor == 0) { + if (!systemCursorTable[Qt::ArrowCursor]) + createSystemCursor(Qt::ArrowCursor); + cursor = systemCursorTable[Qt::ArrowCursor]; + } + cursorImage = cursor->cursorImage; + hot = cursor->hot; +} + +/*! + \fn void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) + + \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy) + + \a image A pointer to a QImage + + \a hx The x coordinate of the cursor's hotspot + + \a hy the y coordinate of the cursor's hotspot +*/ + +void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) +{ + hot.setX(hx); + hot.setY(hy); + cursorImage = *image; +} + +/*! + \fn void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) + + \brief set the cursor image to the graphic represented by the combination of data, mask, + width, and height + + \a data The pixel data of the graphic + + \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn + + \a width The width of the graphic in pixels + + \a height The height of the graphic in pixels + + \a hx The X hotspot of the cursor graphic + + \a hy The Y hotspot of the cursor graphic +*/ +void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, + int width, int height, int hx, int hy) +{ + hot.setX(hx); + hot.setY(hy); + + cursorImage = QImage(width,height, QImage::Format_Indexed8); + + if (!width || !height || !data || !mask || cursorImage.isNull()) + return; + + cursorImage.setNumColors(3); + cursorImage.setColor(0, 0xff000000); + cursorImage.setColor(1, 0xffffffff); + cursorImage.setColor(2, 0x00000000); + + int bytesPerLine = (width + 7) / 8; + int p = 0; + int d, m; + + int x = -1, w = 0; + + uchar *cursor_data = cursorImage.bits(); + int bpl = cursorImage.bytesPerLine(); + for (int i = 0; i < height; i++) + { + for (int j = 0; j < bytesPerLine; j++, data++, mask++) + { + for (int b = 0; b < 8 && j*8+b < width; b++) + { + d = *data & (1 << b); + m = *mask & (1 << b); + if (d && m) p = 0; + else if (!d && m) p = 1; + else p = 2; + cursor_data[j*8+b] = p; + + // calc region + if (x < 0 && m) + x = j*8+b; + else if (x >= 0 && !m) { + x = -1; + w = 0; + } + if (m) + w++; + } + } + if (x >= 0) { + x = -1; + w = 0; + } + cursor_data += bpl; + } + +} + +/*! + \fn QGraphicsSystemCursorImage::QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + + \brief set the cursor image to the graphic represented by the combination of data, mask, + width, and height + + \a data The pixel data of the graphic + + \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn + + \a width The width of the graphic in pixels + + \a height The height of the graphic in pixels + + \a hotX The X hotspot of the cursor graphic + + \a hotY The Y hotspot of the cursor graphic + + \sa set +*/ + +/*! + \fn QImage *QGraphicsSystemCursorImage::image() + + \brief Return the cursor graphic as a pointer to a QImage +*/ + +/*! + \fn QPoint QGraphicsSystemCursorImage::hotspot() + + \brief Return the cursor's hotspot +*/ + +QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystemcursor_qpa.h b/src/gui/painting/qgraphicssystemcursor_qpa.h new file mode 100644 index 0000000..9c65f7f --- /dev/null +++ b/src/gui/painting/qgraphicssystemcursor_qpa.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QGRAPHICSSYSTEMCURSOR_H +#define QGRAPHICSSYSTEMCURSOR_H + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +// Cursor graphics management +class Q_GUI_EXPORT QGraphicsSystemCursorImage { +public: + QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + { set(data, mask, width, height, hotX, hotY); } + QImage * image() { return &cursorImage; } + QPoint hotspot() { return hot; } + void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + void set(const QImage * image, int hx, int hy); + void set(Qt::CursorShape); +private: + static void createSystemCursor(int id); + QImage cursorImage; + QPoint hot; +}; + +class QGraphicsSystemCursor; + +class QGraphicsSystemCursorPrivate { +public: + static QList > getInstances() { return instances; } + static QList > instances; +}; + +class Q_GUI_EXPORT QGraphicsSystemCursor : public QObject { +public: + QGraphicsSystemCursor(QPlatformScreen *); + + // input methods + virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } + virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0; + +protected: + QPlatformScreen* screen; // Where to request an update + +private: + Q_DECLARE_PRIVATE(QGraphicsSystemCursor); + friend void qt_lite_set_cursor(QWidget * w, bool force); + friend class QApplicationPrivate; +}; + +QT_END_NAMESPACE + +#endif // QGRAPHICSSYSTEMCURSOR_H diff --git a/src/gui/painting/qpaintdevice_lite.cpp b/src/gui/painting/qpaintdevice_lite.cpp deleted file mode 100644 index 0d1ca92..0000000 --- a/src/gui/painting/qpaintdevice_lite.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 "qpaintdevice.h" -#include "qpainter.h" -#include "qwidget.h" -#include "qbitmap.h" -#include "qapplication.h" - -QT_BEGIN_NAMESPACE - -extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp - -int QPaintDevice::metric(PaintDeviceMetric m) const -{ - qWarning("QPaintDevice::metrics: Device has no metric information"); - if (m == PdmDpiX) { - return 72; - } else if (m == PdmDpiY) { - return 72; - } else if (m == PdmNumColors) { - // FIXME: does this need to be a real value? - return 256; - } else { - qDebug("Unrecognised metric %d!",m); - return 0; - } -} - -QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintdevice_qpa.cpp b/src/gui/painting/qpaintdevice_qpa.cpp new file mode 100644 index 0000000..0d1ca92 --- /dev/null +++ b/src/gui/painting/qpaintdevice_qpa.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "qpaintdevice.h" +#include "qpainter.h" +#include "qwidget.h" +#include "qbitmap.h" +#include "qapplication.h" + +QT_BEGIN_NAMESPACE + +extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp + +int QPaintDevice::metric(PaintDeviceMetric m) const +{ + qWarning("QPaintDevice::metrics: Device has no metric information"); + if (m == PdmDpiX) { + return 72; + } else if (m == PdmDpiY) { + return 72; + } else if (m == PdmNumColors) { + // FIXME: does this need to be a real value? + return 256; + } else { + qDebug("Unrecognised metric %d!",m); + return 0; + } +} + +QT_END_NAMESPACE diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 3861196..e258a39 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -76,7 +76,7 @@ #include #endif #ifdef Q_WS_QPA -#include +#include #include #endif diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 97c12b3..f196e00 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -80,7 +80,7 @@ SOURCES += qgl.cpp \ embedded_lite { DEFINES += QT_NO_EGL - SOURCES += qgl_lite.cpp \ + SOURCES += qgl_qpa.cpp \ qglpixelbuffer_stub.cpp } diff --git a/src/opengl/qgl_lite.cpp b/src/opengl/qgl_lite.cpp deleted file mode 100644 index 2003cc1..0000000 --- a/src/opengl/qgl_lite.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -** -** 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 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 -#include -#include -#include - -#include -#include - -#include "qgl.h" -#include "qgl_p.h" - -QT_BEGIN_NAMESPACE - - -bool QGLFormat::hasOpenGL() -{ - return QApplicationPrivate::platformIntegration()->hasOpenGL(); -} - -bool QGLContext::chooseContext(const QGLContext* shareContext) -{ - Q_D(QGLContext); - if (!d->paintDevice && d->paintDevice->devType() != QInternal::Widget) { - d->valid = false; - }else { - QWidget *widget = static_cast(d->paintDevice); - if (!widget->platformWindow()){ - widget->winId();//make window - } - d->platformContext = widget->platformWindow()->glContext(); - d->valid =(bool) d->platformContext; - } - - return d->valid; -} - -void QGLContext::reset() -{ - Q_D(QGLContext); - if (!d->valid) - return; - d->cleanup(); - doneCurrent(); - - if (d->platformContext) { - delete d->platformContext; - d->platformContext = 0; - } - - d->crWin = false; - d->sharing = false; - d->valid = false; - d->transpColor = QColor(); - d->initDone = false; - QGLContextGroup::removeShare(this); -} - -void QGLContext::makeCurrent() -{ - Q_D(QGLContext); - d->platformContext->makeCurrent(); - QGLContextPrivate::setCurrentContext(this); -} - -void QGLContext::doneCurrent() -{ - Q_D(QGLContext); - d->platformContext->doneCurrent(); - QGLContextPrivate::setCurrentContext(0); -} - -void QGLContext::swapBuffers() const -{ - Q_D(const QGLContext); - d->platformContext->swapBuffers(); -} - -void *QGLContext::getProcAddress(const QString &procName) const -{ - Q_D(const QGLContext); - return d->platformContext->getProcAddress(procName); -} - -void QGLWidget::setContext(QGLContext *context, - const QGLContext* shareContext, - bool deleteOldContext) -{ - Q_D(QGLWidget); - if (context == 0) { - qWarning("QGLWidget::setContext: Cannot set null context"); - return; - } - if (!context->deviceIsPixmap() && context->device() != this) { - qWarning("QGLWidget::setContext: Context must refer to this widget"); - return; - } - - if (d->glcx) - d->glcx->doneCurrent(); - QGLContext* oldcx = d->glcx; - d->glcx = context; - - if (!d->glcx->isValid()) - d->glcx->create(shareContext ? shareContext : oldcx); - - if (deleteOldContext) - delete oldcx; -} - -void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) -{ - initContext(context, shareWidget); -} - -bool QGLFormat::hasOpenGLOverlays() -{ - return false; -} - -QColor QGLContext::overlayTransparentColor() const -{ - return QColor(); // Invalid color -} - -uint QGLContext::colorIndex(const QColor&) const -{ - return 0; -} - -void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase) -{ - Q_UNUSED(fnt); - Q_UNUSED(listBase); -} - -/* - QGLTemporaryContext implementation -*/ -class QGLTemporaryContextPrivate -{ -public: - QGLWidget *widget; -}; - -QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) - : d(new QGLTemporaryContextPrivate) -{ - d->widget = new QGLWidget; - d->widget->makeCurrent(); -} - -QGLTemporaryContext::~QGLTemporaryContext() -{ - delete d->widget; -} - - -bool QGLWidgetPrivate::renderCxPm(QPixmap*) -{ - return false; -} - -/*! \internal - Free up any allocated colormaps. This fn is only called for - top-level widgets. -*/ -void QGLWidgetPrivate::cleanupColormaps() -{ -} - -void QGLWidget::setMouseTracking(bool enable) -{ - Q_UNUSED(enable); -} - -bool QGLWidget::event(QEvent *e) -{ - return QWidget::event(e); -} - -void QGLWidget::resizeEvent(QResizeEvent *e) -{ - return QWidget::resizeEvent(e); -} - - -const QGLContext* QGLWidget::overlayContext() const -{ - return 0; -} - -void QGLWidget::makeOverlayCurrent() -{ -} - - -void QGLWidget::updateOverlayGL() -{ -} - -const QGLColormap & QGLWidget::colormap() const -{ - Q_D(const QGLWidget); - return d->cmap; -} - -void QGLWidget::setColormap(const QGLColormap & c) -{ - Q_UNUSED(c); -} - -QT_END_NAMESPACE diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp new file mode 100644 index 0000000..2003cc1 --- /dev/null +++ b/src/opengl/qgl_qpa.cpp @@ -0,0 +1,253 @@ +/**************************************************************************** +** +** 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 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 +#include +#include +#include + +#include +#include + +#include "qgl.h" +#include "qgl_p.h" + +QT_BEGIN_NAMESPACE + + +bool QGLFormat::hasOpenGL() +{ + return QApplicationPrivate::platformIntegration()->hasOpenGL(); +} + +bool QGLContext::chooseContext(const QGLContext* shareContext) +{ + Q_D(QGLContext); + if (!d->paintDevice && d->paintDevice->devType() != QInternal::Widget) { + d->valid = false; + }else { + QWidget *widget = static_cast(d->paintDevice); + if (!widget->platformWindow()){ + widget->winId();//make window + } + d->platformContext = widget->platformWindow()->glContext(); + d->valid =(bool) d->platformContext; + } + + return d->valid; +} + +void QGLContext::reset() +{ + Q_D(QGLContext); + if (!d->valid) + return; + d->cleanup(); + doneCurrent(); + + if (d->platformContext) { + delete d->platformContext; + d->platformContext = 0; + } + + d->crWin = false; + d->sharing = false; + d->valid = false; + d->transpColor = QColor(); + d->initDone = false; + QGLContextGroup::removeShare(this); +} + +void QGLContext::makeCurrent() +{ + Q_D(QGLContext); + d->platformContext->makeCurrent(); + QGLContextPrivate::setCurrentContext(this); +} + +void QGLContext::doneCurrent() +{ + Q_D(QGLContext); + d->platformContext->doneCurrent(); + QGLContextPrivate::setCurrentContext(0); +} + +void QGLContext::swapBuffers() const +{ + Q_D(const QGLContext); + d->platformContext->swapBuffers(); +} + +void *QGLContext::getProcAddress(const QString &procName) const +{ + Q_D(const QGLContext); + return d->platformContext->getProcAddress(procName); +} + +void QGLWidget::setContext(QGLContext *context, + const QGLContext* shareContext, + bool deleteOldContext) +{ + Q_D(QGLWidget); + if (context == 0) { + qWarning("QGLWidget::setContext: Cannot set null context"); + return; + } + if (!context->deviceIsPixmap() && context->device() != this) { + qWarning("QGLWidget::setContext: Context must refer to this widget"); + return; + } + + if (d->glcx) + d->glcx->doneCurrent(); + QGLContext* oldcx = d->glcx; + d->glcx = context; + + if (!d->glcx->isValid()) + d->glcx->create(shareContext ? shareContext : oldcx); + + if (deleteOldContext) + delete oldcx; +} + +void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) +{ + initContext(context, shareWidget); +} + +bool QGLFormat::hasOpenGLOverlays() +{ + return false; +} + +QColor QGLContext::overlayTransparentColor() const +{ + return QColor(); // Invalid color +} + +uint QGLContext::colorIndex(const QColor&) const +{ + return 0; +} + +void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase) +{ + Q_UNUSED(fnt); + Q_UNUSED(listBase); +} + +/* + QGLTemporaryContext implementation +*/ +class QGLTemporaryContextPrivate +{ +public: + QGLWidget *widget; +}; + +QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) + : d(new QGLTemporaryContextPrivate) +{ + d->widget = new QGLWidget; + d->widget->makeCurrent(); +} + +QGLTemporaryContext::~QGLTemporaryContext() +{ + delete d->widget; +} + + +bool QGLWidgetPrivate::renderCxPm(QPixmap*) +{ + return false; +} + +/*! \internal + Free up any allocated colormaps. This fn is only called for + top-level widgets. +*/ +void QGLWidgetPrivate::cleanupColormaps() +{ +} + +void QGLWidget::setMouseTracking(bool enable) +{ + Q_UNUSED(enable); +} + +bool QGLWidget::event(QEvent *e) +{ + return QWidget::event(e); +} + +void QGLWidget::resizeEvent(QResizeEvent *e) +{ + return QWidget::resizeEvent(e); +} + + +const QGLContext* QGLWidget::overlayContext() const +{ + return 0; +} + +void QGLWidget::makeOverlayCurrent() +{ +} + + +void QGLWidget::updateOverlayGL() +{ +} + +const QGLColormap & QGLWidget::colormap() const +{ + Q_D(const QGLWidget); + return d->cmap; +} + +void QGLWidget::setColormap(const QGLColormap & c) +{ + Q_UNUSED(c); +} + +QT_END_NAMESPACE -- cgit v0.12 From 9716e12e0f5590ebc23ad9fb7ba75c6a3c5aadab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 24 Jun 2010 11:41:39 +0200 Subject: Adding -qpa configure switch also renaming the embedded_lite qmake switch to be qpa --- configure | 118 ++++++++++++------------ src/3rdparty/webkit/WebCore/WebCore.pro | 2 +- src/corelib/kernel/kernel.pri | 2 +- src/gui/accessible/accessible.pri | 2 +- src/gui/dialogs/dialogs.pri | 4 +- src/gui/egl/egl.pri | 2 +- src/gui/gui.pro | 2 +- src/gui/image/image.pri | 4 +- src/gui/inputmethod/inputmethod.pri | 2 +- src/gui/kernel/kernel.pri | 4 +- src/gui/painting/painting.pri | 14 +-- src/gui/styles/styles.pri | 2 +- src/gui/text/text.pri | 4 +- src/gui/util/util.pri | 4 +- src/gui/widgets/widgets.pri | 2 +- src/opengl/opengl.pro | 4 +- src/plugins/graphicssystems/graphicssystems.pro | 6 +- src/plugins/platforms/platforms.pro | 9 +- src/plugins/plugins.pro | 4 +- src/qt_install.pri | 2 +- tools/tools.pro | 2 +- 21 files changed, 94 insertions(+), 101 deletions(-) diff --git a/configure b/configure index 6143ac1..c33b522 100755 --- a/configure +++ b/configure @@ -187,7 +187,7 @@ fi PLATFORM_X11=no PLATFORM_MAC=no PLATFORM_QWS=maybe -PLATFORM_EMBLITE=maybe +PLATFORM_QPA=maybe BUILD_ON_MAC=no; [ -d /System/Library/Frameworks/Carbon.framework ] && BUILD_ON_MAC=yes @@ -286,8 +286,8 @@ earlyArgParse() VAL=$1 fi ;; - -embedded-lite) - VAR=embedded-lite + -embedded-lite|-qpa) + VAR=qpa # this option may or may not be followed by an argument if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then VAL=auto @@ -338,24 +338,24 @@ earlyArgParse() PLATFORM_X11=no PLATFORM_MAC=no PLATFORM_QWS=yes - PLATFORM_EMBLITE=no + PLATFORM_QPA=no fi else echo "No license exists to enable Qt for Embedded Linux. Disabling." CFG_EMBEDDED=no fi ;; - embedded-lite) + qpa) CFG_EMBEDDED="$VAL" - if [ "$PLATFORM_EMBLITE" != "no" ]; then - if [ "$PLATFORM_EMBLITE" = "maybe" ]; then + if [ "$PLATFORM_QPA" != "no" ]; then + if [ "$PLATFORM_QPA" = "maybe" ]; then PLATFORM_X11=no PLATFORM_MAC=no PLATFORM_QWS=no - PLATFORM_EMBLITE=yes + PLATFORM_QPA=yes fi else - echo "No license exists to enable Qt for Embedded Linux Lite. Disabling." + echo "No license exists to enable Qt QPA. Disabling." CFG_EMBEDDED=no fi ;; @@ -426,7 +426,7 @@ elif [ -f "$relpath"/LICENSE.PREVIEW.COMMERCIAL ] && [ $COMMERCIAL_USER = "yes" elif [ $COMMERCIAL_USER = "yes" ]; then # one of commercial editions [ "$PLATFORM_MAC" = "maybe" ] && PLATFORM_MAC=yes - [ "$PLATFORM_EMBLITE" = "maybe" ] && PLATFORM_EMBLITE=no + [ "$PLATFORM_QPA" = "maybe" ] && PLATFORM_QPA=no [ "$PLATFORM_QWS" = "maybe" ] && PLATFORM_QWS=no # read in the license file @@ -519,7 +519,7 @@ elif [ $COMMERCIAL_USER = "yes" ]; then PlatformCode=`echo "$PlatformCode" | sed 's/.$//'` ;; esac - ### EMBEDDED_LITE logic missing ### + ### EMBEDDED_QPA logic missing ### case "$PlatformCode,$PLATFORM_MAC,$PLATFORM_QWS" in X9,* | XC,* | XU,* | XW,* | XM,*) # Qt All-OS @@ -948,8 +948,8 @@ if [ "$CFG_EMBEDDED" = "nacl" ]; then echo "Setting NaCl options:" echo "-static" CFG_SHARED=no - echo "-embedded-lite nacl" - PLATFORM_EMBLITE=yes + echo "-qpa nacl" + PLATFORM_QPA=yes echo "-fast" OPT_FAST=yes echo "-release" @@ -1026,7 +1026,7 @@ while [ "$#" -gt 0 ]; do ;; #Qt style options that pass an argument -qconfig) - if [ "$PLATFORM_QWS" != "yes" -a "$PLATFORM_EMBLITE" != "yes" ]; then + if [ "$PLATFORM_QWS" != "yes" -a "$PLATFORM_QPA" != "yes" ]; then echo echo "WARNING: -qconfig is only tested and supported on Qt for Embedded Linux." echo @@ -1066,8 +1066,8 @@ while [ "$#" -gt 0 ]; do VAL=$1 fi ;; - -embedded-lite) - VAR=embedded-lite + -embedded-lite|-qpa) + VAR=qpa # this option may or may not be followed by an argument if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then VAL=auto @@ -1297,24 +1297,24 @@ while [ "$#" -gt 0 ]; do PLATFORM_X11=no PLATFORM_MAC=no PLATFORM_QWS=yes - PLATFORM_EMBLITE=no + PLATFORM_QPA=no fi else echo "No license exists to enable Qt for Embedded Linux. Disabling." CFG_EMBEDDED=no fi ;; - embedded-lite) + embedded-lite|qpa) CFG_EMBEDDED="$VAL" - if [ "$PLATFORM_EMBLITE" != "no" ]; then - if [ "$PLATFORM_EMBLITE" = "maybe" ]; then + if [ "$PLATFORM_QPA" != "no" ]; then + if [ "$PLATFORM_QPA" = "maybe" ]; then PLATFORM_X11=no PLATFORM_MAC=no PLATFORM_QWS=no - PLATFORM_EMBLITE=yes + PLATFORM_QPA=yes fi else - echo "No license exists to enable Qt for Embedded Linux Lite. Disabling." + echo "No license exists to enable Qt QPA. Disabling." CFG_EMBEDDED=no fi ;; @@ -1420,8 +1420,8 @@ while [ "$#" -gt 0 ]; do PLATFORM_MAC=no elif [ "$PLATFORM_QWS" = "yes" ]; then PLATFORM_QWS=no - elif [ "$PLATFORM_EMBLITE" = "yes" ]; then - PLATFORM_EMBLITE=no + elif [ "$PLATFORM_QPA" = "yes" ]; then + PLATFORM_QPA=no fi if [ "$CFG_FRAMEWORK" = "auto" ]; then CFG_FRAMEWORK=no @@ -2311,7 +2311,7 @@ if [ "$CFG_GUI" = "no" ]; then fi #disable Qt3Support for Lighthouse -if [ "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_QPA" = "yes" ]; then CFG_QT3SUPPORT="no" fi @@ -2385,7 +2385,7 @@ if [ "$OPT_SHADOW" = "yes" ]; then [ "$OPT_VERBOSE" = "yes" ] && echo "Performing shadow build..." fi -if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ] && [ "$CFG_DEBUG_RELEASE" = "yes" ]; then +if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ] && [ "$CFG_DEBUG_RELEASE" = "yes" ]; then echo echo "WARNING: -debug-and-release is not supported anymore on Qt/X11 and Qt for Embedded Linux" echo "By default, Qt is built in release mode with separate debug information, so" @@ -2489,7 +2489,7 @@ if [ "$OPT_SHADOW" = "yes" ]; then fi # symlink fonts to be able to run application from build directory -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ] && [ ! -d "${outpath}/lib/fonts" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ] && [ ! -d "${outpath}/lib/fonts" ]; then if [ "$PLATFORM" = "$XPLATFORM" ]; then mkdir -p "${outpath}/lib" ln -s "${relpath}/lib/fonts" "${outpath}/lib/fonts" @@ -2529,7 +2529,7 @@ fi ### help #------------------------------------------------------------------------------- [ "$PLATFORM_QWS" = "yes" -a "$CFG_EMBEDDED" = "no" ] && CFG_EMBEDDED=auto -[ "$PLATFORM_EMBLITE" = "yes" -a "$CFG_EMBEDDED" = "no" ] && CFG_EMBEDDED=auto +[ "$PLATFORM_QPA" = "yes" -a "$CFG_EMBEDDED" = "no" ] && CFG_EMBEDDED=auto if [ "$CFG_EMBEDDED" != "no" ]; then case "$UNAME_SYSTEM:$UNAME_RELEASE" in Darwin:*) @@ -2604,7 +2604,7 @@ if [ "$CFG_EMBEDDED" != "no" ]; then echo "Qt for Embedded Linux is not supported on this platform. Disabling." CFG_EMBEDDED=no PLATFORM_QWS=no - PLATFORM_EMBLITE=no + PLATFORM_QPA=no ;; esac fi @@ -2773,7 +2773,7 @@ if [ -z "$PLATFORM" ]; then esac fi -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then CFG_SM=no PLATFORMS=`find "$relpath/mkspecs/qws" | sed "s,$relpath/mkspecs/qws/,,"` else @@ -3087,7 +3087,7 @@ fi if [ "$OPT_VERBOSE" = "yes" ]; then echo "System architecture: '$CFG_ARCH'" - if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then + if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then echo "Host architecture: '$CFG_HOST_ARCH'" fi fi @@ -3278,7 +3278,7 @@ if [ "$CFG_USE_GNUMAKE" = "auto" ] && "$MAKE" -v | grep "GNU Make" >/dev/null 2> fi # If -opengl wasn't specified, don't try to auto-detect -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ] && [ "$CFG_OPENGL" = "auto" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ] && [ "$CFG_OPENGL" = "auto" ]; then CFG_OPENGL=no fi @@ -3354,8 +3354,8 @@ if [ -z "$QT_INSTALL_PREFIX" ]; then if [ -z "$QT_INSTALL_PREFIX" ]; then # still empty if [ "$CFG_DEV" = "yes" ]; then QT_INSTALL_PREFIX="$outpath" # In Development, we use sandboxed builds by default - elif [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then - if [ "$PLATFORM_EMBLITE" = "yes" ]; then + elif [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then + if [ "$PLATFORM_QPA" = "yes" ]; then QT_INSTALL_PREFIX="/usr/local/Trolltech/QtLighthouse-${QT_VERSION}" else QT_INSTALL_PREFIX="/usr/local/Trolltech/QtEmbedded-${QT_VERSION}" @@ -3576,7 +3576,7 @@ Installation options: -prefix ...... This will install everything relative to (default $QT_INSTALL_PREFIX) EOF -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then cat <: arm mips x86 generic - -embedded-lite This will enable the Lighthouse build. + -qpa ......... This will enable the QPA build. Example values for : arm mips x86 generic - Lighthouse does not use QWS. + QPA is a window system agnostic implementation of Qt. -armfpa ............. Target platform uses the ARM-FPA floating point format. -no-armfpa .......... Target platform does not use the ARM-FPA floating point format. @@ -4190,7 +4190,7 @@ EOF fi -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" -o "$PLATFORM_X11" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" -o "$PLATFORM_X11" = "yes" ]; then if [ "$CFG_GLIB" = "no" ]; then GBY=" " GBN="+" @@ -4229,7 +4229,7 @@ fi # Help # LICENSING, INTERACTIVE PART # ----------------------------------------------------------------------------- -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then Platform="Qt for Embedded Linux" elif [ "$PLATFORM_MAC" = "yes" ]; then Platform="Qt for Mac OS X" @@ -5285,7 +5285,7 @@ fi # auto-detect iconv(3) support if [ "$CFG_ICONV" != "no" ]; then - if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then + if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then CFG_ICONV=no elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/iconv" "POSIX iconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then CFG_ICONV=yes @@ -5346,7 +5346,7 @@ if [ "$PLATFORM_MAC" = "yes" -a ! -z "$QT_NAMESPACE" ]; then fi # X11/QWS/Lighthouse -if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then # auto-detect Glib support if [ "$CFG_GLIB" != "no" ]; then @@ -5917,7 +5917,7 @@ if [ "$PLATFORM_MAC" = "yes" ]; then fi -if [ "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_QPA" = "yes" ]; then # auto-detect OpenGL support (es1 = OpenGL ES 1.x Common, es2 = OpenGL ES 2.x) if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengldesktop "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then @@ -6026,7 +6026,7 @@ if [ "$PLATFORM_QWS" = "yes" ]; then fi fi -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then # screen drivers for screen in ${CFG_GFX_ON} ${CFG_GFX_PLUGIN}; do @@ -6210,7 +6210,7 @@ fi if [ "$CFG_DOUBLEFORMAT" = "auto" ]; then - if [ "$PLATFORM_QWS" != "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then + if [ "$PLATFORM_QWS" != "yes" -o "$PLATFORM_QPA" = "yes" ]; then CFG_DOUBLEFORMAT=normal else "$unixtests/doubleformat.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" @@ -6489,7 +6489,7 @@ fi #------------------------------------------------------------------------------- ### fix this: user input should be validated in a loop -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then PROMPT_FOR_DEPTHS="yes" else PROMPT_FOR_DEPTHS="no" @@ -6684,7 +6684,7 @@ else fi if [ "$CFG_OPENGL" = "es1" ] || [ "$CFG_OPENGL" = "es2" ]; then - if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then + if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then if [ "$PLATFORM_QWS" = "yes" ]; then QCONFIG_FLAGS="$QCONFIG_FLAGS Q_BACKINGSTORE_SUBSURFACES" else @@ -6731,10 +6731,10 @@ if [ "$PLATFORM_QWS" = "yes" ]; then QT_CONFIG="$QT_CONFIG embedded" rm -f "src/.moc/$QMAKE_OUTDIR/allmoc.cpp" # needs remaking if config changes fi -if [ "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_QPA" = "yes" ]; then QMAKE_OUTDIR="${QMAKE_OUTDIR}-emb-$CFG_EMBEDDED" - QMAKE_CONFIG="$QMAKE_CONFIG embedded_lite" - QT_CONFIG="$QT_CONFIG embedded_lite" + QMAKE_CONFIG="$QMAKE_CONFIG qpa" + QT_CONFIG="$QT_CONFIG qpa" rm -f "src/.moc/$QMAKE_OUTDIR/allmoc.cpp" # needs remaking if config changes fi @@ -6991,7 +6991,7 @@ if [ '!' -z "$I_FLAGS" ]; then fi # turn off exceptions for the compilers that support it -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then COMPILER=`echo $XPLATFORM | cut -f 3- -d-` else COMPILER=`echo $PLATFORM | cut -f 2- -d-` @@ -6999,7 +6999,7 @@ fi if [ "$CFG_EXCEPTIONS" = "unspecified" -a "$PLATFORM_QWS" = "yes" ]; then CFG_EXCEPTIONS=no fi -if [ "$CFG_EXCEPTIONS" = "unspecified" -a "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$CFG_EXCEPTIONS" = "unspecified" -a "$PLATFORM_QPA" = "yes" ]; then CFG_EXCEPTIONS=no fi @@ -7388,7 +7388,7 @@ esac # ipv6 # # X11 : x11sm xinerama xcursor xfixes xrandr xrender mitshm fontconfig xkb -# Embedded: embedded embedded_lite freetype +# Embedded: embedded qpa freetype # ALL_OPTIONS= BUILD_CONFIG= @@ -7689,8 +7689,8 @@ if [ "$PLATFORM_QWS" = "yes" ]; then done fi # QWS -if [ "$PLATFORM_EMBLITE" = "yes" ]; then - # Add LITE to config.h +if [ "$PLATFORM_QPA" = "yes" ]; then + # Add QPA to config.h QCONFIG_FLAGS="$QCONFIG_FLAGS Q_WS_QPA QT_NO_QWS_QPF QT_NO_QWS_QPF2" fi @@ -8102,7 +8102,7 @@ else echo "Architecture: $CFG_ARCH" fi -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then echo "Host architecture: $CFG_HOST_ARCH" fi @@ -8210,7 +8210,7 @@ else fi echo "zlib support ........... $CFG_ZLIB" echo "Session management ..... $CFG_SM" -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_EMBLITE" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then echo "Embedded support ....... $CFG_EMBEDDED" if [ "$CFG_QWS_FREETYPE" = "auto" ]; then echo "Freetype2 support ...... $CFG_QWS_FREETYPE ($CFG_LIBFREETYPE)" diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index afb1bcd..9870769 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -49,7 +49,7 @@ TEMPLATE = lib TARGET = QtWebKit contains(QT_CONFIG, embedded):CONFIG += embedded -contains(QT_CONFIG, embedded_lite):CONFIG += embedded +contains(QT_CONFIG, qpa):CONFIG += embedded CONFIG(standalone_package) { isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/generated diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index 6f53a3f..1e27c31 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -78,7 +78,7 @@ wince*: { kernel/qfunctions_wince.h } -mac:!embedded:!embedded_lite { +mac:!embedded:!qpa{ SOURCES += \ kernel/qcoreapplication_mac.cpp } diff --git a/src/gui/accessible/accessible.pri b/src/gui/accessible/accessible.pri index afa5ecd..31362ff 100644 --- a/src/gui/accessible/accessible.pri +++ b/src/gui/accessible/accessible.pri @@ -12,7 +12,7 @@ contains(QT_CONFIG, accessibility) { accessible/qaccessiblewidget.cpp \ accessible/qaccessibleplugin.cpp - mac:!embedded:!embedded_lite { + mac:!embedded:!qpa { HEADERS += accessible/qaccessible_mac_p.h OBJECTIVE_SOURCES += accessible/qaccessible_mac.mm \ accessible/qaccessible_mac_cocoa.mm diff --git a/src/gui/dialogs/dialogs.pri b/src/gui/dialogs/dialogs.pri index 20bdabc..cd8e71a 100644 --- a/src/gui/dialogs/dialogs.pri +++ b/src/gui/dialogs/dialogs.pri @@ -27,7 +27,7 @@ HEADERS += \ dialogs/qwizard.h \ dialogs/qprintpreviewdialog.h -!embedded:!embedded_lite:mac { +!embedded:!qpa:mac { OBJECTIVE_SOURCES += dialogs/qfiledialog_mac.mm \ dialogs/qfontdialog_mac.mm \ dialogs/qnspanelproxy_mac.mm \ @@ -61,7 +61,7 @@ win32 { !win32-borland:!wince*: LIBS += -lshell32 # the filedialog needs this library } -!mac:!embedded:!symbian:unix|embedded_lite { +!mac:!embedded:!symbian:unix|qpa { HEADERS += dialogs/qpagesetupdialog_unix_p.h SOURCES += dialogs/qprintdialog_unix.cpp \ dialogs/qpagesetupdialog_unix.cpp diff --git a/src/gui/egl/egl.pri b/src/gui/egl/egl.pri index 476f1a3..8e8664c 100644 --- a/src/gui/egl/egl.pri +++ b/src/gui/egl/egl.pri @@ -28,7 +28,7 @@ contains(QT_CONFIG, egl): { embedded { SOURCES += egl/qegl_qws.cpp } else { - embedded_lite { + qpa { SOURCES += egl/qegl_qpa.cpp } else { symbian { diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 4fbdb36..772f70b 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -5,7 +5,7 @@ DEFINES += QT_BUILD_GUI_LIB QT_NO_USING_NAMESPACE win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000 irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused -!win32:!embedded:!embedded_lite:!mac:!symbian:CONFIG += x11 +!win32:!embedded:!qpa:!mac:!symbian:CONFIG += x11 unix:QMAKE_PKGCONFIG_REQUIRES = QtCore diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 064ba32..13447e7 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -63,14 +63,14 @@ win32 { embedded { SOURCES += image/qpixmap_qws.cpp } -embedded_lite { +qpa { SOURCES += image/qpixmap_qpa.cpp } x11 { HEADERS += image/qpixmap_x11_p.h SOURCES += image/qpixmap_x11.cpp } -!embedded:!embedded_lite:mac { +!embedded:!qpa:mac { HEADERS += image/qpixmap_mac_p.h SOURCES += image/qpixmap_mac.cpp } diff --git a/src/gui/inputmethod/inputmethod.pri b/src/gui/inputmethod/inputmethod.pri index 6a3ef83..d439438 100644 --- a/src/gui/inputmethod/inputmethod.pri +++ b/src/gui/inputmethod/inputmethod.pri @@ -19,7 +19,7 @@ embedded { HEADERS += inputmethod/qwsinputcontext_p.h SOURCES += inputmethod/qwsinputcontext_qws.cpp } -mac:!embedded:!embedded_lite { +mac:!embedded:!qpa { HEADERS += inputmethod/qmacinputcontext_p.h SOURCES += inputmethod/qmacinputcontext_mac.cpp } diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index dcdfd04..5d92456 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -198,7 +198,7 @@ embedded { } } -embedded_lite { +qpa { HEADERS += \ kernel/qgenericpluginfactory_qpa.h \ kernel/qgenericplugin_qpa.h \ @@ -240,7 +240,7 @@ embedded_lite { } } -!embedded:!embedded_lite:!x11:mac { +!embedded:!qpa:!x11:mac { SOURCES += \ kernel/qclipboard_mac.cpp \ kernel/qmime_mac.cpp \ diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 07017ec..8d9b09e 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -119,7 +119,7 @@ embedded { SOURCES += \ painting/qgraphicssystem_qws.cpp \ -} else: if(!embedded_lite) { +} else: if(!qpa) { HEADERS += \ painting/qgraphicssystem_raster_p.h \ painting/qgraphicssystem_runtime_p.h \ @@ -147,7 +147,7 @@ unix:x11 { painting/qpaintengine_x11.cpp } -!embedded:!embedded_lite:!x11:mac { +!embedded:!qpa:!x11:mac { HEADERS += \ painting/qpaintengine_mac_p.h \ painting/qgraphicssystem_mac_p.h \ @@ -163,14 +163,14 @@ unix:x11 { painting/qprintengine_mac.mm \ } -unix:!mac:!symbian|embedded_lite { +unix:!mac:!symbian|qpa { HEADERS += \ painting/qprinterinfo_unix_p.h SOURCES += \ painting/qprinterinfo_unix.cpp } -win32|x11|mac|embedded|embedded_lite|symbian { +win32|x11|mac|embedded|qpa|symbian { SOURCES += painting/qbackingstore.cpp HEADERS += painting/qbackingstore_p.h } @@ -187,7 +187,7 @@ embedded { painting/qpaintdevice_qws.cpp } -embedded_lite { +qpa { SOURCES += \ painting/qcolormap_qpa.cpp \ painting/qpaintdevice_qpa.cpp \ @@ -206,7 +206,7 @@ symbian { painting/qpaintengine_s60_p.h } -x11|embedded|embedded_lite { +x11|embedded|qpa { contains(QT_CONFIG,qtopia) { DEFINES += QT_NO_CUPS QT_NO_LPR } else { @@ -372,7 +372,7 @@ x11 { SOURCES += painting/qwindowsurface_x11.cpp } -!embedded:!embedded_lite:mac { +!embedded:!qpa:mac { HEADERS += painting/qwindowsurface_mac_p.h SOURCES += painting/qwindowsurface_mac.cpp } diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index 9d6b6fb..0bac0aa 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -35,7 +35,7 @@ contains( styles, all ) { styles = mac windows windowsxp windowsvista } -x11|embedded|embedded_lite|!macx-*:styles -= mac +x11|embedded|qpa|!macx-*:styles -= mac x11{ QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index d7bddf5..04ab7df 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -89,7 +89,7 @@ unix:x11 { text/qfontengine_ft.cpp } -!embedded:!embedded_lite:!x11:mac { +!embedded:!qpa:!x11:mac { SOURCES += \ text/qfont_mac.cpp OBJECTIVE_SOURCES += text/qfontengine_mac.mm @@ -110,7 +110,7 @@ embedded { DEFINES += QT_NO_FONTCONFIG } -embedded_lite { +qpa { SOURCES += \ text/qfont_qws.cpp \ text/qfontengine_ft.cpp \ diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri index dd99aa8..f66f9ff 100644 --- a/src/gui/util/util.pri +++ b/src/gui/util/util.pri @@ -33,12 +33,12 @@ unix:x11 { util/qsystemtrayicon_x11.cpp } -embedded|embedded_lite { +embedded|qpa { SOURCES += \ util/qsystemtrayicon_qws.cpp } -!embedded:!embedded_lite:!x11:mac { +!embedded:!qpa:!x11:mac { OBJECTIVE_SOURCES += util/qsystemtrayicon_mac.mm } diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri index 9fe2b3d..669b838 100644 --- a/src/gui/widgets/widgets.pri +++ b/src/gui/widgets/widgets.pri @@ -144,7 +144,7 @@ SOURCES += \ widgets/qplaintextedit.cpp \ widgets/qprintpreviewwidget.cpp -!embedded:!embedded_lite:mac { +!embedded:!qpa:mac { HEADERS += widgets/qmacnativewidget_mac.h \ widgets/qmaccocoaviewcontainer_mac.h OBJECTIVE_HEADERS += widgets/qcocoatoolbardelegate_mac_p.h \ diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index f196e00..09a6b0f 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -11,7 +11,7 @@ unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui include(../qbase.pri) -!win32:!embedded:!mac:!embedded_lite:CONFIG += x11 +!win32:!embedded:!mac:!qpa:CONFIG += x11 contains(QT_CONFIG, opengl):CONFIG += opengl contains(QT_CONFIG, opengles1):CONFIG += opengles1 contains(QT_CONFIG, opengles2):CONFIG += opengles2 @@ -77,7 +77,7 @@ SOURCES += qgl.cpp \ } -embedded_lite { +qpa { DEFINES += QT_NO_EGL SOURCES += qgl_qpa.cpp \ diff --git a/src/plugins/graphicssystems/graphicssystems.pro b/src/plugins/graphicssystems/graphicssystems.pro index c00c9ff..7a8f4d6 100644 --- a/src/plugins/graphicssystems/graphicssystems.pro +++ b/src/plugins/graphicssystems/graphicssystems.pro @@ -2,11 +2,7 @@ TEMPLATE = subdirs SUBDIRS += trace !wince*:contains(QT_CONFIG, opengl):SUBDIRS += opengl contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl) { - embedded_lite { - SUBDIRS += openvglite - } else { - SUBDIRS += openvg - } + SUBDIRS += openvg } contains(QT_CONFIG, shivavg) { diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro index 9688443..b68230c 100644 --- a/src/plugins/platforms/platforms.pro +++ b/src/plugins/platforms/platforms.pro @@ -1,14 +1,11 @@ TEMPLATE = subdirs contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl) { - embedded_lite { - SUBDIRS += openvglite - } + SUBDIRS += openvglite } -embedded_lite { SUBDIRS += minimal -} -embedded_lite:x11 { +#this don't work. but leave it for now +qpa:x11 { SUBDIRS += testlite } diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 04e8c7c..bc76a0c 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -7,12 +7,12 @@ unix:!symbian { SUBDIRS *= codecs } !contains(QT_CONFIG, no-gui): SUBDIRS *= imageformats iconengines -!embedded:!embedded_lite:SUBDIRS *= graphicssystems +!embedded:!qpa:SUBDIRS *= graphicssystems embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers !win32:!embedded:!mac:!symbian:SUBDIRS *= inputmethods !symbian:!contains(QT_CONFIG, no-gui):SUBDIRS += accessible symbian:SUBDIRS += s60 contains(QT_CONFIG, phonon): SUBDIRS *= phonon contains(QT_CONFIG, multimedia): SUBDIRS *= audio - +qpa:SUBDIRS += platforms diff --git a/src/qt_install.pri b/src/qt_install.pri index 3cea79c..268bb86 100644 --- a/src/qt_install.pri +++ b/src/qt_install.pri @@ -38,7 +38,7 @@ qt_install_headers { } } -embedded|embedded_lite: equals(TARGET, QtGui) { +embedded|qpa: equals(TARGET, QtGui) { # install fonts for embedded INSTALLS += fonts fonts.path = $$[QT_INSTALL_LIBS]/fonts diff --git a/tools/tools.pro b/tools/tools.pro index 03d01a0..8002b4b 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -20,7 +20,7 @@ TEMPLATE = subdirs SUBDIRS += designer } } - unix:!mac:!embedded:!embedded_lite:contains(QT_CONFIG, qt3support):SUBDIRS += qtconfig + unix:!mac:!embedded:!qpa:contains(QT_CONFIG, qt3support):SUBDIRS += qtconfig win32:!wince*:SUBDIRS += activeqt } contains(QT_CONFIG, declarative):SUBDIRS += qml -- cgit v0.12 From 3a34a71c6f70a709ac494e65d465dcd4e346ccbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 24 Jun 2010 12:46:49 +0200 Subject: Remove QSound for Lighthouse --- src/gui/kernel/kernel.pri | 13 +++++--- src/gui/kernel/qsound_qpa.cpp | 74 ------------------------------------------- 2 files changed, 9 insertions(+), 78 deletions(-) delete mode 100644 src/gui/kernel/qsound_qpa.cpp diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 5d92456..965cbe3 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -32,8 +32,6 @@ HEADERS += \ kernel/qshortcutmap_p.h \ kernel/qsizepolicy.h \ kernel/qpalette.h \ - kernel/qsound.h \ - kernel/qsound_p.h \ kernel/qstackedlayout.h \ kernel/qtooltip.h \ kernel/qwhatsthis.h \ @@ -73,7 +71,6 @@ SOURCES += \ kernel/qpalette.cpp \ kernel/qshortcut.cpp \ kernel/qshortcutmap.cpp \ - kernel/qsound.cpp \ kernel/qstackedlayout.cpp \ kernel/qtooltip.cpp \ kernel/qguivariant.cpp \ @@ -198,6 +195,15 @@ embedded { } } +!qpa { + HEADERS += \ + kernel/qsound.h \ + kernel/qsound_p.h + + SOURCES += \ + kernel/qsound.cpp +} + qpa { HEADERS += \ kernel/qgenericpluginfactory_qpa.h \ @@ -220,7 +226,6 @@ qpa { kernel/qgenericpluginfactory_qpa.cpp \ kernel/qgenericplugin_qpa.cpp \ kernel/qkeymapper_qws.cpp \ - kernel/qsound_qpa.cpp \ kernel/qwidget_qpa.cpp \ kernel/qeventdispatcher_qpa.cpp \ kernel/qwindowsysteminterface.cpp \ diff --git a/src/gui/kernel/qsound_qpa.cpp b/src/gui/kernel/qsound_qpa.cpp deleted file mode 100644 index 0714185..0000000 --- a/src/gui/kernel/qsound_qpa.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 "qapplication.h" - -#ifndef QT_NO_SOUND - -#include "qsound.h" -#include "qsound_p.h" - -class QAuServerLite : public QAuServer -{ - Q_OBJECT -public: - QAuServerLite( QObject* parent ); - - void play( QSound* s ) {} - void stop( QSound* s ) {} - bool okay() { return false; } -}; - -QAuServerLite::QAuServerLite(QObject* parent) : - QAuServer(parent) -{ -} - -QAuServer* qt_new_audio_server() -{ - return new QAuServerLite(qApp); -} - -#include "qsound_qpa.moc" - -#endif // QT_NO_SOUND - -QT_END_NAMESPACE -- cgit v0.12 From 1e88fd57c693db1e4b6f0c42a2c05fad935fb4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 24 Jun 2010 14:02:41 +0200 Subject: Refactored QGraphicsSystemCursor -> QPlatformCursor --- src/gui/image/qpixmap_blitter.cpp | 4 + src/gui/kernel/qapplication_qpa.cpp | 6 +- src/gui/kernel/qwidget_qpa.cpp | 4 +- src/gui/painting/painting.pri | 4 +- src/gui/painting/qgraphicssystemcursor_qpa.cpp | 664 --------------------- src/gui/painting/qgraphicssystemcursor_qpa.h | 97 --- src/gui/painting/qplatformcursor_qpa.cpp | 664 +++++++++++++++++++++ src/gui/painting/qplatformcursor_qpa.h | 97 +++ src/plugins/platforms/directfb/qdirectfbcursor.cpp | 4 +- src/plugins/platforms/directfb/qdirectfbcursor.h | 6 +- src/plugins/platforms/fb_base/fb_base.cpp | 24 +- src/plugins/platforms/fb_base/fb_base.h | 10 +- .../platforms/linuxfb/qlinuxfbintegration.cpp | 2 +- .../platforms/testlite/qtestliteintegration.cpp | 6 +- src/plugins/platforms/vnc/qvnccursor.cpp | 6 +- src/plugins/platforms/vnc/qvnccursor.h | 2 +- 16 files changed, 802 insertions(+), 798 deletions(-) delete mode 100644 src/gui/painting/qgraphicssystemcursor_qpa.cpp delete mode 100644 src/gui/painting/qgraphicssystemcursor_qpa.h create mode 100644 src/gui/painting/qplatformcursor_qpa.cpp create mode 100644 src/gui/painting/qplatformcursor_qpa.h diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 660f4d2..d91a269 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -37,7 +37,11 @@ QBlittable *QBlittablePixmapData::blittable() const { if (!m_blittable) { QBlittablePixmapData *that = const_cast(this); +#ifdef Q_WS_QPA //####jl: graphics system nor platformintegration should have createBlittable + that->m_blittable = QApplicationPrivate::platformIntegration()->createBlittable(QSize(w,h)); +#else that->m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QSize(w,h)); +#endif } return m_blittable; diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index afa069b..1fc202c 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -57,7 +57,7 @@ #include #include -#include +#include #include #include #include @@ -705,8 +705,8 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent * QMouseEvent ev(type, localPoint, globalPoint, button, buttons, modifiers); - QList > cursors = QGraphicsSystemCursorPrivate::getInstances(); - foreach (QWeakPointer cursor, cursors) { + QList > cursors = QPlatformCursorPrivate::getInstances(); + foreach (QWeakPointer cursor, cursors) { if (cursor) cursor.data()->pointerEvent(ev); } diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index 11fa211..a543c8f 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -49,7 +49,7 @@ #include "QtGui/qdesktopwidget.h" #include "QtGui/qplatformwindow_qpa.h" -#include +#include QT_BEGIN_NAMESPACE static QPlatformScreen *qt_screenForWidget(const QWidget *w); @@ -800,7 +800,7 @@ void qt_lite_set_cursor(QWidget * w, bool force) cursorCursor = w->cursor(); cursorWidget = w; } while (0); - foreach (QWeakPointer cursor, QGraphicsSystemCursorPrivate::getInstances()) + foreach (QWeakPointer cursor, QPlatformCursorPrivate::getInstances()) if (cursor) cursor.data()->changeCursor(&cursorCursor, cursorWidget); } diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 8d9b09e..b235320 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -191,9 +191,9 @@ qpa { SOURCES += \ painting/qcolormap_qpa.cpp \ painting/qpaintdevice_qpa.cpp \ - painting/qgraphicssystemcursor_qpa.cpp + painting/qplatformcursor_qpa.cpp HEADERS += \ - painting/qgraphicssystemcursor_qpa.h + painting/qplatformcursor_qpa.h } symbian { diff --git a/src/gui/painting/qgraphicssystemcursor_qpa.cpp b/src/gui/painting/qgraphicssystemcursor_qpa.cpp deleted file mode 100644 index 24376f9..0000000 --- a/src/gui/painting/qgraphicssystemcursor_qpa.cpp +++ /dev/null @@ -1,664 +0,0 @@ -/**************************************************************************** -** -** 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 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 "qgraphicssystemcursor_qpa.h" - -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -QList > QGraphicsSystemCursorPrivate::instances; - -/*! - \class QGraphicsSystemCursor - - \brief The QGraphicsSystemCursor class provides information about - pointer device events (movement, buttons), and requests to change - the currently displayed cursor. - - Note that QGraphicsSystemCursor does not include any graphics for - display. An application that sets a QCursor may provide its own - graphics. - - \sa QGraphicsSystemCursorImage -*/ - -/*! - \fn virtual void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & event) - - This method is called by Qt whenever a QMouseEvent is generated by the - underlying pointer input. \a event is a reference to the QMouseEvent in - question. A default do-nothing implementation is provided. - - \sa QApplicationPrivate::handleMouseEvent() -*/ - -/*! - \fn virtual void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) - - \brief This method is called by Qt whenever the cursor graphic should be changed. - - Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor. - - \a widgetCursor is a pointer to the QCursor that should be displayed. - - \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note - that this may be 0 if the current position is not occupied by a displayed widget. - - \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos() -*/ - -/*! - \fn QGraphicsSystemCursor::QGraphicsSystemCursor() - - \brief Constructs a QGraphicsSystemCursor -*/ -QGraphicsSystemCursor::QGraphicsSystemCursor(QPlatformScreen *scr ) - : screen(scr) -{ - QGraphicsSystemCursorPrivate::instances.append(this); -} - -// End of display and pointer event handling code -// Beginning of built-in cursor graphics -// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp - -/*! - \class QGraphicsSystemCursorImage - - \brief The QGraphicsSystemCursorImage class provides a set of graphics - intended to be used as cursors. - - \sa QGraphicsSystemCursor -*/ - -static QGraphicsSystemCursorImage *systemCursorTable[Qt::LastCursor+1]; -static bool systemCursorTableInit = false; - -// 16 x 16 -static const uchar cur_arrow_bits[] = { - 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08, - 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22, - 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 }; -static const uchar mcur_arrow_bits[] = { - 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f, - 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e, - 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 }; - -static const unsigned char cur_up_arrow_bits[] = { - 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, - 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01}; -static const unsigned char mcur_up_arrow_bits[] = { - 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07, - 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01}; - -static const unsigned char cur_cross_bits[] = { - 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00}; -static const unsigned char mcur_cross_bits[] = { - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; - -static const uchar cur_ibeam_bits[] = { - 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, - 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, - 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_ibeam_bits[] = { - 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 }; - -static const uchar cur_ver_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, - 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, - 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; -static const uchar mcur_ver_bits[] = { - 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, - 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, - 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; - -static const uchar cur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, - 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, - 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, - 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; -static const uchar cur_bdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, - 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, - 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_bdiag_bits[] = { - 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, - 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, - 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; -static const uchar cur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, - 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, - 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, - 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, - 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; -static const uchar cur_blank_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -// 20 x 20 -static const uchar forbidden_bits[] = { - 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, - 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, - 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, - 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; - -static const uchar forbiddenm_bits[] = { - 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, - 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, - 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, - 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; - -// 32 x 32 -static const uchar wait_data_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00, - 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, - 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00, - 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, - 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00, - 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar wait_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, - 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00, - 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar hsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, - 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar hsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, - 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, - 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, - 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar vsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar vsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar phand_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, - 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00, - 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, - 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar phandm_bits[] = { - 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, - 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, - 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, - 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, - 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar size_all_data_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00, - 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar size_all_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00, - 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01, - 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00, - 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar whatsthis_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, - 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, - 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, - 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, - 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, - 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -static const uchar whatsthism_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, - 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, - 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, - 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, - 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, - 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - -static const uchar busy_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, - 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, - 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, - 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, - 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static const uchar busym_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, - 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, - 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, - 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, - 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, - 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -// 16 x 16 -static const uchar openhand_bits[] = { - 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, - 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, - 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; -static const uchar openhandm_bits[] = { - 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, - 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, - 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; -static const uchar closedhand_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, - 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, - 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; -static const uchar closedhandm_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, - 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, - 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; - -void QGraphicsSystemCursorImage::createSystemCursor(int id) -{ - if (!systemCursorTableInit) { - for (int i = 0; i <= Qt::LastCursor; i++) - systemCursorTable[i] = 0; - systemCursorTableInit = true; - } - switch (id) { - // 16x16 cursors - case Qt::ArrowCursor: - systemCursorTable[Qt::ArrowCursor] = - new QGraphicsSystemCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0); - break; - - case Qt::UpArrowCursor: - systemCursorTable[Qt::UpArrowCursor] = - new QGraphicsSystemCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0); - break; - - case Qt::CrossCursor: - systemCursorTable[Qt::CrossCursor] = - new QGraphicsSystemCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7); - break; - - case Qt::IBeamCursor: - systemCursorTable[Qt::IBeamCursor] = - new QGraphicsSystemCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7); - break; - - case Qt::SizeVerCursor: - systemCursorTable[Qt::SizeVerCursor] = - new QGraphicsSystemCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7); - break; - - case Qt::SizeHorCursor: - systemCursorTable[Qt::SizeHorCursor] = - new QGraphicsSystemCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7); - break; - - case Qt::SizeBDiagCursor: - systemCursorTable[Qt::SizeBDiagCursor] = - new QGraphicsSystemCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7); - break; - - case Qt::SizeFDiagCursor: - systemCursorTable[Qt::SizeFDiagCursor] = - new QGraphicsSystemCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7); - break; - - case Qt::BlankCursor: - systemCursorTable[Qt::BlankCursor] = - new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); - break; - - // 20x20 cursors - case Qt::ForbiddenCursor: - systemCursorTable[Qt::ForbiddenCursor] = - new QGraphicsSystemCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10); - break; - - // 32x32 cursors - case Qt::WaitCursor: - systemCursorTable[Qt::WaitCursor] = - new QGraphicsSystemCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15); - break; - - case Qt::SplitVCursor: - systemCursorTable[Qt::SplitVCursor] = - new QGraphicsSystemCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15); - break; - - case Qt::SplitHCursor: - systemCursorTable[Qt::SplitHCursor] = - new QGraphicsSystemCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15); - break; - - case Qt::SizeAllCursor: - systemCursorTable[Qt::SizeAllCursor] = - new QGraphicsSystemCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15); - break; - - case Qt::PointingHandCursor: - systemCursorTable[Qt::PointingHandCursor] = - new QGraphicsSystemCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0); - break; - - case Qt::WhatsThisCursor: - systemCursorTable[Qt::WhatsThisCursor] = - new QGraphicsSystemCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0); - break; - case Qt::BusyCursor: - systemCursorTable[Qt::BusyCursor] = - new QGraphicsSystemCursorImage(busy_bits, busym_bits, 32, 32, 0, 0); - break; - - case Qt::OpenHandCursor: - systemCursorTable[Qt::OpenHandCursor] = - new QGraphicsSystemCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8); - break; - case Qt::ClosedHandCursor: - systemCursorTable[Qt::ClosedHandCursor] = - new QGraphicsSystemCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8); - break; - default: - qWarning("Unknown system cursor %d", id); - } -} - -/*! - \fn void QGraphicsSystemCursorImage::set(Qt::CursorShape id) - - \brief Calling this method sets the cursor image to the specified shape - - \a id is one of the defined Qt::CursorShape values. - - If id is invalid, Qt::BitmapCursor, or unknown by the implementation, - Qt::ArrowCursor is used instead. -*/ - -void QGraphicsSystemCursorImage::set(Qt::CursorShape id) -{ - QGraphicsSystemCursorImage *cursor = 0; - if (id >= 0 && id <= Qt::LastCursor) { - if (!systemCursorTable[id]) - createSystemCursor(id); - cursor = systemCursorTable[id]; - } - - if (cursor == 0) { - if (!systemCursorTable[Qt::ArrowCursor]) - createSystemCursor(Qt::ArrowCursor); - cursor = systemCursorTable[Qt::ArrowCursor]; - } - cursorImage = cursor->cursorImage; - hot = cursor->hot; -} - -/*! - \fn void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) - - \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy) - - \a image A pointer to a QImage - - \a hx The x coordinate of the cursor's hotspot - - \a hy the y coordinate of the cursor's hotspot -*/ - -void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) -{ - hot.setX(hx); - hot.setY(hy); - cursorImage = *image; -} - -/*! - \fn void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) - - \brief set the cursor image to the graphic represented by the combination of data, mask, - width, and height - - \a data The pixel data of the graphic - - \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn - - \a width The width of the graphic in pixels - - \a height The height of the graphic in pixels - - \a hx The X hotspot of the cursor graphic - - \a hy The Y hotspot of the cursor graphic -*/ -void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, - int width, int height, int hx, int hy) -{ - hot.setX(hx); - hot.setY(hy); - - cursorImage = QImage(width,height, QImage::Format_Indexed8); - - if (!width || !height || !data || !mask || cursorImage.isNull()) - return; - - cursorImage.setNumColors(3); - cursorImage.setColor(0, 0xff000000); - cursorImage.setColor(1, 0xffffffff); - cursorImage.setColor(2, 0x00000000); - - int bytesPerLine = (width + 7) / 8; - int p = 0; - int d, m; - - int x = -1, w = 0; - - uchar *cursor_data = cursorImage.bits(); - int bpl = cursorImage.bytesPerLine(); - for (int i = 0; i < height; i++) - { - for (int j = 0; j < bytesPerLine; j++, data++, mask++) - { - for (int b = 0; b < 8 && j*8+b < width; b++) - { - d = *data & (1 << b); - m = *mask & (1 << b); - if (d && m) p = 0; - else if (!d && m) p = 1; - else p = 2; - cursor_data[j*8+b] = p; - - // calc region - if (x < 0 && m) - x = j*8+b; - else if (x >= 0 && !m) { - x = -1; - w = 0; - } - if (m) - w++; - } - } - if (x >= 0) { - x = -1; - w = 0; - } - cursor_data += bpl; - } - -} - -/*! - \fn QGraphicsSystemCursorImage::QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) - - \brief set the cursor image to the graphic represented by the combination of data, mask, - width, and height - - \a data The pixel data of the graphic - - \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn - - \a width The width of the graphic in pixels - - \a height The height of the graphic in pixels - - \a hotX The X hotspot of the cursor graphic - - \a hotY The Y hotspot of the cursor graphic - - \sa set -*/ - -/*! - \fn QImage *QGraphicsSystemCursorImage::image() - - \brief Return the cursor graphic as a pointer to a QImage -*/ - -/*! - \fn QPoint QGraphicsSystemCursorImage::hotspot() - - \brief Return the cursor's hotspot -*/ - -QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystemcursor_qpa.h b/src/gui/painting/qgraphicssystemcursor_qpa.h deleted file mode 100644 index 9c65f7f..0000000 --- a/src/gui/painting/qgraphicssystemcursor_qpa.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QGRAPHICSSYSTEMCURSOR_H -#define QGRAPHICSSYSTEMCURSOR_H - -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -// Cursor graphics management -class Q_GUI_EXPORT QGraphicsSystemCursorImage { -public: - QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) - { set(data, mask, width, height, hotX, hotY); } - QImage * image() { return &cursorImage; } - QPoint hotspot() { return hot; } - void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); - void set(const QImage * image, int hx, int hy); - void set(Qt::CursorShape); -private: - static void createSystemCursor(int id); - QImage cursorImage; - QPoint hot; -}; - -class QGraphicsSystemCursor; - -class QGraphicsSystemCursorPrivate { -public: - static QList > getInstances() { return instances; } - static QList > instances; -}; - -class Q_GUI_EXPORT QGraphicsSystemCursor : public QObject { -public: - QGraphicsSystemCursor(QPlatformScreen *); - - // input methods - virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } - virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0; - -protected: - QPlatformScreen* screen; // Where to request an update - -private: - Q_DECLARE_PRIVATE(QGraphicsSystemCursor); - friend void qt_lite_set_cursor(QWidget * w, bool force); - friend class QApplicationPrivate; -}; - -QT_END_NAMESPACE - -#endif // QGRAPHICSSYSTEMCURSOR_H diff --git a/src/gui/painting/qplatformcursor_qpa.cpp b/src/gui/painting/qplatformcursor_qpa.cpp new file mode 100644 index 0000000..6665396 --- /dev/null +++ b/src/gui/painting/qplatformcursor_qpa.cpp @@ -0,0 +1,664 @@ +/**************************************************************************** +** +** 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 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 "qplatformcursor_qpa.h" + +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +QList > QPlatformCursorPrivate::instances; + +/*! + \class QGraphicsSystemCursor + + \brief The QGraphicsSystemCursor class provides information about + pointer device events (movement, buttons), and requests to change + the currently displayed cursor. + + Note that QGraphicsSystemCursor does not include any graphics for + display. An application that sets a QCursor may provide its own + graphics. + + \sa QGraphicsSystemCursorImage +*/ + +/*! + \fn virtual void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & event) + + This method is called by Qt whenever a QMouseEvent is generated by the + underlying pointer input. \a event is a reference to the QMouseEvent in + question. A default do-nothing implementation is provided. + + \sa QApplicationPrivate::handleMouseEvent() +*/ + +/*! + \fn virtual void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) + + \brief This method is called by Qt whenever the cursor graphic should be changed. + + Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor. + + \a widgetCursor is a pointer to the QCursor that should be displayed. + + \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note + that this may be 0 if the current position is not occupied by a displayed widget. + + \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos() +*/ + +/*! + \fn QGraphicsSystemCursor::QGraphicsSystemCursor() + + \brief Constructs a QGraphicsSystemCursor +*/ +QPlatformCursor::QPlatformCursor(QPlatformScreen *scr ) + : screen(scr) +{ + QPlatformCursorPrivate::instances.append(this); +} + +// End of display and pointer event handling code +// Beginning of built-in cursor graphics +// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp + +/*! + \class QGraphicsSystemCursorImage + + \brief The QGraphicsSystemCursorImage class provides a set of graphics + intended to be used as cursors. + + \sa QGraphicsSystemCursor +*/ + +static QPlatformCursorImage *systemCursorTable[Qt::LastCursor+1]; +static bool systemCursorTableInit = false; + +// 16 x 16 +static const uchar cur_arrow_bits[] = { + 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08, + 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22, + 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 }; +static const uchar mcur_arrow_bits[] = { + 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f, + 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e, + 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 }; + +static const unsigned char cur_up_arrow_bits[] = { + 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, + 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01}; +static const unsigned char mcur_up_arrow_bits[] = { + 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07, + 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01}; + +static const unsigned char cur_cross_bits[] = { + 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00}; +static const unsigned char mcur_cross_bits[] = { + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; + +static const uchar cur_ibeam_bits[] = { + 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, + 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, + 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_ibeam_bits[] = { + 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 }; + +static const uchar cur_ver_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, + 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, + 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; +static const uchar mcur_ver_bits[] = { + 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, + 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, + 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; + +static const uchar cur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, + 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, + 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, + 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; +static const uchar cur_bdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, + 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, + 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_bdiag_bits[] = { + 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, + 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, + 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; +static const uchar cur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, + 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, + 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, + 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, + 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; +static const uchar cur_blank_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +// 20 x 20 +static const uchar forbidden_bits[] = { + 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, + 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, + 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, + 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; + +static const uchar forbiddenm_bits[] = { + 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, + 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, + 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, + 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; + +// 32 x 32 +static const uchar wait_data_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00, + 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, + 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00, + 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, + 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00, + 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar wait_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, + 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00, + 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar hsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, + 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar hsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, + 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, + 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, + 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar vsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar vsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar phand_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, + 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00, + 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, + 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar phandm_bits[] = { + 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, + 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, + 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, + 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, + 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar size_all_data_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00, + 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar size_all_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00, + 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01, + 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00, + 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar whatsthis_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, + 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, + 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, + 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, + 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, + 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; +static const uchar whatsthism_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, + 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, + 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, + 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, + 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, + 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + +static const uchar busy_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, + 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, + 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, + 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, + 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static const uchar busym_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, + 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, + 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, + 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, + 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +// 16 x 16 +static const uchar openhand_bits[] = { + 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, + 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, + 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; +static const uchar openhandm_bits[] = { + 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, + 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, + 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; +static const uchar closedhand_bits[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, + 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, + 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; +static const uchar closedhandm_bits[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, + 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, + 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; + +void QPlatformCursorImage::createSystemCursor(int id) +{ + if (!systemCursorTableInit) { + for (int i = 0; i <= Qt::LastCursor; i++) + systemCursorTable[i] = 0; + systemCursorTableInit = true; + } + switch (id) { + // 16x16 cursors + case Qt::ArrowCursor: + systemCursorTable[Qt::ArrowCursor] = + new QPlatformCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0); + break; + + case Qt::UpArrowCursor: + systemCursorTable[Qt::UpArrowCursor] = + new QPlatformCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0); + break; + + case Qt::CrossCursor: + systemCursorTable[Qt::CrossCursor] = + new QPlatformCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7); + break; + + case Qt::IBeamCursor: + systemCursorTable[Qt::IBeamCursor] = + new QPlatformCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7); + break; + + case Qt::SizeVerCursor: + systemCursorTable[Qt::SizeVerCursor] = + new QPlatformCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7); + break; + + case Qt::SizeHorCursor: + systemCursorTable[Qt::SizeHorCursor] = + new QPlatformCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7); + break; + + case Qt::SizeBDiagCursor: + systemCursorTable[Qt::SizeBDiagCursor] = + new QPlatformCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7); + break; + + case Qt::SizeFDiagCursor: + systemCursorTable[Qt::SizeFDiagCursor] = + new QPlatformCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7); + break; + + case Qt::BlankCursor: + systemCursorTable[Qt::BlankCursor] = + new QPlatformCursorImage(0, 0, 0, 0, 0, 0); + break; + + // 20x20 cursors + case Qt::ForbiddenCursor: + systemCursorTable[Qt::ForbiddenCursor] = + new QPlatformCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10); + break; + + // 32x32 cursors + case Qt::WaitCursor: + systemCursorTable[Qt::WaitCursor] = + new QPlatformCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15); + break; + + case Qt::SplitVCursor: + systemCursorTable[Qt::SplitVCursor] = + new QPlatformCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15); + break; + + case Qt::SplitHCursor: + systemCursorTable[Qt::SplitHCursor] = + new QPlatformCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15); + break; + + case Qt::SizeAllCursor: + systemCursorTable[Qt::SizeAllCursor] = + new QPlatformCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15); + break; + + case Qt::PointingHandCursor: + systemCursorTable[Qt::PointingHandCursor] = + new QPlatformCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0); + break; + + case Qt::WhatsThisCursor: + systemCursorTable[Qt::WhatsThisCursor] = + new QPlatformCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0); + break; + case Qt::BusyCursor: + systemCursorTable[Qt::BusyCursor] = + new QPlatformCursorImage(busy_bits, busym_bits, 32, 32, 0, 0); + break; + + case Qt::OpenHandCursor: + systemCursorTable[Qt::OpenHandCursor] = + new QPlatformCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8); + break; + case Qt::ClosedHandCursor: + systemCursorTable[Qt::ClosedHandCursor] = + new QPlatformCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8); + break; + default: + qWarning("Unknown system cursor %d", id); + } +} + +/*! + \fn void QGraphicsSystemCursorImage::set(Qt::CursorShape id) + + \brief Calling this method sets the cursor image to the specified shape + + \a id is one of the defined Qt::CursorShape values. + + If id is invalid, Qt::BitmapCursor, or unknown by the implementation, + Qt::ArrowCursor is used instead. +*/ + +void QPlatformCursorImage::set(Qt::CursorShape id) +{ + QPlatformCursorImage *cursor = 0; + if (id >= 0 && id <= Qt::LastCursor) { + if (!systemCursorTable[id]) + createSystemCursor(id); + cursor = systemCursorTable[id]; + } + + if (cursor == 0) { + if (!systemCursorTable[Qt::ArrowCursor]) + createSystemCursor(Qt::ArrowCursor); + cursor = systemCursorTable[Qt::ArrowCursor]; + } + cursorImage = cursor->cursorImage; + hot = cursor->hot; +} + +/*! + \fn void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) + + \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy) + + \a image A pointer to a QImage + + \a hx The x coordinate of the cursor's hotspot + + \a hy the y coordinate of the cursor's hotspot +*/ + +void QPlatformCursorImage::set(const QImage * image, int hx, int hy) +{ + hot.setX(hx); + hot.setY(hy); + cursorImage = *image; +} + +/*! + \fn void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) + + \brief set the cursor image to the graphic represented by the combination of data, mask, + width, and height + + \a data The pixel data of the graphic + + \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn + + \a width The width of the graphic in pixels + + \a height The height of the graphic in pixels + + \a hx The X hotspot of the cursor graphic + + \a hy The Y hotspot of the cursor graphic +*/ +void QPlatformCursorImage::set(const uchar *data, const uchar *mask, + int width, int height, int hx, int hy) +{ + hot.setX(hx); + hot.setY(hy); + + cursorImage = QImage(width,height, QImage::Format_Indexed8); + + if (!width || !height || !data || !mask || cursorImage.isNull()) + return; + + cursorImage.setNumColors(3); + cursorImage.setColor(0, 0xff000000); + cursorImage.setColor(1, 0xffffffff); + cursorImage.setColor(2, 0x00000000); + + int bytesPerLine = (width + 7) / 8; + int p = 0; + int d, m; + + int x = -1, w = 0; + + uchar *cursor_data = cursorImage.bits(); + int bpl = cursorImage.bytesPerLine(); + for (int i = 0; i < height; i++) + { + for (int j = 0; j < bytesPerLine; j++, data++, mask++) + { + for (int b = 0; b < 8 && j*8+b < width; b++) + { + d = *data & (1 << b); + m = *mask & (1 << b); + if (d && m) p = 0; + else if (!d && m) p = 1; + else p = 2; + cursor_data[j*8+b] = p; + + // calc region + if (x < 0 && m) + x = j*8+b; + else if (x >= 0 && !m) { + x = -1; + w = 0; + } + if (m) + w++; + } + } + if (x >= 0) { + x = -1; + w = 0; + } + cursor_data += bpl; + } + +} + +/*! + \fn QGraphicsSystemCursorImage::QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + + \brief set the cursor image to the graphic represented by the combination of data, mask, + width, and height + + \a data The pixel data of the graphic + + \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn + + \a width The width of the graphic in pixels + + \a height The height of the graphic in pixels + + \a hotX The X hotspot of the cursor graphic + + \a hotY The Y hotspot of the cursor graphic + + \sa set +*/ + +/*! + \fn QImage *QGraphicsSystemCursorImage::image() + + \brief Return the cursor graphic as a pointer to a QImage +*/ + +/*! + \fn QPoint QGraphicsSystemCursorImage::hotspot() + + \brief Return the cursor's hotspot +*/ + +QT_END_NAMESPACE diff --git a/src/gui/painting/qplatformcursor_qpa.h b/src/gui/painting/qplatformcursor_qpa.h new file mode 100644 index 0000000..bb8bbb7 --- /dev/null +++ b/src/gui/painting/qplatformcursor_qpa.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QGRAPHICSSYSTEMCURSOR_H +#define QGRAPHICSSYSTEMCURSOR_H + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +// Cursor graphics management +class Q_GUI_EXPORT QPlatformCursorImage { +public: + QPlatformCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + { set(data, mask, width, height, hotX, hotY); } + QImage * image() { return &cursorImage; } + QPoint hotspot() { return hot; } + void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + void set(const QImage * image, int hx, int hy); + void set(Qt::CursorShape); +private: + static void createSystemCursor(int id); + QImage cursorImage; + QPoint hot; +}; + +class QPlatformCursor; + +class QPlatformCursorPrivate { +public: + static QList > getInstances() { return instances; } + static QList > instances; +}; + +class Q_GUI_EXPORT QPlatformCursor : public QObject { +public: + QPlatformCursor(QPlatformScreen *); + + // input methods + virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } + virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0; + +protected: + QPlatformScreen* screen; // Where to request an update + +private: + Q_DECLARE_PRIVATE(QPlatformCursor); + friend void qt_lite_set_cursor(QWidget * w, bool force); + friend class QApplicationPrivate; +}; + +QT_END_NAMESPACE + +#endif // QGRAPHICSSYSTEMCURSOR_H diff --git a/src/plugins/platforms/directfb/qdirectfbcursor.cpp b/src/plugins/platforms/directfb/qdirectfbcursor.cpp index 2edae45..f2c9f35 100644 --- a/src/plugins/platforms/directfb/qdirectfbcursor.cpp +++ b/src/plugins/platforms/directfb/qdirectfbcursor.cpp @@ -3,10 +3,10 @@ QDirectFBCursor::QDirectFBCursor(QPlatformScreen* screen) : - QGraphicsSystemCursor(screen), surface(0) + QPlatformCursor(screen), surface(0) { QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY, &m_layer); - image = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); + image = new QPlatformCursorImage(0, 0, 0, 0, 0, 0); } void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) diff --git a/src/plugins/platforms/directfb/qdirectfbcursor.h b/src/plugins/platforms/directfb/qdirectfbcursor.h index 1566e7c..6aecb16 100644 --- a/src/plugins/platforms/directfb/qdirectfbcursor.h +++ b/src/plugins/platforms/directfb/qdirectfbcursor.h @@ -1,12 +1,12 @@ #ifndef QDIRECTFBCURSOR_H #define QDIRECTFBCURSOR_H -#include +#include #include class QDirectFbScreen; class QDirectFbBlitter; -class QDirectFBCursor : public QGraphicsSystemCursor +class QDirectFBCursor : public QPlatformCursor { public: QDirectFBCursor(QPlatformScreen *screem); @@ -15,7 +15,7 @@ public: private: IDirectFBDisplayLayer * m_layer; IDirectFBSurface * surface; - QGraphicsSystemCursorImage * image; + QPlatformCursorImage * image; QDirectFbBlitter *blitter; }; diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index 213a710..ef7ab02 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -3,17 +3,17 @@ #include #include #include -#include +#include #include -QGraphicsSystemSoftwareCursor::QGraphicsSystemSoftwareCursor(QPlatformScreen *scr) - : QGraphicsSystemCursor(scr), currentRect(QRect()), prevRect(QRect()) +QPlatformSoftwareCursor::QPlatformSoftwareCursor(QPlatformScreen *scr) + : QPlatformCursor(scr), currentRect(QRect()), prevRect(QRect()) { - graphic = new QGraphicsSystemCursorImage(0, 0, 0, 0, 0, 0); + graphic = new QPlatformCursorImage(0, 0, 0, 0, 0, 0); setCursor(Qt::ArrowCursor); } -QRect QGraphicsSystemSoftwareCursor::getCurrentRect() +QRect QPlatformSoftwareCursor::getCurrentRect() { QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(), -graphic->hotspot().y()); @@ -24,7 +24,7 @@ QRect QGraphicsSystemSoftwareCursor::getCurrentRect() } -void QGraphicsSystemSoftwareCursor::pointerEvent(const QMouseEvent & e) +void QPlatformSoftwareCursor::pointerEvent(const QMouseEvent & e) { Q_UNUSED(e); QPoint screenOffset = screen->geometry().topLeft(); @@ -35,7 +35,7 @@ void QGraphicsSystemSoftwareCursor::pointerEvent(const QMouseEvent & e) } } -QRect QGraphicsSystemSoftwareCursor::drawCursor(QPainter & painter) +QRect QPlatformSoftwareCursor::drawCursor(QPainter & painter) { dirty = false; if (currentRect.isNull()) @@ -53,7 +53,7 @@ QRect QGraphicsSystemSoftwareCursor::drawCursor(QPainter & painter) return prevRect; } -QRect QGraphicsSystemSoftwareCursor::dirtyRect() +QRect QPlatformSoftwareCursor::dirtyRect() { if (onScreen) { onScreen = false; @@ -62,22 +62,22 @@ QRect QGraphicsSystemSoftwareCursor::dirtyRect() return QRect(); } -void QGraphicsSystemSoftwareCursor::setCursor(Qt::CursorShape shape) +void QPlatformSoftwareCursor::setCursor(Qt::CursorShape shape) { graphic->set(shape); } -void QGraphicsSystemSoftwareCursor::setCursor(const QImage * image, int hotx, int hoty) +void QPlatformSoftwareCursor::setCursor(const QImage * image, int hotx, int hoty) { graphic->set(image, hotx, hoty); } -void QGraphicsSystemSoftwareCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) +void QPlatformSoftwareCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) { graphic->set(data, mask, width, height, hotX, hotY); } -void QGraphicsSystemSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) +void QPlatformSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) { Q_UNUSED(widget); Qt::CursorShape shape = widgetCursor->shape(); diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index 3b5075d..10f292e 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -16,10 +16,10 @@ class QPainter; class QFbScreen; -class QGraphicsSystemSoftwareCursor : public QGraphicsSystemCursor +class QPlatformSoftwareCursor : public QPlatformCursor { public: - QGraphicsSystemSoftwareCursor(QPlatformScreen * scr); + QPlatformSoftwareCursor(QPlatformScreen * scr); // output methods QRect dirtyRect(); @@ -35,7 +35,7 @@ public: virtual QRect lastPainted() { return prevRect; } protected: - QGraphicsSystemCursorImage * graphic; + QPlatformCursorImage * graphic; private: void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); @@ -142,7 +142,7 @@ public: protected: QList windowStack; QRegion repaintRegion; - QGraphicsSystemSoftwareCursor * cursor; + QPlatformSoftwareCursor * cursor; QTimer redrawTimer; protected slots: diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp index f79f956..437af81 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp @@ -811,7 +811,7 @@ QLinuxFbScreen::QLinuxFbScreen(uchar * d, int w, mFormat); mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(), bytesPerLine, mFormat); - cursor = new QGraphicsSystemSoftwareCursor(this); + cursor = new QPlatformSoftwareCursor(this); } void QLinuxFbScreen::setGeometry(QRect rect) diff --git a/src/plugins/platforms/testlite/qtestliteintegration.cpp b/src/plugins/platforms/testlite/qtestliteintegration.cpp index 46f2384..3f500c0 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.cpp +++ b/src/plugins/platforms/testlite/qtestliteintegration.cpp @@ -46,7 +46,7 @@ #include #include -#include +#include #include "qtestlitewindow.h" @@ -59,10 +59,10 @@ QT_BEGIN_NAMESPACE -class MyCursor : QGraphicsSystemCursor +class MyCursor : QPlatformCursor { public: - MyCursor(QPlatformScreen *screen) : QGraphicsSystemCursor(screen) {} + MyCursor(QPlatformScreen *screen) : QPlatformCursor(screen) {} void changeCursor(QCursor * cursor, QWidget * widget) { QTestLiteWindow *w = 0; diff --git a/src/plugins/platforms/vnc/qvnccursor.cpp b/src/plugins/platforms/vnc/qvnccursor.cpp index 72dcb25..e83696d 100644 --- a/src/plugins/platforms/vnc/qvnccursor.cpp +++ b/src/plugins/platforms/vnc/qvnccursor.cpp @@ -54,13 +54,13 @@ QT_BEGIN_NAMESPACE QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCScreen *scr ) - :QGraphicsSystemSoftwareCursor(scr), useVncCursor(false), server(srvr) + :QPlatformSoftwareCursor(scr), useVncCursor(false), server(srvr) { } void QVNCCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) { - QGraphicsSystemSoftwareCursor::changeCursor(widgetCursor, widget); + QPlatformSoftwareCursor::changeCursor(widgetCursor, widget); if (useVncCursor) { server->setDirtyCursor(); } else { @@ -84,7 +84,7 @@ QRect QVNCCursor::drawCursor(QPainter & painter) if (useVncCursor) return QRect(); - return QGraphicsSystemSoftwareCursor::drawCursor(painter); + return QPlatformSoftwareCursor::drawCursor(painter); } void QVNCCursor::clearClientCursor() diff --git a/src/plugins/platforms/vnc/qvnccursor.h b/src/plugins/platforms/vnc/qvnccursor.h index 2c6ff5b..eeb3686 100644 --- a/src/plugins/platforms/vnc/qvnccursor.h +++ b/src/plugins/platforms/vnc/qvnccursor.h @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE class QVNCScreen; class QVNCServer; -class QVNCCursor : public QGraphicsSystemSoftwareCursor { +class QVNCCursor : public QPlatformSoftwareCursor { public: QVNCCursor(QVNCServer *, QVNCScreen *); -- cgit v0.12 From 13cc79de7b96cfe367869a748d07d502997d0342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 24 Jun 2010 14:41:17 +0200 Subject: Refactored classes and functions using lite --- src/gui/kernel/kernel.pri | 6 +++--- src/gui/kernel/qapplication.cpp | 9 ++++----- src/gui/kernel/qapplication_p.h | 4 ++-- src/gui/kernel/qapplication_qpa.cpp | 12 ++++++------ src/gui/kernel/qdesktopwidget_qpa_p.h | 6 +++--- src/gui/kernel/qeventdispatcher_glib_qpa.cpp | 16 ++++++++-------- src/gui/kernel/qeventdispatcher_glib_qpa_p.h | 22 +++++++++++----------- src/gui/kernel/qeventdispatcher_qpa.cpp | 26 +++++++++++++------------- src/gui/kernel/qeventdispatcher_qpa_p.h | 16 ++++++++-------- src/gui/kernel/qgenericplugin_qpa.cpp | 6 +++--- src/gui/kernel/qgenericplugin_qpa.h | 6 +++--- src/gui/kernel/qgenericpluginfactory_qpa.cpp | 6 +++--- src/gui/kernel/qgenericpluginfactory_qpa.h | 6 +++--- src/gui/kernel/qwidget_qpa.cpp | 6 +++--- src/gui/kernel/qwindowsysteminterface.cpp | 2 +- src/gui/painting/qplatformcursor_qpa.h | 2 +- 16 files changed, 75 insertions(+), 76 deletions(-) diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 965cbe3..f773906 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -48,8 +48,7 @@ HEADERS += \ kernel/qgesturemanager_p.h \ kernel/qsoftkeymanager_p.h \ kernel/qsoftkeymanager_common_p.h \ - kernel/qguiplatformplugin_p.h \ - kernel/qdesktopwidget_qpa_p.h + kernel/qguiplatformplugin_p.h SOURCES += \ kernel/qaction.cpp \ @@ -215,7 +214,8 @@ qpa { kernel/qplatformintegrationfactory_qpa_p.h \ kernel/qplatformintegrationplugin_qpa.h \ kernel/qplatformwindow_qpa.h \ - kernel/qplatformglcontext_qpa.h + kernel/qplatformglcontext_qpa.h \ + kernel/qdesktopwidget_qpa_p.h SOURCES += \ kernel/qapplication_qpa.cpp \ diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index b3e6fcd..e1ed588 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -927,8 +927,7 @@ void QApplicationPrivate::initialize() // initialize the graphics system - on X11 this is initialized inside // qt_init() in qapplication_x11.cpp because of several reasons. // On QWS, the graphics system is set by the QScreen plugin. - // For lighthouse it will be initialized to QLiteGraphicsSystem - // when the platformIntegration plugin is instansiated in qt_init( + // We don't use graphics systems in Qt QPA graphics_system = QGraphicsSystemFactory::create(graphics_system_name); #endif @@ -2763,9 +2762,9 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { qt_x11_enforce_cursor(parentOfLeavingCursor,true); #elif defined(Q_WS_QPA) if (enter == QApplication::desktop()) { - qt_lite_set_cursor(enter, true); + qt_qpa_set_cursor(enter, true); } else { - qt_lite_set_cursor(parentOfLeavingCursor, true); + qt_qpa_set_cursor(parentOfLeavingCursor, true); } #endif } @@ -2792,7 +2791,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { #elif defined(Q_WS_S60) qt_symbian_set_cursor(cursorWidget, true); #elif defined(Q_WS_QPA) - qt_lite_set_cursor(cursorWidget, true); + qt_qpa_set_cursor(cursorWidget, true); #endif } } diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 7d98f4d..68ec648 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -328,7 +328,7 @@ public: static QPlatformIntegration *platformIntegration() { return platform_integration; } - static QAbstractEventDispatcher *qt_lite_core_dispatcher() + static QAbstractEventDispatcher *qt_qpa_core_dispatcher() { return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; } #endif @@ -661,7 +661,7 @@ Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, #elif defined(Q_OS_SYMBIAN) extern void qt_symbian_set_cursor(QWidget *, bool); #elif defined (Q_WS_QPA) - extern void qt_lite_set_cursor(QWidget *, bool); + extern void qt_qpa_set_cursor(QWidget *, bool); #endif QT_END_NAMESPACE diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index 1fc202c..2adcfc1 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -123,10 +123,10 @@ void QApplicationPrivate::createEventDispatcher() Q_Q(QApplication); #if !defined(QT_NO_GLIB) if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported()) - eventDispatcher = new QLiteEventDispatcherGlib(q); + eventDispatcher = new QPAEventDispatcherGlib(q); else #endif - eventDispatcher = new QEventDispatcherLite(q); + eventDispatcher = new QEventDispatcherQPA(q); } static bool qt_try_modal(QWidget *widget, QEvent::Type type) @@ -378,7 +378,7 @@ bool QApplication::isEffectEnabled(Qt::UIEffect effect) void QApplication::setOverrideCursor(const QCursor &cursor) { qApp->d_func()->cursor_list.prepend(cursor); - qt_lite_set_cursor(0, false); + qt_qpa_set_cursor(0, false); } void QApplication::restoreOverrideCursor() @@ -386,7 +386,7 @@ void QApplication::restoreOverrideCursor() if (qApp->d_func()->cursor_list.isEmpty()) return; qApp->d_func()->cursor_list.removeFirst(); - qt_lite_set_cursor(0, false); + qt_qpa_set_cursor(0, false); } #endif// QT_NO_CURSOR @@ -490,7 +490,7 @@ void qt_init(QApplicationPrivate *priv, int type) } QList pluginList; - QString platformName = qgetenv("QT_LITE_PLATFORM"); + QString platformName = qgetenv("QT_QPA_PLATFORM"); // Get command line params @@ -521,7 +521,7 @@ void qt_init(QApplicationPrivate *priv, int type) } #if 0 - QByteArray pluginEnv = qgetenv("QT_LITE_PLUGINS"); + QByteArray pluginEnv = qgetenv("QT_QPA_PLUGINS"); if (!pluginEnv.isEmpty()) { pluginList.append(pluginEnv.split(';')); } diff --git a/src/gui/kernel/qdesktopwidget_qpa_p.h b/src/gui/kernel/qdesktopwidget_qpa_p.h index 33e4c98..8bed09d 100644 --- a/src/gui/kernel/qdesktopwidget_qpa_p.h +++ b/src/gui/kernel/qdesktopwidget_qpa_p.h @@ -50,8 +50,8 @@ // We mean it. // -#ifndef QDESKTOPWIDGET_LITE_P_H -#define QDESKTOPWIDGET_LITE_P_H +#ifndef QDESKTOPWIDGET_QPA_P_H +#define QDESKTOPWIDGET_QPA_P_H #include "QDesktopWidget" #include "private/qwidget_p.h" @@ -73,4 +73,4 @@ public: QDesktopScreenWidget virtualScreen; }; -#endif // QDESKTOPWIDGET_LITE_P_H +#endif // QDESKTOPWIDGET_QPA_P_H diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp index f45902c..9585b26 100644 --- a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp +++ b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE struct GUserEventSource { GSource source; - QLiteEventDispatcherGlib *q; + QPAEventDispatcherGlib *q; }; static gboolean userEventSourcePrepare(GSource *s, gint *timeout) @@ -104,7 +104,7 @@ static GSourceFuncs userEventSourceFuncs = { NULL }; -QLiteEventDispatcherGlibPrivate::QLiteEventDispatcherGlibPrivate(GMainContext *context) +QPAEventDispatcherGlibPrivate::QPAEventDispatcherGlibPrivate(GMainContext *context) : QEventDispatcherGlibPrivate(context) { userEventSource = reinterpret_cast(g_source_new(&userEventSourceFuncs, @@ -115,23 +115,23 @@ QLiteEventDispatcherGlibPrivate::QLiteEventDispatcherGlibPrivate(GMainContext *c } -QLiteEventDispatcherGlib::QLiteEventDispatcherGlib(QObject *parent) - : QEventDispatcherGlib(*new QLiteEventDispatcherGlibPrivate, parent) +QPAEventDispatcherGlib::QPAEventDispatcherGlib(QObject *parent) + : QEventDispatcherGlib(*new QPAEventDispatcherGlibPrivate, parent) { - Q_D(QLiteEventDispatcherGlib); + Q_D(QPAEventDispatcherGlib); d->userEventSource->q = this; } -QLiteEventDispatcherGlib::~QLiteEventDispatcherGlib() +QPAEventDispatcherGlib::~QPAEventDispatcherGlib() { - Q_D(QLiteEventDispatcherGlib); + Q_D(QPAEventDispatcherGlib); g_source_destroy(&d->userEventSource->source); g_source_unref(&d->userEventSource->source); d->userEventSource = 0; } -bool QLiteEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags) +bool QPAEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags) { return QEventDispatcherGlib::processEvents(flags); } diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa_p.h b/src/gui/kernel/qeventdispatcher_glib_qpa_p.h index 6ebdb25..1c32ab2 100644 --- a/src/gui/kernel/qeventdispatcher_glib_qpa_p.h +++ b/src/gui/kernel/qeventdispatcher_glib_qpa_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QLITEEVENTDISPATCHER_GLIB_P_H -#define QLITEEVENTDISPATCHER_GLIB_P_H +#ifndef QEVENTDISPATCHER_GLIB_QPA_P_H +#define QEVENTDISPATCHER_GLIB_QPA_P_H // // W A R N I N G @@ -58,31 +58,31 @@ typedef struct _GMainContext GMainContext; QT_BEGIN_NAMESPACE -class QLiteEventDispatcherGlibPrivate; +class QPAEventDispatcherGlibPrivate; -class QLiteEventDispatcherGlib : public QEventDispatcherGlib +class QPAEventDispatcherGlib : public QEventDispatcherGlib { Q_OBJECT - Q_DECLARE_PRIVATE(QLiteEventDispatcherGlib) + Q_DECLARE_PRIVATE(QPAEventDispatcherGlib) public: - explicit QLiteEventDispatcherGlib(QObject *parent = 0); - ~QLiteEventDispatcherGlib(); + explicit QPAEventDispatcherGlib(QObject *parent = 0); + ~QPAEventDispatcherGlib(); bool processEvents(QEventLoop::ProcessEventsFlags flags); }; struct GUserEventSource; -class QLiteEventDispatcherGlibPrivate : public QEventDispatcherGlibPrivate +class QPAEventDispatcherGlibPrivate : public QEventDispatcherGlibPrivate { - Q_DECLARE_PUBLIC(QLiteEventDispatcherGlib) + Q_DECLARE_PUBLIC(QPAEventDispatcherGlib) public: - QLiteEventDispatcherGlibPrivate(GMainContext *context = 0); + QPAEventDispatcherGlibPrivate(GMainContext *context = 0); GUserEventSource *userEventSource; }; QT_END_NAMESPACE -#endif // QLITEEVENTDISPATCHER_GLIB_P_H +#endif // QEVENTDISPATCHER_GLIB_QPA_P_H diff --git a/src/gui/kernel/qeventdispatcher_qpa.cpp b/src/gui/kernel/qeventdispatcher_qpa.cpp index c6b5636..5740548 100644 --- a/src/gui/kernel/qeventdispatcher_qpa.cpp +++ b/src/gui/kernel/qeventdispatcher_qpa.cpp @@ -54,29 +54,29 @@ QT_BEGIN_NAMESPACE QT_USE_NAMESPACE -class QEventDispatcherLitePrivate : public QEventDispatcherUNIXPrivate +class QEventDispatcherQPAPrivate : public QEventDispatcherUNIXPrivate { - Q_DECLARE_PUBLIC(QEventDispatcherLite) + Q_DECLARE_PUBLIC(QEventDispatcherQPA) public: - inline QEventDispatcherLitePrivate() + inline QEventDispatcherQPAPrivate() { } }; -QEventDispatcherLite::QEventDispatcherLite(QObject *parent) - : QEventDispatcherUNIX(*new QEventDispatcherLitePrivate, parent) +QEventDispatcherQPA::QEventDispatcherQPA(QObject *parent) + : QEventDispatcherUNIX(*new QEventDispatcherQPAPrivate, parent) { } -QEventDispatcherLite::~QEventDispatcherLite() +QEventDispatcherQPA::~QEventDispatcherQPA() { } //#define ZERO_FOR_THE_MOMENT -bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags) +bool QEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags) { - Q_D(QEventDispatcherLite); + Q_D(QEventDispatcherQPA); int nevents = 0; // handle gui and posted events @@ -112,30 +112,30 @@ bool QEventDispatcherLite::processEvents(QEventLoop::ProcessEventsFlags flags) return (nevents > 0); } -bool QEventDispatcherLite::hasPendingEvents() +bool QEventDispatcherQPA::hasPendingEvents() { extern uint qGlobalPostedEventsCount(); // from qapplication.cpp return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::userEventsQueued();; } -void QEventDispatcherLite::startingUp() +void QEventDispatcherQPA::startingUp() { } -void QEventDispatcherLite::closingDown() +void QEventDispatcherQPA::closingDown() { } -void QEventDispatcherLite::flush() +void QEventDispatcherQPA::flush() { if(qApp) qApp->sendPostedEvents(); } -int QEventDispatcherLite::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, +int QEventDispatcherQPA::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, timeval *timeout) { return QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout); diff --git a/src/gui/kernel/qeventdispatcher_qpa_p.h b/src/gui/kernel/qeventdispatcher_qpa_p.h index c098e6c..878daaa 100644 --- a/src/gui/kernel/qeventdispatcher_qpa_p.h +++ b/src/gui/kernel/qeventdispatcher_qpa_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QEVENTDISPATCHER_LITE_P_H -#define QEVENTDISPATCHER_LITE_P_H +#ifndef QEVENTDISPATCHER_QPA_P_H +#define QEVENTDISPATCHER_QPA_P_H // // W A R N I N G @@ -57,16 +57,16 @@ QT_BEGIN_NAMESPACE -class QEventDispatcherLitePrivate; +class QEventDispatcherQPAPrivate; -class QEventDispatcherLite : public QEventDispatcherUNIX +class QEventDispatcherQPA : public QEventDispatcherUNIX { Q_OBJECT - Q_DECLARE_PRIVATE(QEventDispatcherLite) + Q_DECLARE_PRIVATE(QEventDispatcherQPA) public: - explicit QEventDispatcherLite(QObject *parent = 0); - ~QEventDispatcherLite(); + explicit QEventDispatcherQPA(QObject *parent = 0); + ~QEventDispatcherQPA(); bool processEvents(QEventLoop::ProcessEventsFlags flags); bool hasPendingEvents(); @@ -83,4 +83,4 @@ protected: QT_END_NAMESPACE -#endif // QEVENTDISPATCHER_LITE_P_H +#endif // QEVENTDISPATCHER_QPA_P_H diff --git a/src/gui/kernel/qgenericplugin_qpa.cpp b/src/gui/kernel/qgenericplugin_qpa.cpp index 6290b40..43d6525 100644 --- a/src/gui/kernel/qgenericplugin_qpa.cpp +++ b/src/gui/kernel/qgenericplugin_qpa.cpp @@ -48,12 +48,12 @@ QT_BEGIN_NAMESPACE /*! \class QGenericPlugin \ingroup plugins - \ingroup lite + \ingroup qpa \brief The QGenericPlugin class is an abstract base class for - window-system related plugins in Qt for Embedded Linux LITE. + window-system related plugins in Qt QPA. - Note that this class is only available in \l{Qt for Embedded Linux LITE}. + Note that this class is only available in \l{Qt QPA}. A mouse plugin can be created by subclassing QGenericPlugin and reimplementing the pure virtual keys() and diff --git a/src/gui/kernel/qgenericplugin_qpa.h b/src/gui/kernel/qgenericplugin_qpa.h index a468a9f..e1792cd 100644 --- a/src/gui/kernel/qgenericplugin_qpa.h +++ b/src/gui/kernel/qgenericplugin_qpa.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QGENERICPLUGIN_LITE_H -#define QGENERICPLUGIN_LITE_H +#ifndef QGENERICPLUGIN_QPA_H +#define QGENERICPLUGIN_QPA_H #include #include @@ -81,4 +81,4 @@ QT_END_NAMESPACE QT_END_HEADER -#endif // QMOUSEDRIVERPLUGIN_QWS_H +#endif // QGENERICPLUGIN_QPA_H diff --git a/src/gui/kernel/qgenericpluginfactory_qpa.cpp b/src/gui/kernel/qgenericpluginfactory_qpa.cpp index dcc7cc7..abc575a 100644 --- a/src/gui/kernel/qgenericpluginfactory_qpa.cpp +++ b/src/gui/kernel/qgenericpluginfactory_qpa.cpp @@ -60,12 +60,12 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, /*! \class QGenericPluginFactory - \ingroup qws + \ingroup qpa \brief The QGenericPluginFactory class creates window-system - related plugin drivers in Qt for Embedded Linux LITE. + related plugin drivers in Qt QPA. - Note that this class is only available in \l{Qt for Embedded Linux LITE}. + Note that this class is only available in \l{Qt QPA}. \sa QGenericPlugin diff --git a/src/gui/kernel/qgenericpluginfactory_qpa.h b/src/gui/kernel/qgenericpluginfactory_qpa.h index 86886f1..59eac38 100644 --- a/src/gui/kernel/qgenericpluginfactory_qpa.h +++ b/src/gui/kernel/qgenericpluginfactory_qpa.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QGENERICPLUGINFACTORY_LITE_H -#define QGENERICPLUGINFACTORY_LITE_H +#ifndef QGENERICPLUGINFACTORY_QPA_H +#define QGENERICPLUGINFACTORY_QPA_H #include @@ -64,4 +64,4 @@ QT_END_NAMESPACE QT_END_HEADER -#endif // QGENERICPLUGINFACTORY_QWS_H +#endif // QGENERICPLUGINFACTORY_QPA_H diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index a543c8f..8bb3f38 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -246,14 +246,14 @@ void QWidgetPrivate::setCursor_sys(const QCursor &cursor) Q_UNUSED(cursor); Q_Q(QWidget); if (q->isVisible()) - qt_lite_set_cursor(q, false); + qt_qpa_set_cursor(q, false); } void QWidgetPrivate::unsetCursor_sys() { Q_Q(QWidget); if (q->isVisible()) - qt_lite_set_cursor(q, false); + qt_qpa_set_cursor(q, false); } void QWidgetPrivate::updateCursor() const @@ -753,7 +753,7 @@ void QWidgetPrivate::setModal_sys() } #ifndef QT_NO_CURSOR -void qt_lite_set_cursor(QWidget * w, bool force) +void qt_qpa_set_cursor(QWidget * w, bool force) { static QCursor arrowCursor(Qt::ArrowCursor); static QPointer lastUnderMouse = 0; diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index c9d177d..4cf9ded 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -129,7 +129,7 @@ void QWindowSystemInterfacePrivate::queueUserEvent(QWindowSystemInterface::UserE userEventQueue.append(ev); queueMutex.unlock(); - QAbstractEventDispatcher *dispatcher = QApplicationPrivate::qt_lite_core_dispatcher(); + QAbstractEventDispatcher *dispatcher = QApplicationPrivate::qt_qpa_core_dispatcher(); if (dispatcher) dispatcher->wakeUp(); } diff --git a/src/gui/painting/qplatformcursor_qpa.h b/src/gui/painting/qplatformcursor_qpa.h index bb8bbb7..5f1654d 100644 --- a/src/gui/painting/qplatformcursor_qpa.h +++ b/src/gui/painting/qplatformcursor_qpa.h @@ -88,7 +88,7 @@ protected: private: Q_DECLARE_PRIVATE(QPlatformCursor); - friend void qt_lite_set_cursor(QWidget * w, bool force); + friend void qt_qpa_set_cursor(QWidget * w, bool force); friend class QApplicationPrivate; }; -- cgit v0.12 From bd337d251a3ff54c6845f1c4469ec7c99068971e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 24 Jun 2010 15:03:26 +0200 Subject: Removed QGraphicsSystem include from QPlatformIntegration --- src/gui/kernel/qplatformintegration_qpa.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h index f80b0ae..ea0ed35 100644 --- a/src/gui/kernel/qplatformintegration_qpa.h +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -42,19 +42,24 @@ #ifndef QPLATFORMINTEGRATION_H #define QPLATFORMINTEGRATION_H -#include +#include +#include #include QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(Gui) +//QT_MODULE(Gui) +class QPlatformWindow; +class QWindowSurface; +class QBlittable; +class QWidget; class Q_GUI_EXPORT QPlatformIntegration { public: - virtual ~QPlatformIntegration() { }; + virtual ~QPlatformIntegration() { } // GraphicsSystem functions virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; @@ -69,6 +74,7 @@ public: virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; virtual bool hasOpenGL() const; + }; QT_END_NAMESPACE -- cgit v0.12 From d879c51dea3521d36a2f47e2406a99386f442254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 24 Jun 2010 15:50:16 +0200 Subject: Compile fix for testlite plugin --- src/plugins/platforms/testlite/qtestliteintegration.h | 3 +++ src/plugins/platforms/testlite/qtestlitewindow.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/src/plugins/platforms/testlite/qtestliteintegration.h b/src/plugins/platforms/testlite/qtestliteintegration.h index 01d428c..ac10841 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.h +++ b/src/plugins/platforms/testlite/qtestliteintegration.h @@ -45,6 +45,9 @@ #include #include +//make sure textstream is included before any X11 headers +#include + QT_BEGIN_NAMESPACE class MyDisplay; diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index 82e64e6..0f6c921 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -41,6 +41,7 @@ #include "qtestliteintegration.h" #include +#include #include "qtestlitewindow.h" -- cgit v0.12 From 38e29c10cfdee145cb5e56f789f2b156a7ae3b35 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 29 Jun 2010 10:21:35 +0200 Subject: Compile after _qpa renaming --- src/plugins/generic/linuxinput/main.cpp | 2 +- src/plugins/generic/tslib/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/generic/linuxinput/main.cpp b/src/plugins/generic/linuxinput/main.cpp index 25e80eb..dc05254 100644 --- a/src/plugins/generic/linuxinput/main.cpp +++ b/src/plugins/generic/linuxinput/main.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include +#include #include "qlinuxinput.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/generic/tslib/main.cpp b/src/plugins/generic/tslib/main.cpp index 4e8e50a..502c6a0 100644 --- a/src/plugins/generic/tslib/main.cpp +++ b/src/plugins/generic/tslib/main.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include +#include #include "qtslib.h" QT_BEGIN_NAMESPACE -- cgit v0.12 From 9cc54422943c0fc662b7b0c9a0d10565f7f6e73b Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 30 Jun 2010 11:09:25 +0200 Subject: check for a null new parent before trying to access its platformWindow This fixes a crash seen in the arora browser when exiting --- src/gui/kernel/qwidget_qpa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index 8bb3f38..1acf398 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -161,7 +161,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) if (parent != newparent) { QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? - if (q->platformWindow()) { + if (q->platformWindow() && newparent) { QWidget * parentWithWindow = newparent->platformWindow()? newparent : newparent->nativeParentWidget(); if (parentWithWindow && parentWithWindow->platformWindow()) { q->platformWindow()->setParent(parentWithWindow->platformWindow()); -- cgit v0.12 From d7168ae0ff930f19f206a1b56c03fc35b22bb948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 7 Jul 2010 15:09:35 +0200 Subject: Never compile lighthouse with EGL support it should reside in the plugin, not in the opengl module nor in gui --- configure | 5 +++++ src/gui/kernel/qplatformglcontext_qpa.h | 5 +---- src/opengl/opengl.pro | 2 -- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 23aa101..a57f6ce 100755 --- a/configure +++ b/configure @@ -6636,6 +6636,11 @@ else QT_CONFIG="$QT_CONFIG accessibility" fi +# egl stuff does not belong in lighthouse, but rather in plugins +if [ "$PLATFORM_QPA" = "yes" ]; then + CFG_EGL="no" +fi + # enable egl if [ "$CFG_EGL" = "no" ]; then QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_EGL" diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h index 8aeb635..dcfd54c 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.h +++ b/src/gui/kernel/qplatformglcontext_qpa.h @@ -51,10 +51,7 @@ QT_BEGIN_NAMESPACE class Q_OPENGL_EXPORT QPlatformGLContext { public: - //QPlatformGLContext(); - //virtual ~QPlatformGLContext(); - - //virtual bool create(QPaintDevice* device, QPlatformGLContext* shareContext) = 0; + virtual ~QPlatformGLContext() { } virtual void makeCurrent() = 0; virtual void doneCurrent() = 0; diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 09a6b0f..772c27f 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -78,8 +78,6 @@ SOURCES += qgl.cpp \ } qpa { - DEFINES += QT_NO_EGL - SOURCES += qgl_qpa.cpp \ qglpixelbuffer_stub.cpp } -- cgit v0.12 From 8ede118779b0b4cde591f3bf5ec94f7a6f25e2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 7 Jul 2010 15:11:01 +0200 Subject: Make openkode work with new interfaces and moved egl stuff into plugin --- .../platforms/openkode/qopenkodeglintegration.cpp | 189 ++++----------------- .../platforms/openkode/qopenkodeglintegration.h | 14 +- .../platforms/openkode/qopenkodeintegration.cpp | 41 ++++- .../platforms/openkode/qopenkodeintegration.h | 9 +- src/plugins/platforms/openkode/qopenkodewindow.cpp | 160 ++++++++++++++--- src/plugins/platforms/openkode/qopenkodewindow.h | 14 +- .../platforms/openkode/qopenkodewindowsurface.cpp | 39 ++--- .../platforms/openkode/qopenkodewindowsurface.h | 8 +- 8 files changed, 239 insertions(+), 235 deletions(-) diff --git a/src/plugins/platforms/openkode/qopenkodeglintegration.cpp b/src/plugins/platforms/openkode/qopenkodeglintegration.cpp index 7223538..4296876 100644 --- a/src/plugins/platforms/openkode/qopenkodeglintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeglintegration.cpp @@ -40,198 +40,69 @@ ****************************************************************************/ #include "qopenkodeglintegration.h" + +#include + #include #include #include #include -#include -void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLFormat& glFormat) +QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi) + : m_eglDisplay(display) + , m_eglSurface(surface) + , m_eglApi(eglApi) { - int redSize = glFormat.redBufferSize(); - int greenSize = glFormat.greenBufferSize(); - int blueSize = glFormat.blueBufferSize(); - int alphaSize = glFormat.alphaBufferSize(); - int depthSize = glFormat.depthBufferSize(); - int stencilSize = glFormat.stencilBufferSize(); - int sampleCount = glFormat.samples(); - - // QGLFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that - // type has been requested. So we must check QGLFormat's booleans too if size is -1: - if (glFormat.alpha() && alphaSize <= 0) - alphaSize = 1; - if (glFormat.depth() && depthSize <= 0) - depthSize = 1; - if (glFormat.stencil() && stencilSize <= 0) - stencilSize = 1; - if (glFormat.sampleBuffers() && sampleCount <= 0) - sampleCount = 1; - - // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide - // the best performance. The EGL config selection algorithm is a bit stange in this regard: - // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard - // 32-bit configs completely from the selection. So it then comes to the sorting algorithm. - // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort - // order is special and described as "by larger _total_ number of color bits.". So EGL will - // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on - // to say "If the requested number of bits in attrib_list for a particular component is 0, - // then the number of bits for that component is not considered". This part of the spec also - // seems to imply that setting the red/green/blue bits to zero means none of the components - // are considered and EGL disregards the entire sorting rule. It then looks to the next - // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being - // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are - // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit, - // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that - // if the application sets the red/green/blue size to 5/6/5 on the QGLFormat, they will - // probably get a 32-bit config, even when there's an RGB565 config avaliable. Oh well. - - // Now normalize the values so -1 becomes 0 - redSize = redSize > 0 ? redSize : 0; - greenSize = greenSize > 0 ? greenSize : 0; - blueSize = blueSize > 0 ? blueSize : 0; - alphaSize = alphaSize > 0 ? alphaSize : 0; - depthSize = depthSize > 0 ? depthSize : 0; - stencilSize = stencilSize > 0 ? stencilSize : 0; - sampleCount = sampleCount > 0 ? sampleCount : 0; - - eglProperties.setValue(EGL_RED_SIZE, redSize); - eglProperties.setValue(EGL_GREEN_SIZE, greenSize); - eglProperties.setValue(EGL_BLUE_SIZE, blueSize); - eglProperties.setValue(EGL_ALPHA_SIZE, alphaSize); - eglProperties.setValue(EGL_DEPTH_SIZE, depthSize); - eglProperties.setValue(EGL_STENCIL_SIZE, stencilSize); - eglProperties.setValue(EGL_SAMPLES, sampleCount); - eglProperties.setValue(EGL_SAMPLE_BUFFERS, sampleCount ? 1 : 0); -} - -// Updates "format" with the parameters of the selected configuration. -void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config) -{ - EGLint redSize = 0; - EGLint greenSize = 0; - EGLint blueSize = 0; - EGLint alphaSize = 0; - EGLint depthSize = 0; - EGLint stencilSize = 0; - EGLint sampleCount = 0; - EGLint level = 0; - - EGLDisplay display = QEgl::display(); - eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize); - eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize); - eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize); - eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize); - eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize); - eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize); - eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount); - eglGetConfigAttrib(display, config, EGL_LEVEL, &level); - - format.setRedBufferSize(redSize); - format.setGreenBufferSize(greenSize); - format.setBlueBufferSize(blueSize); - format.setAlphaBufferSize(alphaSize); - format.setDepthBufferSize(depthSize); - format.setStencilBufferSize(stencilSize); - format.setSamples(sampleCount); - format.setPlane(level + 1); // EGL calls level 0 "normal" whereas Qt calls 1 "normal" - format.setDirectRendering(true); // All EGL contexts are direct-rendered - format.setRgba(true); // EGL doesn't support colour index rendering - format.setStereo(false); // EGL doesn't support stereo buffers - format.setAccumBufferSize(0); // EGL doesn't support accululation buffers - - // Clear the EGL error state because some of the above may - // have errored out because the attribute is not applicable - // to the surface type. Such errors don't matter. - eglGetError(); -} + if (m_eglSurface == EGL_NO_SURFACE) { + qWarning("Createing QEGLPlatformContext with no surface"); + } -QEGLPlatformContext::QEGLPlatformContext() -{ + eglBindAPI(m_eglApi); + m_eglContext = eglCreateContext(m_eglDisplay,config, KD_NULL,contextAttrs); + if (!m_eglContext) { + qErrnoWarning("QEGLPlatformContext could not create eglContext"); + } } QEGLPlatformContext::~QEGLPlatformContext() { if (m_eglSurface != EGL_NO_SURFACE) { doneCurrent(); - eglDestroySurface(QEgl::display(), m_eglSurface); + eglDestroySurface(m_eglDisplay, m_eglSurface); m_eglSurface = EGL_NO_SURFACE; } - if (m_context != EGL_NO_CONTEXT) { - eglDestroyContext(QEgl::display(), m_context); - m_context = EGL_NO_CONTEXT; - } -} - -bool QEGLPlatformContext::create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext) -{ - QEglProperties properties; - properties.setValue(EGL_CONTEXT_CLIENT_VERSION, 2); - //lets go with all defaults :) Seems like we get bad attributes for anything else - //qt_eglproperties_set_glformat(properties,format); - format.setDepthBufferSize(1); - EGLConfig config = QEgl::defaultConfig(device->devType(), QEgl::OpenGL,QEgl::Renderable); - QEGLPlatformContext *eglShareContext = static_cast(shareContext); - if (shareContext && eglShareContext->m_context != EGL_NO_CONTEXT) { - m_context = eglCreateContext(QEgl::display(), config, eglShareContext->m_context, properties.properties()); - if (m_context == EGL_NO_CONTEXT) { - qWarning() << "QEglContext::createContext(): Could not share context:" << QEgl::errorString(); - shareContext = 0; - } - } else { - m_context = eglCreateContext(QEgl::display(), config, EGL_NO_CONTEXT, properties.properties()); - if (m_context == EGL_NO_CONTEXT) { - qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << QEgl::errorString(); - return false; - } + if (m_eglContext != EGL_NO_CONTEXT) { + eglDestroyContext(m_eglDisplay, m_eglContext); + m_eglContext = EGL_NO_CONTEXT; } - //Get/create the EGLSurface - if (device && device->devType() == QInternal::Widget){ - QWidget* widget = static_cast(device); - QGLWidget* glWidget = qobject_cast(widget); - - if (!widget->isTopLevel()) { - qWarning("Creating a GL context is only supported on top-level QWidgets"); - return false; - } - EGLNativeWindowType winId = (EGLNativeWindowType) widget->window()->winId(); - - m_eglSurface = eglCreateWindowSurface(QEgl::display(), config, winId, 0); - makeCurrent(); - glClearColor(0.0, 0.0, 0.0, 1.0); - swapBuffers(); - - - } else { - qDebug() << "QEGLPlatformContext::create: didn't create surface!!!!!"; - } - return true; - } void QEGLPlatformContext::makeCurrent() { - eglBindAPI(EGL_OPENGL_API); - bool ok = eglMakeCurrent(QEgl::display(), m_eglSurface, m_eglSurface, m_context); + eglBindAPI(m_eglApi); + bool ok = eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext); if (!ok) - qWarning() << "QEGLPlatformContext::makeCurrent(" << m_eglSurface << "):" << QEgl::errorString(); + qWarning() << "QEGLPlatformContext::makeCurrent(" << m_eglSurface << "):" << eglGetError(); } void QEGLPlatformContext::doneCurrent() { - eglBindAPI(EGL_OPENGL_ES_API); - bool ok = eglMakeCurrent(QEgl::display(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglBindAPI(m_eglApi); + bool ok = eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (!ok) - qWarning() << "QEGLPlatformContext::doneCurrent():" << QEgl::errorString(); + qWarning() << "QEGLPlatformContext::doneCurrent():" << eglGetError(); } void QEGLPlatformContext::swapBuffers() { - bool ok = eglSwapBuffers(QEgl::display(), m_eglSurface); + eglBindAPI(m_eglApi); + bool ok = eglSwapBuffers(m_eglDisplay, m_eglSurface); if (!ok) - qWarning() << "QEGLPlatformContext::swapBuffers():" << QEgl::errorString(); + qWarning() << "QEGLPlatformContext::swapBuffers():" << eglGetError(); } void* QEGLPlatformContext::getProcAddress(const QString& procName) { - eglGetProcAddress(qPrintable(procName)); + eglBindAPI(m_eglApi); + return (void *)eglGetProcAddress(qPrintable(procName)); } diff --git a/src/plugins/platforms/openkode/qopenkodeglintegration.h b/src/plugins/platforms/openkode/qopenkodeglintegration.h index b0b7a48..19d155a 100644 --- a/src/plugins/platforms/openkode/qopenkodeglintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeglintegration.h @@ -42,29 +42,25 @@ #ifndef QOPENKODEGLINTEGRATION_H #define QOPENKODEGLINTEGRATION_H -#include -#include +#include #include -void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLFormat& glFormat); -// Updates "format" with the parameters of the selected configuration. -void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config); - class QEGLPlatformContext : public QPlatformGLContext { public: - QEGLPlatformContext(); + QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi); ~QEGLPlatformContext(); - bool create(QPaintDevice* device, QGLFormat& format, QPlatformGLContext* shareContext); void makeCurrent(); void doneCurrent(); void swapBuffers(); void* getProcAddress(const QString& procName); private: - EGLContext m_context; + EGLContext m_eglContext; + EGLDisplay m_eglDisplay; EGLSurface m_eglSurface; + EGLenum m_eglApi; }; #endif //QOPENKODEGLINTEGRATION_H diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index 5e461ae..52b57d9 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -57,6 +57,8 @@ #include #include +#include + #include "GLES2/gl2ext.h" #include @@ -85,6 +87,19 @@ QOpenKODEScreen::QOpenKODEScreen() return; } + KDboolean enabled = KD_TRUE; + kdSetDisplayPropertybvNV(kdDisplay, + KD_DISPLAYPROPERTY_ENABLED_NV, + &enabled); + KDboolean power = KD_DISPLAY_POWER_ON; + kdSetDisplayPropertyivNV(kdDisplay, + KD_DISPLAYPROPERTY_POWER_NV, + &power); + + kdSetDisplayPropertycvNV(kdDisplay, + KD_DISPLAYPROPERTY_DESKTOP_NAME_NV, + KD_DEFAULT_DESKTOP_NV); + KDDisplayModeNV mode; if (kdGetDisplayModeNV(kdDisplay, &mode)) { qErrnoWarning(kdGetError(), "Could not get display mode"); @@ -95,15 +110,26 @@ QOpenKODEScreen::QOpenKODEScreen() KDint desktopSize[] = { mode.width, mode.height }; - if (kdSetDesktopPropertyivNV(kdDesktop, KD_DESKTOPPROPERTY_SIZE_NV, desktopSize)) { - qErrnoWarning(kdGetError(), "Could not set desktop size"); - return; - } +// if (kdSetDesktopPropertyivNV(kdDesktop, KD_DESKTOPPROPERTY_SIZE_NV, desktopSize)) { +// qErrnoWarning(kdGetError(), "Could not set desktop size"); +// return; +// } // Once we've set up the desktop and display we don't need them anymore kdReleaseDisplayNV(kdDisplay); kdReleaseDesktopNV(kdDesktop); + mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (mEglDisplay == EGL_NO_DISPLAY) { + qErrnoWarning("EGL failed to obtain display"); + } + + /* Initialize EGL display */ + EGLBoolean rvbool = eglInitialize(mEglDisplay, 0, 0); + if (!rvbool) { + qErrnoWarning("EGL failed to initialize display"); + } + const int defaultDpi = 72; mGeometry = QRect(0, 0, mode.width, mode.height); mPhysicalSize = QSize(mode.width * 25.4 / defaultDpi, mode.height * 25.4 / defaultDpi); @@ -212,17 +238,14 @@ QPlatformWindow *QOpenKODEIntegration::createPlatformWindow(QWidget *tlw, WId ) QWindowSurface *QOpenKODEIntegration::createWindowSurface(QWidget *widget, WId wid) const { - return new QOpenKODEWindowSurface(widget, wid); +// return new QOpenKODEWindowSurface(widget, wid); + return new QGLWindowSurface(widget); } bool QOpenKODEIntegration::hasOpenGL() const { return true; } -QPlatformGLContext *QOpenKODEIntegration::createGLContext() -{ - return new QEGLPlatformContext; -} GLuint QOpenKODEIntegration::blitterProgram() { diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h index f53c520..9029086 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeintegration.h @@ -46,10 +46,10 @@ #include #include -#include -#include +#include -# include +#include +#include QT_BEGIN_NAMESPACE @@ -57,6 +57,7 @@ struct KDDesktopNV; class QOpenKODEScreen : public QPlatformScreen { + Q_OBJECT public: QOpenKODEScreen(); ~QOpenKODEScreen() {} @@ -66,11 +67,13 @@ public: QImage::Format format() const { return mFormat; } QSize physicalSize() const { return mPhysicalSize; } + EGLDisplay eglDisplay() { return mEglDisplay; } public: QRect mGeometry; int mDepth; QImage::Format mFormat; QSize mPhysicalSize; + EGLDisplay mEglDisplay; }; class QOpenKODEIntegration : public QPlatformIntegration diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index 4d18a6f..88e6a75 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -39,40 +39,112 @@ ** ****************************************************************************/ #include "qopenkodewindow.h" +#include "qopenkodeintegration.h" +#include "qopenkodeglintegration.h" +#include #include -#include +#include + #include +#include +#include #include QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) : QPlatformWindow(tlw) { - /* Initialize EGL display */ - EGLBoolean rvbool = eglInitialize(QEgl::display(), KD_NULL, KD_NULL); - if (!rvbool) { - kdLogMessage("EGL failed to initialize display\n"); + EGLint configAttrs[] = { + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_BUFFER_SIZE, 16, + EGL_DEPTH_SIZE, 0, + EGL_LEVEL, 0, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, +// #ifdef EGL_NV_coverage_sample +// EGL_COVERAGE_BUFFERS_NV, 1, +// EGL_COVERAGE_SAMPLES_NV, 5, +// #endif + EGL_ALPHA_SIZE, 0, +// EGL_LUMINANCE_SIZE, 0, + EGL_ALPHA_MASK_SIZE, 0, + EGL_SAMPLES, 0, + EGL_SAMPLE_BUFFERS, 0, +// EGL_STENCIL_SIZE, 0, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_TRANSPARENT_TYPE, EGL_NONE, + EGL_NONE + }; + EGLint contextAttrs[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, // NOTE: not needed for VG + EGL_NONE + }; + + // EGL_RENDER_BUFFER, EGL_BACK_BUFFER, +// m_eglWindowAttrs.append(EGL_RENDER_BUFFER); +// m_eglWindowAttrs.append(EGL_BACK_BUFFER); + m_eglWindowAttrs.append(EGL_NONE); + + EGLenum eglApi = EGL_OPENGL_ES_API; + eglBindAPI(eglApi); + + QList screens = QApplicationPrivate::platformIntegration()->screens(); + //XXXX: jl figure out how to pick the correct screen. +// Q_ASSERT(screens.size() > tlw->d_func()->screenNumber); +// QOpenKODEScreen *screen = qobject_cast(screens.at(tlw->d_func()->screenNumber)); + QOpenKODEScreen *screen = qobject_cast(screens.at(0)); + if (!screen) { + qErrnoWarning("Could not make QOpenKODEWindow without a screen"); + } + + EGLint configCount; + // Find out how many configurations suit our needs + EGLBoolean eglStatus = eglChooseConfig(screen->eglDisplay(), configAttrs, + KD_NULL, 0, &configCount); + if (!eglStatus || !configCount) { + qErrnoWarning("EGL failed to return any matching configurations"); + } + + qDebug() << "config count" << configCount; + + // Allocate room for the list of matching configurations + EGLConfig *configList = (EGLConfig*)kdMalloc(configCount * sizeof(EGLConfig)); + if (!configList) { + qErrnoWarning("kdMalloc failure obtaining configuration list"); } - kdWindow = kdCreateWindow(QEgl::display(), - QEgl::defaultConfig(QInternal::Widget,QEgl::OpenGL,QEgl::Renderable), + // Obtain the configuration list from EGL + eglStatus = eglChooseConfig(screen->eglDisplay(), configAttrs, + configList, configCount, &configCount); + if (!eglStatus || !configCount) { + qErrnoWarning("EGL failed to populate configuration list"); + } + + // Select an EGL configuration that matches the native window + + m_eglConfig = configList[11]; + kdFree(configList);//free the list not the configs + + m_kdWindow = kdCreateWindow(screen->eglDisplay(), + m_eglConfig, KD_NULL); - if (!kdWindow) { + if (!m_kdWindow) { qErrnoWarning(kdGetError(), "Error creating native window"); return; } const KDint windowSize[2] = { tlw->width(), tlw->height()-1 }; - if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { + if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { qErrnoWarning(kdGetError(), "Could not set native window size"); return; } - KDboolean visibillity(false); - if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) { - qErrnoWarning(kdGetError(), "Could not set visibillity to false"); - } +// KDboolean visibillity(false); +// if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) { +// qErrnoWarning(kdGetError(), "Could not set visibillity to false"); +// } // const KDboolean windowExclusive[] = { false }; // if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, windowExclusive)) { @@ -81,28 +153,44 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) // } // const KDint windowPos[2] = { tlw->x(), tlw->y() }; - if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { + if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { qErrnoWarning(kdGetError(), "Could not set native window position"); return; } - if (kdRealizeWindow(kdWindow, &eglWindow)) { + if (kdRealizeWindow(m_kdWindow, &m_eglWindow)) { qErrnoWarning(kdGetError(), "Could not realize native window"); return; } + + KDint32 layer = 1; + kdGetWindowPropertyiv(m_kdWindow,KD_WINDOWPROPERTY_DESKTOP_LAYER_NV,&layer); + qDebug() << "LAYER:" << layer; + + EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); + + qDebug() << "surface id " << surface; + + m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(),m_eglConfig,contextAttrs,surface,eglApi); + m_platformGlContext->makeCurrent(); + glClearColor(0,0,0,0); + + } QOpenKODEWindow::~QOpenKODEWindow() { - qDebug() << "destroying window"; - kdDestroyWindow(kdWindow); + qDebug() << "destroying window" << m_kdWindow; +// delete m_platformGlContext; + kdDestroyWindow(m_kdWindow); } void QOpenKODEWindow::setGeometry(const QRect &rect) { + qDebug() << "setting geo"; const QRect geo = geometry(); if (geo.size() != rect.size()) { const KDint windowSize[2] = { rect.width(), rect.height() }; - if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { + if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { qErrnoWarning(kdGetError(), "Could not set native window size"); //return; } @@ -110,18 +198,50 @@ void QOpenKODEWindow::setGeometry(const QRect &rect) if (geo.topLeft() != rect.topLeft()) { const KDint windowPos[2] = { rect.x(), rect.y() }; - if (kdSetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { + if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { qErrnoWarning(kdGetError(), "Could not set native window position"); //return; } } + delete m_platformGlContext; + + QList screens = QApplicationPrivate::platformIntegration()->screens(); + //XXXX: jl figure out how to pick the correct screen. +// Q_ASSERT(screens.size() > tlw->d_func()->screenNumber); +// QOpenKODEScreen *screen = qobject_cast(screens.at(tlw->d_func()->screenNumber)); + QOpenKODEScreen *screen = qobject_cast(screens.at(0)); + +// if (kdRealizeWindow(m_kdWindow, &m_eglWindow)) { +// qErrnoWarning(kdGetError(), "Could not realize native window in geo"); +// return; +// } + + EGLint contextAttrs[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, // NOTE: not needed for VG + EGL_NONE + }; + + EGLenum eglApi = EGL_OPENGL_ES_API; + + EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); + + qDebug() << "surface id " << surface; + + m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(),m_eglConfig,contextAttrs,surface,eglApi); + m_platformGlContext->makeCurrent(); + glClearColor(0,0,0,1); } void QOpenKODEWindow::setVisible(bool visible) { KDboolean visibillity(visible); - if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) { + if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) { qErrnoWarning(kdGetError(), "Could not set visibillity to false"); } } + +QPlatformGLContext *QOpenKODEWindow::glContext() +{ + return m_platformGlContext; +} diff --git a/src/plugins/platforms/openkode/qopenkodewindow.h b/src/plugins/platforms/openkode/qopenkodewindow.h index 741e676..04fa70a 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.h +++ b/src/plugins/platforms/openkode/qopenkodewindow.h @@ -43,9 +43,12 @@ #define QOPENKODEWINDOW_H #include +#include #include +class QEGLPlatformContext; + class QOpenKODEWindow : public QPlatformWindow { public: @@ -54,11 +57,16 @@ public: void setGeometry(const QRect &rect); void setVisible(bool visible); - WId winId() const { return WId(eglWindow); } + WId winId() const { return WId(m_eglWindow); } + + QPlatformGLContext *glContext(); private: - struct KDWindow *kdWindow; - EGLNativeWindowType eglWindow; + struct KDWindow *m_kdWindow; + EGLNativeWindowType m_eglWindow; + EGLConfig m_eglConfig; + QVector m_eglWindowAttrs; + QEGLPlatformContext *m_platformGlContext; }; #endif //QOPENKODEWINDOW_H diff --git a/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp b/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp index dacd019..a349031 100644 --- a/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp @@ -45,21 +45,14 @@ #include "qopenkodewindow.h" #include +#include QT_BEGIN_NAMESPACE QOpenKODEWindowSurface::QOpenKODEWindowSurface - (QWidget *window, WId winId) - : QWindowSurface(window), - mSurface(EGL_NO_SURFACE), - mWin((EGLNativeWindowType) winId) + (QWidget *window, WId) + : QWindowSurface(window), m_platformGLContext(window->platformWindow()->glContext()) { - EGLConfig config = QEgl::defaultConfig(QInternal::Widget,QEgl::OpenGL,QEgl::Renderable); - mContext.setConfig(config); - if (!mContext.createContext()) { - qWarning("QOpenKODEWindowSurface: Unable to create context"); - return; - } } QOpenKODEWindowSurface::~QOpenKODEWindowSurface() @@ -72,19 +65,16 @@ QPaintDevice *QOpenKODEWindowSurface::paintDevice() } // ### TODO - this updates the entire toplevel, should only update the region -void QOpenKODEWindowSurface::flush(QWidget *, const QRegion ®ion, const QPoint &offset) +void QOpenKODEWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { - mContext.makeCurrent(mSurface); + m_platformGLContext->makeCurrent(); if (!offset.isNull()) { qWarning("Offset flushing not supported yet"); return; } - if (!mContext.makeCurrent(mSurface)) { - qWarning("EGL couldn't make context/surface current: 0x%x", eglGetError()); - return; - } + m_platformGLContext->makeCurrent(); QRect boundingRect = region.boundingRect(); @@ -103,7 +93,7 @@ void QOpenKODEWindowSurface::flush(QWidget *, const QRegion ®ion, const QPoin y = boundingRect.y(); } -// qDebug() << "flush" << widget << offset << region.boundingRect() << mImage.format() << blitImage.format(); + qDebug() << "flush" << widget << offset << region.boundingRect() << mImage.format() << blitImage.format(); GLuint shaderProgram = QOpenKODEIntegration::blitterProgram(); @@ -159,8 +149,8 @@ void QOpenKODEWindowSurface::flush(QWidget *, const QRegion ®ion, const QPoin eglWaitGL(); - mContext.swapBuffers(mSurface); - mContext.doneCurrent(); + m_platformGLContext->swapBuffers(); + m_platformGLContext->doneCurrent(); eglWaitNative(EGL_CORE_NATIVE_ENGINE); } @@ -168,21 +158,14 @@ void QOpenKODEWindowSurface::flush(QWidget *, const QRegion ®ion, const QPoin void QOpenKODEWindowSurface::resize(const QSize &size) { QWindowSurface::resize(size); - mContext.destroySurface(mSurface); - mSurface = EGL_NO_SURFACE; mImage = QImage(); } void QOpenKODEWindowSurface::beginPaint(const QRegion ®ion) { Q_UNUSED(region); - if (mSurface == EGL_NO_SURFACE) { - EGLConfig config = QEgl::defaultConfig(QInternal::Widget,QEgl::OpenGL,QEgl::Renderable); - EGLint windowAttrs[] = { EGL_NONE }; - mSurface = eglCreateWindowSurface(QEgl::display(), config, mWin, windowAttrs); - if (mSurface == EGL_NO_SURFACE) { - qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError()); - } + if (mImage.isNull()) { + m_platformGLContext = window()->platformWindow()->glContext(); mImage = QImage(size(),QImage::Format_RGB32); } } diff --git a/src/plugins/platforms/openkode/qopenkodewindowsurface.h b/src/plugins/platforms/openkode/qopenkodewindowsurface.h index 568dbc2..4acd1d8 100644 --- a/src/plugins/platforms/openkode/qopenkodewindowsurface.h +++ b/src/plugins/platforms/openkode/qopenkodewindowsurface.h @@ -43,11 +43,13 @@ #define QWINDOWSURFACE_OPENKODE_H #include -#include + +#include QT_BEGIN_NAMESPACE class QOpenKODEWindow; +class QPlatformGLContext; class QOpenKODEWindowSurface : public QWindowSurface { @@ -65,9 +67,7 @@ public: private: QImage mImage; - EGLSurface mSurface; - QEglContext mContext; - EGLNativeWindowType mWin; + QPlatformGLContext *m_platformGLContext; }; QT_END_NAMESPACE -- cgit v0.12 From 2b384a4df14fab0f377b04df24b67ee7634f8403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 8 Jul 2010 08:28:35 +0200 Subject: Make tempcontext use new lighthouse api --- src/opengl/qgl_qpa.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 2003cc1..be2ef87 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -180,14 +180,16 @@ void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase) class QGLTemporaryContextPrivate { public: - QGLWidget *widget; + QWidget *widget; }; QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) : d(new QGLTemporaryContextPrivate) { - d->widget = new QGLWidget; - d->widget->makeCurrent(); + d->widget = new QWidget; + d->widget->setGeometry(0,0,3,3); + d->widget->winId(); + d->widget->platformWindow()->glContext()->makeCurrent(); } QGLTemporaryContext::~QGLTemporaryContext() -- cgit v0.12 From 13e75dd03d2fb8a1f01406c30520cef80cb2800a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 8 Jul 2010 10:19:01 +0200 Subject: Fix deletion of QPlatformGLContext it is owned by the QPlatformWindow, and should thus be delted by it, even for QGLContext --- src/opengl/qgl_qpa.cpp | 2 +- src/plugins/platforms/openkode/qopenkodewindow.cpp | 36 ++++++---------------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index be2ef87..aa124fe 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -84,7 +84,7 @@ void QGLContext::reset() doneCurrent(); if (d->platformContext) { - delete d->platformContext; + //dont delete. This will be done by the platform d->platformContext = 0; } diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index 88e6a75..e40783f 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -82,7 +82,6 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) EGL_NONE }; - // EGL_RENDER_BUFFER, EGL_BACK_BUFFER, // m_eglWindowAttrs.append(EGL_RENDER_BUFFER); // m_eglWindowAttrs.append(EGL_BACK_BUFFER); m_eglWindowAttrs.append(EGL_NONE); @@ -141,17 +140,11 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) return; } -// KDboolean visibillity(false); -// if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) { -// qErrnoWarning(kdGetError(), "Could not set visibillity to false"); -// } - -// const KDboolean windowExclusive[] = { false }; -// if (kdSetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, windowExclusive)) { -// qErrnoWarning(kdGetError(), "Could not set exclusive bit"); -// //return; -// } -// + KDboolean visibillity(false); + if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) { + qErrnoWarning(kdGetError(), "Could not set visibillity to false"); + } + const KDint windowPos[2] = { tlw->x(), tlw->y() }; if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { qErrnoWarning(kdGetError(), "Could not set native window position"); @@ -169,19 +162,13 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); - qDebug() << "surface id " << surface; - m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(),m_eglConfig,contextAttrs,surface,eglApi); - m_platformGlContext->makeCurrent(); - glClearColor(0,0,0,0); - - } QOpenKODEWindow::~QOpenKODEWindow() { qDebug() << "destroying window" << m_kdWindow; -// delete m_platformGlContext; + delete m_platformGlContext; kdDestroyWindow(m_kdWindow); } void QOpenKODEWindow::setGeometry(const QRect &rect) @@ -189,7 +176,7 @@ void QOpenKODEWindow::setGeometry(const QRect &rect) qDebug() << "setting geo"; const QRect geo = geometry(); if (geo.size() != rect.size()) { - const KDint windowSize[2] = { rect.width(), rect.height() }; + const KDint windowSize[2] = { rect.width(), rect.height() -1 }; if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { qErrnoWarning(kdGetError(), "Could not set native window size"); //return; @@ -206,17 +193,13 @@ void QOpenKODEWindow::setGeometry(const QRect &rect) delete m_platformGlContext; + /********####neeeds cleaning up **********/ QList screens = QApplicationPrivate::platformIntegration()->screens(); //XXXX: jl figure out how to pick the correct screen. // Q_ASSERT(screens.size() > tlw->d_func()->screenNumber); // QOpenKODEScreen *screen = qobject_cast(screens.at(tlw->d_func()->screenNumber)); QOpenKODEScreen *screen = qobject_cast(screens.at(0)); -// if (kdRealizeWindow(m_kdWindow, &m_eglWindow)) { -// qErrnoWarning(kdGetError(), "Could not realize native window in geo"); -// return; -// } - EGLint contextAttrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, // NOTE: not needed for VG EGL_NONE @@ -229,8 +212,7 @@ void QOpenKODEWindow::setGeometry(const QRect &rect) qDebug() << "surface id " << surface; m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(),m_eglConfig,contextAttrs,surface,eglApi); - m_platformGlContext->makeCurrent(); - glClearColor(0,0,0,1); + /*******************************************/ } void QOpenKODEWindow::setVisible(bool visible) -- cgit v0.12 From c7590d9f255e1efd3dc528e1052f997f4f477009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 8 Jul 2010 11:08:49 +0200 Subject: cleaning up QOpenKODEWindow --- src/plugins/platforms/openkode/qopenkodewindow.cpp | 35 +++++++--------------- src/plugins/platforms/openkode/qopenkodewindow.h | 2 ++ 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index e40783f..52117ad 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -77,17 +77,17 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) EGL_TRANSPARENT_TYPE, EGL_NONE, EGL_NONE }; - EGLint contextAttrs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, // NOTE: not needed for VG - EGL_NONE - }; + + m_eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); + m_eglContextAttrs.append(2); + m_eglContextAttrs.append(EGL_NONE); // m_eglWindowAttrs.append(EGL_RENDER_BUFFER); // m_eglWindowAttrs.append(EGL_BACK_BUFFER); m_eglWindowAttrs.append(EGL_NONE); - EGLenum eglApi = EGL_OPENGL_ES_API; - eglBindAPI(eglApi); + m_eglApi = EGL_OPENGL_ES_API; + eglBindAPI(m_eglApi); QList screens = QApplicationPrivate::platformIntegration()->screens(); //XXXX: jl figure out how to pick the correct screen. @@ -162,7 +162,8 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); - m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(),m_eglConfig,contextAttrs,surface,eglApi); + m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(), m_eglConfig, + m_eglContextAttrs.data(), surface, m_eglApi); } QOpenKODEWindow::~QOpenKODEWindow() @@ -191,28 +192,14 @@ void QOpenKODEWindow::setGeometry(const QRect &rect) } } + //need to recreate context delete m_platformGlContext; - /********####neeeds cleaning up **********/ QList screens = QApplicationPrivate::platformIntegration()->screens(); - //XXXX: jl figure out how to pick the correct screen. -// Q_ASSERT(screens.size() > tlw->d_func()->screenNumber); -// QOpenKODEScreen *screen = qobject_cast(screens.at(tlw->d_func()->screenNumber)); QOpenKODEScreen *screen = qobject_cast(screens.at(0)); - - EGLint contextAttrs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, // NOTE: not needed for VG - EGL_NONE - }; - - EGLenum eglApi = EGL_OPENGL_ES_API; - EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); - - qDebug() << "surface id " << surface; - - m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(),m_eglConfig,contextAttrs,surface,eglApi); - /*******************************************/ + m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(),m_eglConfig, + m_eglContextAttrs.data(),surface,m_eglApi); } void QOpenKODEWindow::setVisible(bool visible) diff --git a/src/plugins/platforms/openkode/qopenkodewindow.h b/src/plugins/platforms/openkode/qopenkodewindow.h index 04fa70a..51252a9 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.h +++ b/src/plugins/platforms/openkode/qopenkodewindow.h @@ -66,6 +66,8 @@ private: EGLNativeWindowType m_eglWindow; EGLConfig m_eglConfig; QVector m_eglWindowAttrs; + QVector m_eglContextAttrs; + EGLenum m_eglApi; QEGLPlatformContext *m_platformGlContext; }; -- cgit v0.12 From e7054204ff74bde531d293de5b360587724f6857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 9 Jul 2010 16:04:46 +0200 Subject: Added QPlatformWindowFormat Its mostly a copy of QGLFormat Only plugin that uses it is the openkode, and thats just a poc. --- src/gui/kernel/kernel.pri | 6 +- src/gui/kernel/qplatformwindow_qpa.cpp | 41 + src/gui/kernel/qplatformwindow_qpa.h | 2 + src/gui/kernel/qplatformwindowformat_qpa.cpp | 1283 ++++++++++++++++++++ src/gui/kernel/qplatformwindowformat_qpa.h | 256 ++++ src/gui/kernel/qwidget.cpp | 37 +- src/gui/kernel/qwidget.h | 8 + src/gui/kernel/qwidget_p.h | 1 + src/gui/kernel/qwidget_qpa.cpp | 52 + .../platforms/openkode/qopenkodeintegration.cpp | 8 +- src/plugins/platforms/openkode/qopenkodewindow.cpp | 290 ++++- 11 files changed, 1891 insertions(+), 93 deletions(-) create mode 100644 src/gui/kernel/qplatformwindowformat_qpa.cpp create mode 100644 src/gui/kernel/qplatformwindowformat_qpa.h diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index f773906..e9b8f25 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -214,9 +214,10 @@ qpa { kernel/qplatformintegrationfactory_qpa_p.h \ kernel/qplatformintegrationplugin_qpa.h \ kernel/qplatformwindow_qpa.h \ + kernel/qplatformwindowformat_qpa.h \ kernel/qplatformglcontext_qpa.h \ kernel/qdesktopwidget_qpa_p.h - + SOURCES += \ kernel/qapplication_qpa.cpp \ kernel/qclipboard_qpa.cpp \ @@ -233,7 +234,8 @@ qpa { kernel/qplatformscreen_qpa.cpp \ kernel/qplatformintegrationfactory_qpa.cpp \ kernel/qplatformintegrationplugin_qpa.cpp \ - kernel/qplatformwindow_qpa.cpp + kernel/qplatformwindow_qpa.cpp \ + kernel/qplatformwindowformat_qpa.cpp contains(QT_CONFIG, glib) { SOURCES += \ diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp index c0e642c..4cd8ead 100644 --- a/src/gui/kernel/qplatformwindow_qpa.cpp +++ b/src/gui/kernel/qplatformwindow_qpa.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 "qplatformwindow_qpa.h" #include diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h index 5f8d259..e8b5ad8 100644 --- a/src/gui/kernel/qplatformwindow_qpa.h +++ b/src/gui/kernel/qplatformwindow_qpa.h @@ -82,6 +82,8 @@ public: virtual QPlatformGLContext *glContext(); protected: QScopedPointer d_ptr; +private: + Q_DISABLE_COPY(QPlatformWindow); }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformwindowformat_qpa.cpp b/src/gui/kernel/qplatformwindowformat_qpa.cpp new file mode 100644 index 0000000..4ded26b --- /dev/null +++ b/src/gui/kernel/qplatformwindowformat_qpa.cpp @@ -0,0 +1,1283 @@ +/**************************************************************************** +** +** 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 "qplatformwindowformat_qpa.h" + +Q_GLOBAL_STATIC(QPlatformWindowFormat, q_platformwindow_default_format); + +class QPlatformWindowFormatPrivate +{ +public: + QPlatformWindowFormatPrivate() + : ref(1) + , opts(QPlatformWindowFormat::DoubleBuffer | QPlatformWindowFormat::DepthBuffer + | QPlatformWindowFormat::Rgba | QPlatformWindowFormat::DirectRendering + | QPlatformWindowFormat::StencilBuffer | QPlatformWindowFormat::DeprecatedFunctions) + , depthSize(-1) + , accumSize(-1) + , stencilSize(-1) + , redSize(-1) + , greenSize(-1) + , blueSize(-1) + , alphaSize(-1) + , numSamples(-1) + , swapInterval(-1) + , majorVersion(1) + , minorVersion(0) + , profile(QPlatformWindowFormat::NoProfile) + { + } + + QPlatformWindowFormatPrivate(const QPlatformWindowFormatPrivate *other) + : ref(1), + opts(other->opts), + depthSize(other->depthSize), + accumSize(other->accumSize), + stencilSize(other->stencilSize), + redSize(other->redSize), + greenSize(other->greenSize), + blueSize(other->blueSize), + alphaSize(other->alphaSize), + numSamples(other->numSamples), + swapInterval(other->swapInterval), + majorVersion(other->majorVersion), + minorVersion(other->minorVersion), + profile(other->profile) + { + } + QAtomicInt ref; + QPlatformWindowFormat::FormatOptions opts; + int depthSize; + int accumSize; + int stencilSize; + int redSize; + int greenSize; + int blueSize; + int alphaSize; + int numSamples; + int swapInterval; + int majorVersion; + int minorVersion; + QPlatformWindowFormat::OpenGLContextProfile profile; +}; + +/*! + \class QGLFormat + \brief The QGLFormat class specifies the display format of an OpenGL + rendering context. + + \ingroup painting-3D + + A display format has several characteristics: + \list + \i \link setDoubleBuffer() Double or single buffering.\endlink + \i \link setDepth() Depth buffer.\endlink + \i \link setRgba() RGBA or color index mode.\endlink + \i \link setAlpha() Alpha channel.\endlink + \i \link setAccum() Accumulation buffer.\endlink + \i \link setStencil() Stencil buffer.\endlink + \i \link setStereo() Stereo buffers.\endlink + \i \link setDirectRendering() Direct rendering.\endlink + \i \link setOverlay() Presence of an overlay.\endlink + \i \link setPlane() Plane of an overlay.\endlink + \i \link setSampleBuffers() Multisample buffers.\endlink + \endlist + + You can also specify preferred bit depths for the color buffer, + depth buffer, alpha buffer, accumulation buffer and the stencil + buffer with the functions: setRedBufferSize(), setGreenBufferSize(), + setBlueBufferSize(), setDepthBufferSize(), setAlphaBufferSize(), + setAccumBufferSize() and setStencilBufferSize(). + + Note that even if you specify that you prefer a 32 bit depth + buffer (e.g. with setDepthBufferSize(32)), the format that is + chosen may not have a 32 bit depth buffer, even if there is a + format available with a 32 bit depth buffer. The main reason for + this is how the system dependant picking algorithms work on the + different platforms, and some format options may have higher + precedence than others. + + You create and tell a QGLFormat object what rendering options you + want from an OpenGL rendering context. + + OpenGL drivers or accelerated hardware may or may not support + advanced features such as alpha channel or stereographic viewing. + If you request some features that the driver/hardware does not + provide when you create a QGLWidget, you will get a rendering + context with the nearest subset of features. + + There are different ways to define the display characteristics of + a rendering context. One is to create a QGLFormat and make it the + default for the entire application: + \snippet doc/src/snippets/code/src_opengl_qgl.cpp 0 + + Or you can specify the desired format when creating an object of + your QGLWidget subclass: + \snippet doc/src/snippets/code/src_opengl_qgl.cpp 1 + + After the widget has been created, you can find out which of the + requested features the system was able to provide: + \snippet doc/src/snippets/code/src_opengl_qgl.cpp 2 + + \legalese + OpenGL is a trademark of Silicon Graphics, Inc. in the + United States and other countries. + \endlegalese + + \sa QGLContext, QGLWidget +*/ + +/*! + Constructs a QGLFormat object with the following default settings: + \list + \i \link setDoubleBuffer() Double buffer:\endlink Enabled. + \i \link setDepth() Depth buffer:\endlink Enabled. + \i \link setRgba() RGBA:\endlink Enabled (i.e., color index disabled). + \i \link setAlpha() Alpha channel:\endlink Disabled. + \i \link setAccum() Accumulator buffer:\endlink Disabled. + \i \link setStencil() Stencil buffer:\endlink Enabled. + \i \link setStereo() Stereo:\endlink Disabled. + \i \link setDirectRendering() Direct rendering:\endlink Enabled. + \i \link setOverlay() Overlay:\endlink Disabled. + \i \link setPlane() Plane:\endlink 0 (i.e., normal plane). + \i \link setSampleBuffers() Multisample buffers:\endlink Disabled. + \endlist +*/ + +QPlatformWindowFormat::QPlatformWindowFormat() +{ + d = new QPlatformWindowFormatPrivate; +} + + +/*! + Creates a QGLFormat object that is a copy of the current + defaultFormat(). + + If \a options is not 0, the default format is modified by the + specified format options. The \a options parameter should be + QGL::FormatOption values OR'ed together. + + This constructor makes it easy to specify a certain desired format + in classes derived from QGLWidget, for example: + \snippet doc/src/snippets/code/src_opengl_qgl.cpp 3 + + Note that there are QGL::FormatOption values to turn format settings + both on and off, e.g. QGL::DepthBuffer and QGL::NoDepthBuffer, + QGL::DirectRendering and QGL::IndirectRendering, etc. + + The \a plane parameter defaults to 0 and is the plane which this + format should be associated with. Not all OpenGL implementations + supports overlay/underlay rendering planes. + + \sa defaultFormat(), setOption(), setPlane() +*/ + +QPlatformWindowFormat::QPlatformWindowFormat(QPlatformWindowFormat::FormatOptions options) +{ + d = new QPlatformWindowFormatPrivate; + QPlatformWindowFormat::FormatOptions newOpts = options; + d->opts = defaultFormat().d->opts; + d->opts |= (newOpts & 0xffff); + d->opts &= ~(newOpts >> 16); +} + +/*! + \internal +*/ +void QPlatformWindowFormat::detach() +{ + if (d->ref != 1) { + QPlatformWindowFormatPrivate *newd = new QPlatformWindowFormatPrivate(d); + if (!d->ref.deref()) + delete d; + d = newd; + } +} + +/*! + Constructs a copy of \a other. +*/ + +QPlatformWindowFormat::QPlatformWindowFormat(const QPlatformWindowFormat &other) +{ + d = other.d; + d->ref.ref(); +} + +/*! + Assigns \a other to this object. +*/ + +QPlatformWindowFormat &QPlatformWindowFormat::operator=(const QPlatformWindowFormat &other) +{ + if (d != other.d) { + other.d->ref.ref(); + if (!d->ref.deref()) + delete d; + d = other.d; + } + return *this; +} + +/*! + Destroys the QGLFormat. +*/ +QPlatformWindowFormat::~QPlatformWindowFormat() +{ + if (!d->ref.deref()) + delete d; +} + +/*! + \fn bool QGLFormat::doubleBuffer() const + + Returns true if double buffering is enabled; otherwise returns + false. Double buffering is enabled by default. + + \sa setDoubleBuffer() +*/ + +/*! + If \a enable is true sets double buffering; otherwise sets single + buffering. + + Double buffering is enabled by default. + + Double buffering is a technique where graphics are rendered on an + off-screen buffer and not directly to the screen. When the drawing + has been completed, the program calls a swapBuffers() function to + exchange the screen contents with the buffer. The result is + flicker-free drawing and often better performance. + + \sa doubleBuffer(), QGLContext::swapBuffers(), + QGLWidget::swapBuffers() +*/ + +void QPlatformWindowFormat::setDoubleBuffer(bool enable) +{ + setOption(enable ? QPlatformWindowFormat::DoubleBuffer : QPlatformWindowFormat::SingleBuffer); +} + + +/*! + \fn bool QGLFormat::depth() const + + Returns true if the depth buffer is enabled; otherwise returns + false. The depth buffer is enabled by default. + + \sa setDepth(), setDepthBufferSize() +*/ + +/*! + If \a enable is true enables the depth buffer; otherwise disables + the depth buffer. + + The depth buffer is enabled by default. + + The purpose of a depth buffer (or Z-buffering) is to remove hidden + surfaces. Pixels are assigned Z values based on the distance to + the viewer. A pixel with a high Z value is closer to the viewer + than a pixel with a low Z value. This information is used to + decide whether to draw a pixel or not. + + \sa depth(), setDepthBufferSize() +*/ + +void QPlatformWindowFormat::setDepth(bool enable) +{ + setOption(enable ? QPlatformWindowFormat::DepthBuffer : QPlatformWindowFormat::NoDepthBuffer); +} + + +/*! + \fn bool QGLFormat::rgba() const + + Returns true if RGBA color mode is set. Returns false if color + index mode is set. The default color mode is RGBA. + + \sa setRgba() +*/ + +/*! + If \a enable is true sets RGBA mode. If \a enable is false sets + color index mode. + + The default color mode is RGBA. + + RGBA is the preferred mode for most OpenGL applications. In RGBA + color mode you specify colors as red + green + blue + alpha + quadruplets. + + In color index mode you specify an index into a color lookup + table. + + \sa rgba() +*/ + +void QPlatformWindowFormat::setRgba(bool enable) +{ + setOption(enable ? QPlatformWindowFormat::Rgba : QPlatformWindowFormat::ColorIndex); +} + + +/*! + \fn bool QGLFormat::alpha() const + + Returns true if the alpha buffer in the framebuffer is enabled; + otherwise returns false. The alpha buffer is disabled by default. + + \sa setAlpha(), setAlphaBufferSize() +*/ + +/*! + If \a enable is true enables the alpha buffer; otherwise disables + the alpha buffer. + + The alpha buffer is disabled by default. + + The alpha buffer is typically used for implementing transparency + or translucency. The A in RGBA specifies the transparency of a + pixel. + + \sa alpha(), setAlphaBufferSize() +*/ + +void QPlatformWindowFormat::setAlpha(bool enable) +{ + setOption(enable ? QPlatformWindowFormat::AlphaChannel : QPlatformWindowFormat::NoAlphaChannel); +} + + +/*! + \fn bool QGLFormat::accum() const + + Returns true if the accumulation buffer is enabled; otherwise + returns false. The accumulation buffer is disabled by default. + + \sa setAccum(), setAccumBufferSize() +*/ + +/*! + If \a enable is true enables the accumulation buffer; otherwise + disables the accumulation buffer. + + The accumulation buffer is disabled by default. + + The accumulation buffer is used to create blur effects and + multiple exposures. + + \sa accum(), setAccumBufferSize() +*/ + +void QPlatformWindowFormat::setAccum(bool enable) +{ + setOption(enable ? QPlatformWindowFormat::AccumBuffer : QPlatformWindowFormat::NoAccumBuffer); +} + + +/*! + \fn bool QGLFormat::stencil() const + + Returns true if the stencil buffer is enabled; otherwise returns + false. The stencil buffer is enabled by default. + + \sa setStencil(), setStencilBufferSize() +*/ + +/*! + If \a enable is true enables the stencil buffer; otherwise + disables the stencil buffer. + + The stencil buffer is enabled by default. + + The stencil buffer masks certain parts of the drawing area so that + masked parts are not drawn on. + + \sa stencil(), setStencilBufferSize() +*/ + +void QPlatformWindowFormat::setStencil(bool enable) +{ + setOption(enable ? QPlatformWindowFormat::StencilBuffer: QPlatformWindowFormat::NoStencilBuffer); +} + + +/*! + \fn bool QGLFormat::stereo() const + + Returns true if stereo buffering is enabled; otherwise returns + false. Stereo buffering is disabled by default. + + \sa setStereo() +*/ + +/*! + If \a enable is true enables stereo buffering; otherwise disables + stereo buffering. + + Stereo buffering is disabled by default. + + Stereo buffering provides extra color buffers to generate left-eye + and right-eye images. + + \sa stereo() +*/ + +void QPlatformWindowFormat::setStereo(bool enable) +{ + setOption(enable ? QPlatformWindowFormat::StereoBuffers : QPlatformWindowFormat::NoStereoBuffers); +} + + +/*! + \fn bool QGLFormat::directRendering() const + + Returns true if direct rendering is enabled; otherwise returns + false. + + Direct rendering is enabled by default. + + \sa setDirectRendering() +*/ + +/*! + If \a enable is true enables direct rendering; otherwise disables + direct rendering. + + Direct rendering is enabled by default. + + Enabling this option will make OpenGL bypass the underlying window + system and render directly from hardware to the screen, if this is + supported by the system. + + \sa directRendering() +*/ + +void QPlatformWindowFormat::setDirectRendering(bool enable) +{ + setOption(enable ? QPlatformWindowFormat::DirectRendering : QPlatformWindowFormat::IndirectRendering); +} + +/*! + \fn bool QGLFormat::sampleBuffers() const + + Returns true if multisample buffer support is enabled; otherwise + returns false. + + The multisample buffer is disabled by default. + + \sa setSampleBuffers() +*/ + +/*! + If \a enable is true, a GL context with multisample buffer support + is picked; otherwise ignored. + + \sa sampleBuffers(), setSamples(), samples() +*/ +void QPlatformWindowFormat::setSampleBuffers(bool enable) +{ + setOption(enable ? QPlatformWindowFormat::SampleBuffers : QPlatformWindowFormat::NoSampleBuffers); +} + +/*! + Returns the number of samples per pixel when multisampling is + enabled. By default, the highest number of samples that is + available is used. + + \sa setSampleBuffers(), sampleBuffers(), setSamples() +*/ +int QPlatformWindowFormat::samples() const +{ + return d->numSamples; +} + +/*! + Set the preferred number of samples per pixel when multisampling + is enabled to \a numSamples. By default, the highest number of + samples available is used. + + \sa setSampleBuffers(), sampleBuffers(), samples() +*/ +void QPlatformWindowFormat::setSamples(int numSamples) +{ + detach(); + if (numSamples < 0) { + qWarning("QGLFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples); + return; + } + d->numSamples = numSamples; + setSampleBuffers(numSamples > 0); +} + +/*! + \since 4.2 + + Set the preferred swap interval. This can be used to sync the GL + drawing into a system window to the vertical refresh of the screen. + Setting an \a interval value of 0 will turn the vertical refresh syncing + off, any value higher than 0 will turn the vertical syncing on. + + Under Windows and under X11, where the \c{WGL_EXT_swap_control} + and \c{GLX_SGI_video_sync} extensions are used, the \a interval + parameter can be used to set the minimum number of video frames + that are displayed before a buffer swap will occur. In effect, + setting the \a interval to 10, means there will be 10 vertical + retraces between every buffer swap. + + Under Windows the \c{WGL_EXT_swap_control} extension has to be present, + and under X11 the \c{GLX_SGI_video_sync} extension has to be present. +*/ +void QPlatformWindowFormat::setSwapInterval(int interval) +{ + detach(); + d->swapInterval = interval; +} + +/*! + \since 4.2 + + Returns the currently set swap interval. -1 is returned if setting + the swap interval isn't supported in the system GL implementation. +*/ +int QPlatformWindowFormat::swapInterval() const +{ + return d->swapInterval; +} + +///*! +// \fn bool QGLFormat::hasOverlay() const + +// Returns true if overlay plane is enabled; otherwise returns false. + +// Overlay is disabled by default. + +// \sa setOverlay() +//*/ + +///*! +// If \a enable is true enables an overlay plane; otherwise disables +// the overlay plane. + +// Enabling the overlay plane will cause QGLWidget to create an +// additional context in an overlay plane. See the QGLWidget +// documentation for further information. + +// \sa hasOverlay() +//*/ + +//void QPlatformWindowFormat::setOverlay(bool enable) +//{ +// setOption(enable ? QPlatformWindowFormat::HasOverlay : QPlatformWindowFormat::NoOverlay); +//} + +/*! + Sets the format option to \a opt. + + \sa testOption() +*/ + +void QPlatformWindowFormat::setOption(QPlatformWindowFormat::FormatOptions opt) +{ + detach(); + if (opt & 0xffff) + d->opts |= opt; + else + d->opts &= ~(opt >> 16); +} + + + +/*! + Returns true if format option \a opt is set; otherwise returns false. + + \sa setOption() +*/ + +bool QPlatformWindowFormat::testOption(QPlatformWindowFormat::FormatOptions opt) const +{ + if (opt & 0xffff) + return (d->opts & opt) != 0; + else + return (d->opts & (opt >> 16)) == 0; +} + +/*! + Set the minimum depth buffer size to \a size. + + \sa depthBufferSize(), setDepth(), depth() +*/ +void QPlatformWindowFormat::setDepthBufferSize(int size) +{ + detach(); + if (size < 0) { + qWarning("QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size); + return; + } + d->depthSize = size; + setDepth(size > 0); +} + +/*! + Returns the depth buffer size. + + \sa depth(), setDepth(), setDepthBufferSize() +*/ +int QPlatformWindowFormat::depthBufferSize() const +{ + return d->depthSize; +} + +/*! + \since 4.2 + + Set the preferred red buffer size to \a size. + + \sa setGreenBufferSize(), setBlueBufferSize(), setAlphaBufferSize() +*/ +void QPlatformWindowFormat::setRedBufferSize(int size) +{ + detach(); + if (size < 0) { + qWarning("QGLFormat::setRedBufferSize: Cannot set negative red buffer size %d", size); + return; + } + d->redSize = size; +} + +/*! + \since 4.2 + + Returns the red buffer size. + + \sa setRedBufferSize() +*/ +int QPlatformWindowFormat::redBufferSize() const +{ + return d->redSize; +} + +/*! + \since 4.2 + + Set the preferred green buffer size to \a size. + + \sa setRedBufferSize(), setBlueBufferSize(), setAlphaBufferSize() +*/ +void QPlatformWindowFormat::setGreenBufferSize(int size) +{ + detach(); + if (size < 0) { + qWarning("QGLFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size); + return; + } + d->greenSize = size; +} + +/*! + \since 4.2 + + Returns the green buffer size. + + \sa setGreenBufferSize() +*/ +int QPlatformWindowFormat::greenBufferSize() const +{ + return d->greenSize; +} + +/*! + \since 4.2 + + Set the preferred blue buffer size to \a size. + + \sa setRedBufferSize(), setGreenBufferSize(), setAlphaBufferSize() +*/ +void QPlatformWindowFormat::setBlueBufferSize(int size) +{ + detach(); + if (size < 0) { + qWarning("QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size); + return; + } + d->blueSize = size; +} + +/*! + \since 4.2 + + Returns the blue buffer size. + + \sa setBlueBufferSize() +*/ +int QPlatformWindowFormat::blueBufferSize() const +{ + return d->blueSize; +} + +/*! + Set the preferred alpha buffer size to \a size. + This function implicitly enables the alpha channel. + + \sa setRedBufferSize(), setGreenBufferSize(), alphaBufferSize() +*/ +void QPlatformWindowFormat::setAlphaBufferSize(int size) +{ + detach(); + if (size < 0) { + qWarning("QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size); + return; + } + d->alphaSize = size; + setAlpha(size > 0); +} + +/*! + Returns the alpha buffer size. + + \sa alpha(), setAlpha(), setAlphaBufferSize() +*/ +int QPlatformWindowFormat::alphaBufferSize() const +{ + return d->alphaSize; +} + +/*! + Set the preferred accumulation buffer size, where \a size is the + bit depth for each RGBA component. + + \sa accum(), setAccum(), accumBufferSize() +*/ +void QPlatformWindowFormat::setAccumBufferSize(int size) +{ + detach(); + if (size < 0) { + qWarning("QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size); + return; + } + d->accumSize = size; + setAccum(size > 0); +} + +/*! + Returns the accumulation buffer size. + + \sa setAccumBufferSize(), accum(), setAccum() +*/ +int QPlatformWindowFormat::accumBufferSize() const +{ + return d->accumSize; +} + +/*! + Set the preferred stencil buffer size to \a size. + + \sa stencilBufferSize(), setStencil(), stencil() +*/ +void QPlatformWindowFormat::setStencilBufferSize(int size) +{ + detach(); + if (size < 0) { + qWarning("QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size); + return; + } + d->stencilSize = size; + setStencil(size > 0); +} + +/*! + Returns the stencil buffer size. + + \sa stencil(), setStencil(), setStencilBufferSize() +*/ +int QPlatformWindowFormat::stencilBufferSize() const +{ + return d->stencilSize; +} + +/*! + \since 4.7 + + Set the OpenGL version to the \a major and \a minor numbers. If a + context compatible with the requested OpenGL version cannot be + created, a context compatible with version 1.x is created instead. + + \sa majorVersion(), minorVersion() +*/ +void QPlatformWindowFormat::setVersion(int major, int minor) +{ + if (major < 1 || minor < 0) { + qWarning("QGLFormat::setVersion: Cannot set zero or negative version number %d.%d", major, minor); + return; + } + detach(); + d->majorVersion = major; + d->minorVersion = minor; +} + +/*! + \since 4.7 + + Returns the OpenGL major version. + + \sa setVersion(), minorVersion() +*/ +int QPlatformWindowFormat::majorVersion() const +{ + return d->majorVersion; +} + +/*! + \since 4.7 + + Returns the OpenGL minor version. + + \sa setVersion(), majorVersion() +*/ +int QPlatformWindowFormat::minorVersion() const +{ + return d->minorVersion; +} + +/*! + \enum QGLFormat::OpenGLContextProfile + \since 4.7 + + This enum describes the OpenGL context profiles that can be + specified for contexts implementing OpenGL version 3.2 or + higher. These profiles are different from OpenGL ES profiles. + + \value NoProfile OpenGL version is lower than 3.2. + \value CoreProfile Functionality deprecated in OpenGL version 3.0 is not available. + \value CompatibilityProfile Functionality from earlier OpenGL versions is available. +*/ + +/*! + \since 4.7 + + Set the OpenGL context profile to \a profile. The \a profile is + ignored if the requested OpenGL version is less than 3.2. + + \sa profile() +*/ +void QPlatformWindowFormat::setProfile(OpenGLContextProfile profile) +{ + detach(); + d->profile = profile; +} + +/*! + \since 4.7 + + Returns the OpenGL context profile. + + \sa setProfile() +*/ +QPlatformWindowFormat::OpenGLContextProfile QPlatformWindowFormat::profile() const +{ + return d->profile; +} + + +/*! + \fn bool QGLFormat::hasOpenGL() + + Returns true if the window system has any OpenGL support; + otherwise returns false. + + \warning This function must not be called until the QApplication + object has been created. +*/ + + + +/*! + \fn bool QGLFormat::hasOpenGLOverlays() + + Returns true if the window system supports OpenGL overlays; + otherwise returns false. + + \warning This function must not be called until the QApplication + object has been created. +*/ + +QPlatformWindowFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(const QString &versionString) +{ + QPlatformWindowFormat::OpenGLVersionFlags versionFlags = QPlatformWindowFormat::OpenGL_Version_None; + + if (versionString.startsWith(QLatin1String("OpenGL ES"))) { + QStringList parts = versionString.split(QLatin1Char(' ')); + if (parts.size() >= 3) { + if (parts[2].startsWith(QLatin1String("1."))) { + if (parts[1].endsWith(QLatin1String("-CM"))) { + versionFlags |= QPlatformWindowFormat::OpenGL_ES_Common_Version_1_0 | + QPlatformWindowFormat::OpenGL_ES_CommonLite_Version_1_0; + if (parts[2].startsWith(QLatin1String("1.1"))) + versionFlags |= QPlatformWindowFormat::OpenGL_ES_Common_Version_1_1 | + QPlatformWindowFormat::OpenGL_ES_CommonLite_Version_1_1; + } else { + // Not -CM, must be CL, CommonLite + versionFlags |= QPlatformWindowFormat::OpenGL_ES_CommonLite_Version_1_0; + if (parts[2].startsWith(QLatin1String("1.1"))) + versionFlags |= QPlatformWindowFormat::OpenGL_ES_CommonLite_Version_1_1; + } + } else { + // OpenGL ES version 2.0 or higher + versionFlags |= QPlatformWindowFormat::OpenGL_ES_Version_2_0; + } + } else { + // if < 3 parts to the name, it is an unrecognised OpenGL ES + qWarning("Unrecognised OpenGL ES version"); + } + } else { + // not ES, regular OpenGL, the version numbers are first in the string + if (versionString.startsWith(QLatin1String("1."))) { + switch (versionString[2].toAscii()) { + case '5': + versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_5; + case '4': + versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_4; + case '3': + versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_3; + case '2': + versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_2; + case '1': + versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1; + default: + break; + } + } else if (versionString.startsWith(QLatin1String("2."))) { + versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1 | + QPlatformWindowFormat::OpenGL_Version_1_2 | + QPlatformWindowFormat::OpenGL_Version_1_3 | + QPlatformWindowFormat::OpenGL_Version_1_4 | + QPlatformWindowFormat::OpenGL_Version_1_5 | + QPlatformWindowFormat::OpenGL_Version_2_0; + if (versionString[2].toAscii() == '1') + versionFlags |= QPlatformWindowFormat::OpenGL_Version_2_1; + } else if (versionString.startsWith(QLatin1String("3."))) { + versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1 | + QPlatformWindowFormat::OpenGL_Version_1_2 | + QPlatformWindowFormat::OpenGL_Version_1_3 | + QPlatformWindowFormat::OpenGL_Version_1_4 | + QPlatformWindowFormat::OpenGL_Version_1_5 | + QPlatformWindowFormat::OpenGL_Version_2_0 | + QPlatformWindowFormat::OpenGL_Version_2_1 | + QPlatformWindowFormat::OpenGL_Version_3_0; + switch (versionString[2].toAscii()) { + case '3': + versionFlags |= QPlatformWindowFormat::OpenGL_Version_3_3; + case '2': + versionFlags |= QPlatformWindowFormat::OpenGL_Version_3_2; + case '1': + versionFlags |= QPlatformWindowFormat::OpenGL_Version_3_1; + case '0': + break; + default: + versionFlags |= QPlatformWindowFormat::OpenGL_Version_3_1 | + QPlatformWindowFormat::OpenGL_Version_3_2 | + QPlatformWindowFormat::OpenGL_Version_3_3; + break; + } + } else if (versionString.startsWith(QLatin1String("4."))) { + versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1 | + QPlatformWindowFormat::OpenGL_Version_1_2 | + QPlatformWindowFormat::OpenGL_Version_1_3 | + QPlatformWindowFormat::OpenGL_Version_1_4 | + QPlatformWindowFormat::OpenGL_Version_1_5 | + QPlatformWindowFormat::OpenGL_Version_2_0 | + QPlatformWindowFormat::OpenGL_Version_2_1 | + QPlatformWindowFormat::OpenGL_Version_3_0 | + QPlatformWindowFormat::OpenGL_Version_3_1 | + QPlatformWindowFormat::OpenGL_Version_3_2 | + QPlatformWindowFormat::OpenGL_Version_3_3 | + QPlatformWindowFormat::OpenGL_Version_4_0; + } else { + versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1 | + QPlatformWindowFormat::OpenGL_Version_1_2 | + QPlatformWindowFormat::OpenGL_Version_1_3 | + QPlatformWindowFormat::OpenGL_Version_1_4 | + QPlatformWindowFormat::OpenGL_Version_1_5 | + QPlatformWindowFormat::OpenGL_Version_2_0 | + QPlatformWindowFormat::OpenGL_Version_2_1 | + QPlatformWindowFormat::OpenGL_Version_3_0 | + QPlatformWindowFormat::OpenGL_Version_3_1 | + QPlatformWindowFormat::OpenGL_Version_3_2 | + QPlatformWindowFormat::OpenGL_Version_3_3 | + QPlatformWindowFormat::OpenGL_Version_4_0; + } + } + return versionFlags; +} + +/*! + \enum QGLFormat::OpenGLVersionFlag + \since 4.2 + + This enum describes the various OpenGL versions that are + recognized by Qt. Use the QGLFormat::openGLVersionFlags() function + to identify which versions that are supported at runtime. + + \value OpenGL_Version_None If no OpenGL is present or if no OpenGL context is current. + + \value OpenGL_Version_1_1 OpenGL version 1.1 or higher is present. + + \value OpenGL_Version_1_2 OpenGL version 1.2 or higher is present. + + \value OpenGL_Version_1_3 OpenGL version 1.3 or higher is present. + + \value OpenGL_Version_1_4 OpenGL version 1.4 or higher is present. + + \value OpenGL_Version_1_5 OpenGL version 1.5 or higher is present. + + \value OpenGL_Version_2_0 OpenGL version 2.0 or higher is present. + Note that version 2.0 supports all the functionality of version 1.5. + + \value OpenGL_Version_2_1 OpenGL version 2.1 or higher is present. + + \value OpenGL_Version_3_0 OpenGL version 3.0 or higher is present. + + \value OpenGL_Version_3_1 OpenGL version 3.1 or higher is present. + Note that OpenGL version 3.1 or higher does not necessarily support all the features of + version 3.0 and lower. + + \value OpenGL_Version_3_2 OpenGL version 3.2 or higher is present. + + \value OpenGL_ES_CommonLite_Version_1_0 OpenGL ES version 1.0 Common Lite or higher is present. + + \value OpenGL_ES_Common_Version_1_0 OpenGL ES version 1.0 Common or higher is present. + The Common profile supports all the features of Common Lite. + + \value OpenGL_ES_CommonLite_Version_1_1 OpenGL ES version 1.1 Common Lite or higher is present. + + \value OpenGL_ES_Common_Version_1_1 OpenGL ES version 1.1 Common or higher is present. + The Common profile supports all the features of Common Lite. + + \value OpenGL_ES_Version_2_0 OpenGL ES version 2.0 or higher is present. + Note that OpenGL ES version 2.0 does not support all the features of OpenGL ES 1.x. + So if OpenGL_ES_Version_2_0 is returned, none of the ES 1.x flags are returned. + + See also \l{http://www.opengl.org} for more information about the different + revisions of OpenGL. + + \sa openGLVersionFlags() +*/ + +/*! + \since 4.2 + + Identifies, at runtime, which OpenGL versions that are supported + by the current platform. + + Note that if OpenGL version 1.5 is supported, its predecessors + (i.e., version 1.4 and lower) are also supported. To identify the + support of a particular feature, like multi texturing, test for + the version in which the feature was first introduced (i.e., + version 1.3 in the case of multi texturing) to adapt to the largest + possible group of runtime platforms. + + This function needs a valid current OpenGL context to work; + otherwise it will return OpenGL_Version_None. + + \sa hasOpenGL(), hasOpenGLOverlays() +*/ +QPlatformWindowFormat::OpenGLVersionFlags QPlatformWindowFormat::openGLVersionFlags() +{ +// static bool cachedDefault = false; + static OpenGLVersionFlags defaultVersionFlags = OpenGL_Version_None; +// QGLContext *currentCtx = const_cast(QGLContext::currentContext()); +// QGLTemporaryContext *tmpContext = 0; + +// if (currentCtx && currentCtx->d_func()->version_flags_cached) +// return currentCtx->d_func()->version_flags; + +// if (!currentCtx) { +// if (cachedDefault) { +// return defaultVersionFlags; +// } else { +// if (!hasOpenGL()) +// return defaultVersionFlags; +// tmpContext = new QGLTemporaryContext; +// cachedDefault = true; +// } +// } + +// QString versionString(QLatin1String(reinterpret_cast(glGetString(GL_VERSION)))); +// OpenGLVersionFlags versionFlags = qOpenGLVersionFlagsFromString(versionString); +// if (currentCtx) { +// currentCtx->d_func()->version_flags_cached = true; +// currentCtx->d_func()->version_flags = versionFlags; +// } +// if (tmpContext) { +// defaultVersionFlags = versionFlags; +// delete tmpContext; +// } + +// return versionFlags; + return defaultVersionFlags; +} + + +/*! + Returns the default QGLFormat for the application. All QGLWidget + objects that are created use this format unless another format is + specified, e.g. when they are constructed. + + If no special default format has been set using + setDefaultFormat(), the default format is the same as that created + with QGLFormat(). + + \sa setDefaultFormat() +*/ + +QPlatformWindowFormat QPlatformWindowFormat::defaultFormat() +{ + return *q_platformwindow_default_format(); +} + +/*! + Sets a new default QGLFormat for the application to \a f. For + example, to set single buffering as the default instead of double + buffering, your main() might contain code like this: + \snippet doc/src/snippets/code/src_opengl_qgl.cpp 4 + + \sa defaultFormat() +*/ + +void QPlatformWindowFormat::setDefaultFormat(const QPlatformWindowFormat &f) +{ + *q_platformwindow_default_format() = f; +} + + +/*! + Returns the default QGLFormat for overlay contexts. + + The default overlay format is: + \list + \i \link setDoubleBuffer() Double buffer:\endlink Disabled. + \i \link setDepth() Depth buffer:\endlink Disabled. + \i \link setRgba() RGBA:\endlink Disabled (i.e., color index enabled). + \i \link setAlpha() Alpha channel:\endlink Disabled. + \i \link setAccum() Accumulator buffer:\endlink Disabled. + \i \link setStencil() Stencil buffer:\endlink Disabled. + \i \link setStereo() Stereo:\endlink Disabled. + \i \link setDirectRendering() Direct rendering:\endlink Enabled. + \i \link setOverlay() Overlay:\endlink Disabled. + \i \link setSampleBuffers() Multisample buffers:\endlink Disabled. + \i \link setPlane() Plane:\endlink 1 (i.e., first overlay plane). + \endlist + + \sa setDefaultFormat() +*/ + +//QPlatformWindowFormat QPlatformWindowFormat::defaultOverlayFormat() +//{ +// return *defaultOverlayFormatInstance(); +//} + +///*! +// Sets a new default QGLFormat for overlay contexts to \a f. This +// format is used whenever a QGLWidget is created with a format that +// hasOverlay() enabled. + +// For example, to get a double buffered overlay context (if +// available), use code like this: + +// \snippet doc/src/snippets/code/src_opengl_qgl.cpp 5 + +// As usual, you can find out after widget creation whether the +// underlying OpenGL system was able to provide the requested +// specification: + +// \snippet doc/src/snippets/code/src_opengl_qgl.cpp 6 + +// \sa defaultOverlayFormat() +//*/ + +//void QPlatformWindowFormat::setDefaultOverlayFormat(const QPlatformWindowFormat &f) +//{ +// QPlatformWindowFormat *defaultFormat = defaultOverlayFormatInstance(); +// *defaultFormat = f; +// // Make sure the user doesn't request that the overlays themselves +// // have overlays, since it is unlikely that the system supports +// // infinitely many planes... +// defaultFormat->setOverlay(false); +//} + + +/*! + Returns true if all the options of the two QGLFormat objects + \a a and \a b are equal; otherwise returns false. + + \relates QGLFormat +*/ + +bool operator==(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b) +{ + return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts + && a.d->alphaSize == b.d->alphaSize + && a.d->accumSize == b.d->accumSize + && a.d->stencilSize == b.d->stencilSize + && a.d->depthSize == b.d->depthSize + && a.d->redSize == b.d->redSize + && a.d->greenSize == b.d->greenSize + && a.d->blueSize == b.d->blueSize + && a.d->numSamples == b.d->numSamples + && a.d->swapInterval == b.d->swapInterval + && a.d->majorVersion == b.d->majorVersion + && a.d->minorVersion == b.d->minorVersion + && a.d->profile == b.d->profile); +} + + +/*! + Returns false if all the options of the two QGLFormat objects + \a a and \a b are equal; otherwise returns true. + + \relates QGLFormat +*/ + +bool operator!=(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b) +{ + return !(a == b); +} diff --git a/src/gui/kernel/qplatformwindowformat_qpa.h b/src/gui/kernel/qplatformwindowformat_qpa.h new file mode 100644 index 0000000..929ad7a --- /dev/null +++ b/src/gui/kernel/qplatformwindowformat_qpa.h @@ -0,0 +1,256 @@ +/**************************************************************************** +** +** 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 QPLATFORMWINDOWFORMAT_QPA_H +#define QPLATFORMWINDOWFORMAT_QPA_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QPlatformWindowFormatPrivate; + +class Q_GUI_EXPORT QPlatformWindowFormat +{ +public: + enum FormatOption { + DoubleBuffer = 0x0001, + DepthBuffer = 0x0002, + Rgba = 0x0004, + AlphaChannel = 0x0008, + AccumBuffer = 0x0010, + StencilBuffer = 0x0020, + StereoBuffers = 0x0040, + DirectRendering = 0x0080, + HasOverlay = 0x0100, + SampleBuffers = 0x0200, + DeprecatedFunctions = 0x0400, + SingleBuffer = DoubleBuffer << 16, + NoDepthBuffer = DepthBuffer << 16, + ColorIndex = Rgba << 16, + NoAlphaChannel = AlphaChannel << 16, + NoAccumBuffer = AccumBuffer << 16, + NoStencilBuffer = StencilBuffer << 16, + NoStereoBuffers = StereoBuffers << 16, + IndirectRendering = DirectRendering << 16, + NoOverlay = HasOverlay << 16, + NoSampleBuffers = SampleBuffers << 16, + NoDeprecatedFunctions = DeprecatedFunctions << 16 + }; + Q_DECLARE_FLAGS(FormatOptions, FormatOption) + + enum OpenGLVersionFlag { + OpenGL_Version_None = 0x00000000, + OpenGL_Version_1_1 = 0x00000001, + OpenGL_Version_1_2 = 0x00000002, + OpenGL_Version_1_3 = 0x00000004, + OpenGL_Version_1_4 = 0x00000008, + OpenGL_Version_1_5 = 0x00000010, + OpenGL_Version_2_0 = 0x00000020, + OpenGL_Version_2_1 = 0x00000040, + OpenGL_ES_Common_Version_1_0 = 0x00000080, + OpenGL_ES_CommonLite_Version_1_0 = 0x00000100, + OpenGL_ES_Common_Version_1_1 = 0x00000200, + OpenGL_ES_CommonLite_Version_1_1 = 0x00000400, + OpenGL_ES_Version_2_0 = 0x00000800, + OpenGL_Version_3_0 = 0x00001000, + OpenGL_Version_3_1 = 0x00002000, + OpenGL_Version_3_2 = 0x00004000, + OpenGL_Version_3_3 = 0x00008000, + OpenGL_Version_4_0 = 0x00010000 + }; + Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag) + + QPlatformWindowFormat(); + QPlatformWindowFormat(FormatOptions options); + QPlatformWindowFormat(const QPlatformWindowFormat &other); + QPlatformWindowFormat &operator=(const QPlatformWindowFormat &other); + ~QPlatformWindowFormat(); + + void setDepthBufferSize(int size); + int depthBufferSize() const; + + void setAccumBufferSize(int size); + int accumBufferSize() const; + + void setRedBufferSize(int size); + int redBufferSize() const; + + void setGreenBufferSize(int size); + int greenBufferSize() const; + + void setBlueBufferSize(int size); + int blueBufferSize() const; + + void setAlphaBufferSize(int size); + int alphaBufferSize() const; + + void setStencilBufferSize(int size); + int stencilBufferSize() const; + + void setSampleBuffers(bool enable); + bool sampleBuffers() const; + + void setSamples(int numSamples); + int samples() const; + + void setSwapInterval(int interval); + int swapInterval() const; + + bool doubleBuffer() const; + void setDoubleBuffer(bool enable); + bool depth() const; + void setDepth(bool enable); + bool rgba() const; + void setRgba(bool enable); + bool alpha() const; + void setAlpha(bool enable); + bool accum() const; + void setAccum(bool enable); + bool stencil() const; + void setStencil(bool enable); + bool stereo() const; + void setStereo(bool enable); + bool directRendering() const; + void setDirectRendering(bool enable); +// bool hasOverlay() const; +// void setOverlay(bool enable); + + void setOption(QPlatformWindowFormat::FormatOptions opt); + bool testOption(QPlatformWindowFormat::FormatOptions opt) const; + + static QPlatformWindowFormat defaultFormat(); + static void setDefaultFormat(const QPlatformWindowFormat& f); + +// static QPlatformWindowFormat defaultOverlayFormat(); +// static void setDefaultOverlayFormat(const QPlatformWindowFormat& f); + + static bool hasOpenGL(); + static bool hasOpenGLOverlays(); + + void setVersion(int major, int minor); + int majorVersion() const; + int minorVersion() const; + + enum OpenGLContextProfile { + NoProfile, + CoreProfile, + CompatibilityProfile + }; + + void setProfile(OpenGLContextProfile profile); + OpenGLContextProfile profile() const; + + + static OpenGLVersionFlags openGLVersionFlags(); + +private: + QPlatformWindowFormatPrivate *d; + + void detach(); + + friend Q_GUI_EXPORT bool operator==(const QPlatformWindowFormat&, const QPlatformWindowFormat&); + friend Q_GUI_EXPORT bool operator!=(const QPlatformWindowFormat&, const QPlatformWindowFormat&); +}; + +Q_GUI_EXPORT bool operator==(const QPlatformWindowFormat&, const QPlatformWindowFormat&); +Q_GUI_EXPORT bool operator!=(const QPlatformWindowFormat&, const QPlatformWindowFormat&); + +Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformWindowFormat::FormatOptions) +Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformWindowFormat::OpenGLVersionFlags) + +inline bool QPlatformWindowFormat::doubleBuffer() const +{ + return testOption(QPlatformWindowFormat::DoubleBuffer); +} + +inline bool QPlatformWindowFormat::depth() const +{ + return testOption(QPlatformWindowFormat::DepthBuffer); +} + +inline bool QPlatformWindowFormat::rgba() const +{ + return testOption(QPlatformWindowFormat::Rgba); +} + +inline bool QPlatformWindowFormat::alpha() const +{ + return testOption(QPlatformWindowFormat::AlphaChannel); +} + +inline bool QPlatformWindowFormat::accum() const +{ + return testOption(QPlatformWindowFormat::AccumBuffer); +} + +inline bool QPlatformWindowFormat::stencil() const +{ + return testOption(QPlatformWindowFormat::StencilBuffer); +} + +inline bool QPlatformWindowFormat::stereo() const +{ + return testOption(QPlatformWindowFormat::StereoBuffers); +} + +inline bool QPlatformWindowFormat::directRendering() const +{ + return testOption(QPlatformWindowFormat::DirectRendering); +} + +//inline bool QPlatformWindowFormat::hasOverlay() const +//{ +// return testOption(QPlatformWindowFormat::HasOverlay); +//} + +inline bool QPlatformWindowFormat::sampleBuffers() const +{ + return testOption(QPlatformWindowFormat::SampleBuffers); +} + + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif //QPLATFORMWINDOWFORMAT_QPA_H diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 53b35dd..943da79 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1662,6 +1662,7 @@ void QWidgetPrivate::createTLExtra() #endif #if defined(Q_WS_QPA) x->platformWindow = 0; + x->platformWindowFormat = QPlatformWindowFormat::defaultFormat(); #endif } } @@ -2455,6 +2456,7 @@ void QWidgetPrivate::createWinId(WId winid) q->create(); } #else + Q_UNUSED(winid); q->create(); #endif //Q_WS_QPA @@ -11937,41 +11939,6 @@ QWindowSurface *QWidget::windowSurface() const return bs ? bs->windowSurface : 0; } -#if defined(Q_WS_QPA) -/*! - \preliminary - - Sets the window to be the \a window specified. - The QWidget takes ownership of the \a surface. -*/ -void QWidget::setPlatformWindow(QPlatformWindow *window) -{ - Q_D(QWidget); - - QTLWExtra *topData = d->topData(); - if (topData->platformWindow == window) - return; - - delete topData->platformWindow; - topData->platformWindow = window; -} - -/*! - \preliminary - - Returns the QPlatformWindow this widget will be drawn into. -*/ -QPlatformWindow *QWidget::platformWindow() const -{ - Q_D(const QWidget); - QTLWExtra *extra = d->maybeTopData(); - if (extra && extra->platformWindow) - return extra->platformWindow; - - return 0; -} -#endif //defined(Q_WS_QPA) - void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const { if (left) diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 8e08ce5..c750465 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -56,6 +56,10 @@ #include #include +#ifdef Q_WS_QPA //should this go somewhere else? +#include +#endif + #ifdef QT_INCLUDE_COMPAT #include #endif @@ -631,6 +635,10 @@ public: #if defined(Q_WS_QPA) void setPlatformWindow(QPlatformWindow *window); QPlatformWindow *platformWindow() const; + + void setPlatformWindowFormat(const QPlatformWindowFormat &format); + QPlatformWindowFormat platformWindowFormat() const; + friend class QDesktopScreenWidget; #endif diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 5274c3b..3903124 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -229,6 +229,7 @@ struct QTLWExtra { uint inExpose : 1; // Prevents drawing recursion #elif defined(Q_WS_QPA) QPlatformWindow *platformWindow; + QPlatformWindowFormat platformWindowFormat; #endif }; diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index 1acf398..4229a05 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -691,6 +691,58 @@ int QWidget::metric(PaintDeviceMetric m) const return val; } +/*! + \preliminary + + Sets the window to be the \a window specified. + The QWidget takes ownership of the \a surface. +*/ +void QWidget::setPlatformWindow(QPlatformWindow *window) +{ + Q_D(QWidget); + + QTLWExtra *topData = d->topData(); + if (topData->platformWindow == window) + return; + + delete topData->platformWindow; + topData->platformWindow = window; +} + +/*! + \preliminary + + Returns the QPlatformWindow this widget will be drawn into. +*/ +QPlatformWindow *QWidget::platformWindow() const +{ + Q_D(const QWidget); + QTLWExtra *extra = d->maybeTopData(); + if (extra && extra->platformWindow) + return extra->platformWindow; + + return 0; +} + +void QWidget::setPlatformWindowFormat(const QPlatformWindowFormat &format) +{ + Q_D(QWidget); + QTLWExtra *topData = d->topData(); + topData->platformWindowFormat = format; +} + +QPlatformWindowFormat QWidget::platformWindowFormat() const +{ + Q_D(const QWidget); + + QTLWExtra *extra = d->maybeTopData(); + if (extra){ + return extra->platformWindowFormat; + } else { + return QPlatformWindowFormat::defaultFormat(); + } +} + void QWidgetPrivate::createSysExtra() { } diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index 52b57d9..eed268e 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -110,10 +110,10 @@ QOpenKODEScreen::QOpenKODEScreen() KDint desktopSize[] = { mode.width, mode.height }; -// if (kdSetDesktopPropertyivNV(kdDesktop, KD_DESKTOPPROPERTY_SIZE_NV, desktopSize)) { -// qErrnoWarning(kdGetError(), "Could not set desktop size"); -// return; -// } + if (kdSetDesktopPropertyivNV(kdDesktop, KD_DESKTOPPROPERTY_SIZE_NV, desktopSize)) { + qErrnoWarning(kdGetError(), "Could not set desktop size"); + return; + } // Once we've set up the desktop and display we don't need them anymore kdReleaseDisplayNV(kdDisplay); diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index 52117ad..f62eae5 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -50,33 +50,243 @@ #include #include #include + +#include #include +QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format) +{ + int redSize = format.redBufferSize(); + int greenSize = format.greenBufferSize(); + int blueSize = format.blueBufferSize(); + int alphaSize = format.alphaBufferSize(); + int depthSize = format.depthBufferSize(); + int stencilSize = format.stencilBufferSize(); + int sampleCount = format.samples(); + + // QPlatformWindowFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that + // type has been requested. So we must check QPlatformWindowFormat's booleans too if size is -1: + if (format.alpha() && alphaSize <= 0) + alphaSize = 1; + if (format.depth() && depthSize <= 0) + depthSize = 1; + if (format.stencil() && stencilSize <= 0) + stencilSize = 1; + if (format.sampleBuffers() && sampleCount <= 0) + sampleCount = 1; + + // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide + // the best performance. The EGL config selection algorithm is a bit stange in this regard: + // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard + // 32-bit configs completely from the selection. So it then comes to the sorting algorithm. + // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort + // order is special and described as "by larger _total_ number of color bits.". So EGL will + // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on + // to say "If the requested number of bits in attrib_list for a particular component is 0, + // then the number of bits for that component is not considered". This part of the spec also + // seems to imply that setting the red/green/blue bits to zero means none of the components + // are considered and EGL disregards the entire sorting rule. It then looks to the next + // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being + // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are + // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit, + // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that + // if the application sets the red/green/blue size to 5/6/5 on the QPlatformWindowFormat, + // they will probably get a 32-bit config, even when there's an RGB565 config avaliable. + + // Now normalize the values so -1 becomes 0 + redSize = redSize > 0 ? redSize : 0; + greenSize = greenSize > 0 ? greenSize : 0; + blueSize = blueSize > 0 ? blueSize : 0; + alphaSize = alphaSize > 0 ? alphaSize : 0; + depthSize = depthSize > 0 ? depthSize : 0; + stencilSize = stencilSize > 0 ? stencilSize : 0; + sampleCount = sampleCount > 0 ? sampleCount : 0; + + QVector configAttributes; + + configAttributes.append(EGL_RED_SIZE); + configAttributes.append(redSize); + + configAttributes.append(EGL_GREEN_SIZE); + configAttributes.append(greenSize); + + configAttributes.append(EGL_BLUE_SIZE); + configAttributes.append(blueSize); + + configAttributes.append(EGL_ALPHA_SIZE); + configAttributes.append(alphaSize); + + configAttributes.append(EGL_DEPTH_SIZE); + configAttributes.append(depthSize); + + configAttributes.append(EGL_STENCIL_SIZE); + configAttributes.append(stencilSize); + + configAttributes.append(EGL_SAMPLES); + configAttributes.append(sampleCount); + + configAttributes.append(EGL_SAMPLE_BUFFERS); + configAttributes.append(sampleCount? 1:0); + + return configAttributes; +} + +bool q_reduceConfigAttributes(QVector *configAttributes) +{ + int i = -1; + // Reduce the complexity of a configuration request to ask for less + // because the previous request did not result in success. Returns + // true if the complexity was reduced, or false if no further + // reductions in complexity are possible. + + i = configAttributes->indexOf(EGL_SWAP_BEHAVIOR); + if (i >= 0) { + configAttributes->remove(i,2); + } + +#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT + // For OpenVG, we sometimes try to create a surface using a pre-multiplied format. If we can't + // find a config which supports pre-multiplied formats, remove the flag on the surface type: + + i = configAttributes->indexOf(EGL_SURFACE_TYPE); + if (i >= 0) { + EGLint surfaceType = configAttributes->at(i +1); + if (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) { + surfaceType ^= EGL_VG_ALPHA_FORMAT_PRE_BIT; + configAttributes->replace(i+1,surfaceType); + return true; + } + } +#endif + + // EGL chooses configs with the highest color depth over + // those with smaller (but faster) lower color depths. One + // way around this is to set EGL_BUFFER_SIZE to 16, which + // trumps the others. Of course, there may not be a 16-bit + // config avaliable, so it's the first restraint we remove. + i = configAttributes->indexOf(EGL_BUFFER_SIZE); + if (i >= 0) { + if (configAttributes->at(i+1) == 16) { + configAttributes->remove(i,2); + return true; + } + } + + i = configAttributes->indexOf(EGL_SAMPLE_BUFFERS); + if (i >= 0) { + configAttributes->remove(i,2); + i = configAttributes->indexOf(EGL_SAMPLES); + if (i >= 0) { + configAttributes->remove(i,2); + } + return true; + } + + i = configAttributes->indexOf(EGL_ALPHA_SIZE); + if (i >= 0) { + configAttributes->remove(i,2); +#if defined(EGL_BIND_TO_TEXTURE_RGBA) && defined(EGL_BIND_TO_TEXTURE_RGB) + i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGBA); + if (i >= 0) { + configAttributes->replace(i,EGL_BIND_TO_TEXTURE_RGB); + configAttributes->replace(i+1,TRUE); + + } +#endif + return true; + } + + i = configAttributes->indexOf(EGL_STENCIL_SIZE); + if (i >= 0) { + configAttributes->remove(i,2); + return true; + } + i = configAttributes->indexOf(EGL_DEPTH_SIZE); + if (i >= 0) { + configAttributes->remove(i,2); + return true; + } +#ifdef EGL_BIND_TO_TEXTURE_RGB + i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGB); + if (i >= 0) { + configAttributes->remove(i,2); + return true; + } +#endif + + return false; +} + +EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, EGLenum eglApi) +{ + EGLConfig cfg = 0; + QVector configureAttributes = q_createConfigAttributesFromFormat(format); + configureAttributes.append(EGL_SURFACE_TYPE); + configureAttributes.append(EGL_WINDOW_BIT); + + configureAttributes.append(EGL_RENDERABLE_TYPE); + configureAttributes.append(EGL_OPENGL_ES2_BIT); + + configureAttributes.append(EGL_NONE); + + do { + // Get the number of matching configurations for this set of properties. + EGLint matching = 0; + 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; +// } + + // Fetch all of the matching configurations and find the + // first that matches the pixel format we wanted. + int i = configureAttributes.indexOf(EGL_RED_SIZE); + int confAttrRed = configureAttributes.at(i+1); + i = configureAttributes.indexOf(EGL_GREEN_SIZE); + int confAttrGreen = configureAttributes.at(i+1); + i = configureAttributes.indexOf(EGL_BLUE_SIZE); + int confAttrBlue = configureAttributes.at(i+1); + i = configureAttributes.indexOf(EGL_ALPHA_SIZE); + int confAttrAlpha = configureAttributes.at(i+1); + + EGLint size = matching; + EGLConfig *configs = new EGLConfig [size]; + eglChooseConfig(display, configureAttributes.constData(), configs, size, &matching); + for (EGLint index = 0; index < size; ++index) { + EGLint red, green, blue, alpha; + eglGetConfigAttrib(display, configs[index], EGL_RED_SIZE, &red); + eglGetConfigAttrib(display, configs[index], EGL_GREEN_SIZE, &green); + eglGetConfigAttrib(display, configs[index], EGL_BLUE_SIZE, &blue); + eglGetConfigAttrib(display, configs[index], EGL_ALPHA_SIZE, &alpha); +// qDebug() << "red" << red << confAttrRed; +// qDebug() << "green" << green << confAttrGreen; +// qDebug() << "blue" << blue << confAttrBlue; +// qDebug() << "alpha" << alpha << confAttrAlpha << (confAttrAlpha == 0 || alpha == confAttrAlpha); + if (red == confAttrRed && + green == confAttrGreen && + blue == confAttrBlue && + (confAttrAlpha == 0 || + alpha == confAttrAlpha)) { + cfg = configs[index]; + delete [] configs; + return cfg; + } + } + delete [] configs; + } while (q_reduceConfigAttributes(&configureAttributes)); + qDebug() << "RETURNING NULL!"; + return 0; +} + QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) : QPlatformWindow(tlw) { - EGLint configAttrs[] = { - EGL_RED_SIZE, 1, - EGL_GREEN_SIZE, 1, - EGL_BLUE_SIZE, 1, - EGL_BUFFER_SIZE, 16, - EGL_DEPTH_SIZE, 0, - EGL_LEVEL, 0, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, -// #ifdef EGL_NV_coverage_sample -// EGL_COVERAGE_BUFFERS_NV, 1, -// EGL_COVERAGE_SAMPLES_NV, 5, -// #endif - EGL_ALPHA_SIZE, 0, -// EGL_LUMINANCE_SIZE, 0, - EGL_ALPHA_MASK_SIZE, 0, - EGL_SAMPLES, 0, - EGL_SAMPLE_BUFFERS, 0, -// EGL_STENCIL_SIZE, 0, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_TRANSPARENT_TYPE, EGL_NONE, - EGL_NONE - }; m_eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); m_eglContextAttrs.append(2); @@ -98,33 +308,13 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) qErrnoWarning("Could not make QOpenKODEWindow without a screen"); } - EGLint configCount; - // Find out how many configurations suit our needs - EGLBoolean eglStatus = eglChooseConfig(screen->eglDisplay(), configAttrs, - KD_NULL, 0, &configCount); - if (!eglStatus || !configCount) { - qErrnoWarning("EGL failed to return any matching configurations"); - } - - qDebug() << "config count" << configCount; - - // Allocate room for the list of matching configurations - EGLConfig *configList = (EGLConfig*)kdMalloc(configCount * sizeof(EGLConfig)); - if (!configList) { - qErrnoWarning("kdMalloc failure obtaining configuration list"); - } + QPlatformWindowFormat format = tlw->platformWindowFormat(); + format.setRedBufferSize(5); + format.setGreenBufferSize(6); + format.setBlueBufferSize(5); + tlw->setPlatformWindowFormat(format); - // Obtain the configuration list from EGL - eglStatus = eglChooseConfig(screen->eglDisplay(), configAttrs, - configList, configCount, &configCount); - if (!eglStatus || !configCount) { - qErrnoWarning("EGL failed to populate configuration list"); - } - - // Select an EGL configuration that matches the native window - - m_eglConfig = configList[11]; - kdFree(configList);//free the list not the configs + m_eglConfig = q_configFromQPlatformWindowFormat(screen->eglDisplay(),tlw->platformWindowFormat(),m_eglApi); m_kdWindow = kdCreateWindow(screen->eglDisplay(), m_eglConfig, @@ -156,10 +346,6 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) return; } - KDint32 layer = 1; - kdGetWindowPropertyiv(m_kdWindow,KD_WINDOWPROPERTY_DESKTOP_LAYER_NV,&layer); - qDebug() << "LAYER:" << layer; - EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(), m_eglConfig, -- cgit v0.12 From 82ea3e45567dbe83d97638124e7351dc462afe3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 12 Jul 2010 09:43:04 +0200 Subject: clean up QPlatformWindowFormat --- src/gui/kernel/qapplication.cpp | 2 + src/gui/kernel/qplatformintegration_qpa.h | 2 +- src/gui/kernel/qplatformwindowformat_qpa.cpp | 342 ++------------------------- src/gui/kernel/qplatformwindowformat_qpa.h | 47 +--- 4 files changed, 25 insertions(+), 368 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index e1ed588..ac79958 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -6032,6 +6032,8 @@ QPixmap QApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) default: break; } +#else + Q_UNUSED(cshape); #endif return QPixmap(); } diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h index ea0ed35..8c1659f 100644 --- a/src/gui/kernel/qplatformintegration_qpa.h +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -42,8 +42,8 @@ #ifndef QPLATFORMINTEGRATION_H #define QPLATFORMINTEGRATION_H -#include #include +#include #include QT_BEGIN_HEADER diff --git a/src/gui/kernel/qplatformwindowformat_qpa.cpp b/src/gui/kernel/qplatformwindowformat_qpa.cpp index 4ded26b..bc234ab 100644 --- a/src/gui/kernel/qplatformwindowformat_qpa.cpp +++ b/src/gui/kernel/qplatformwindowformat_qpa.cpp @@ -62,7 +62,7 @@ public: , swapInterval(-1) , majorVersion(1) , minorVersion(0) - , profile(QPlatformWindowFormat::NoProfile) + , windowApi(QPlatformWindowFormat::Raster) { } @@ -80,7 +80,7 @@ public: swapInterval(other->swapInterval), majorVersion(other->majorVersion), minorVersion(other->minorVersion), - profile(other->profile) + windowApi(other->windowApi) { } QAtomicInt ref; @@ -96,7 +96,7 @@ public: int swapInterval; int majorVersion; int minorVersion; - QPlatformWindowFormat::OpenGLContextProfile profile; + QPlatformWindowFormat::WindowApi windowApi; }; /*! @@ -584,6 +584,17 @@ int QPlatformWindowFormat::swapInterval() const return d->swapInterval; } +void QPlatformWindowFormat::setWindowApi(QPlatformWindowFormat::WindowApi api) +{ + detach(); + d->windowApi = api; +} + +QPlatformWindowFormat::WindowApi QPlatformWindowFormat::windowApi() const +{ + return d->windowApi; +} + ///*! // \fn bool QGLFormat::hasOverlay() const @@ -835,329 +846,6 @@ int QPlatformWindowFormat::stencilBufferSize() const } /*! - \since 4.7 - - Set the OpenGL version to the \a major and \a minor numbers. If a - context compatible with the requested OpenGL version cannot be - created, a context compatible with version 1.x is created instead. - - \sa majorVersion(), minorVersion() -*/ -void QPlatformWindowFormat::setVersion(int major, int minor) -{ - if (major < 1 || minor < 0) { - qWarning("QGLFormat::setVersion: Cannot set zero or negative version number %d.%d", major, minor); - return; - } - detach(); - d->majorVersion = major; - d->minorVersion = minor; -} - -/*! - \since 4.7 - - Returns the OpenGL major version. - - \sa setVersion(), minorVersion() -*/ -int QPlatformWindowFormat::majorVersion() const -{ - return d->majorVersion; -} - -/*! - \since 4.7 - - Returns the OpenGL minor version. - - \sa setVersion(), majorVersion() -*/ -int QPlatformWindowFormat::minorVersion() const -{ - return d->minorVersion; -} - -/*! - \enum QGLFormat::OpenGLContextProfile - \since 4.7 - - This enum describes the OpenGL context profiles that can be - specified for contexts implementing OpenGL version 3.2 or - higher. These profiles are different from OpenGL ES profiles. - - \value NoProfile OpenGL version is lower than 3.2. - \value CoreProfile Functionality deprecated in OpenGL version 3.0 is not available. - \value CompatibilityProfile Functionality from earlier OpenGL versions is available. -*/ - -/*! - \since 4.7 - - Set the OpenGL context profile to \a profile. The \a profile is - ignored if the requested OpenGL version is less than 3.2. - - \sa profile() -*/ -void QPlatformWindowFormat::setProfile(OpenGLContextProfile profile) -{ - detach(); - d->profile = profile; -} - -/*! - \since 4.7 - - Returns the OpenGL context profile. - - \sa setProfile() -*/ -QPlatformWindowFormat::OpenGLContextProfile QPlatformWindowFormat::profile() const -{ - return d->profile; -} - - -/*! - \fn bool QGLFormat::hasOpenGL() - - Returns true if the window system has any OpenGL support; - otherwise returns false. - - \warning This function must not be called until the QApplication - object has been created. -*/ - - - -/*! - \fn bool QGLFormat::hasOpenGLOverlays() - - Returns true if the window system supports OpenGL overlays; - otherwise returns false. - - \warning This function must not be called until the QApplication - object has been created. -*/ - -QPlatformWindowFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(const QString &versionString) -{ - QPlatformWindowFormat::OpenGLVersionFlags versionFlags = QPlatformWindowFormat::OpenGL_Version_None; - - if (versionString.startsWith(QLatin1String("OpenGL ES"))) { - QStringList parts = versionString.split(QLatin1Char(' ')); - if (parts.size() >= 3) { - if (parts[2].startsWith(QLatin1String("1."))) { - if (parts[1].endsWith(QLatin1String("-CM"))) { - versionFlags |= QPlatformWindowFormat::OpenGL_ES_Common_Version_1_0 | - QPlatformWindowFormat::OpenGL_ES_CommonLite_Version_1_0; - if (parts[2].startsWith(QLatin1String("1.1"))) - versionFlags |= QPlatformWindowFormat::OpenGL_ES_Common_Version_1_1 | - QPlatformWindowFormat::OpenGL_ES_CommonLite_Version_1_1; - } else { - // Not -CM, must be CL, CommonLite - versionFlags |= QPlatformWindowFormat::OpenGL_ES_CommonLite_Version_1_0; - if (parts[2].startsWith(QLatin1String("1.1"))) - versionFlags |= QPlatformWindowFormat::OpenGL_ES_CommonLite_Version_1_1; - } - } else { - // OpenGL ES version 2.0 or higher - versionFlags |= QPlatformWindowFormat::OpenGL_ES_Version_2_0; - } - } else { - // if < 3 parts to the name, it is an unrecognised OpenGL ES - qWarning("Unrecognised OpenGL ES version"); - } - } else { - // not ES, regular OpenGL, the version numbers are first in the string - if (versionString.startsWith(QLatin1String("1."))) { - switch (versionString[2].toAscii()) { - case '5': - versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_5; - case '4': - versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_4; - case '3': - versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_3; - case '2': - versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_2; - case '1': - versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1; - default: - break; - } - } else if (versionString.startsWith(QLatin1String("2."))) { - versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1 | - QPlatformWindowFormat::OpenGL_Version_1_2 | - QPlatformWindowFormat::OpenGL_Version_1_3 | - QPlatformWindowFormat::OpenGL_Version_1_4 | - QPlatformWindowFormat::OpenGL_Version_1_5 | - QPlatformWindowFormat::OpenGL_Version_2_0; - if (versionString[2].toAscii() == '1') - versionFlags |= QPlatformWindowFormat::OpenGL_Version_2_1; - } else if (versionString.startsWith(QLatin1String("3."))) { - versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1 | - QPlatformWindowFormat::OpenGL_Version_1_2 | - QPlatformWindowFormat::OpenGL_Version_1_3 | - QPlatformWindowFormat::OpenGL_Version_1_4 | - QPlatformWindowFormat::OpenGL_Version_1_5 | - QPlatformWindowFormat::OpenGL_Version_2_0 | - QPlatformWindowFormat::OpenGL_Version_2_1 | - QPlatformWindowFormat::OpenGL_Version_3_0; - switch (versionString[2].toAscii()) { - case '3': - versionFlags |= QPlatformWindowFormat::OpenGL_Version_3_3; - case '2': - versionFlags |= QPlatformWindowFormat::OpenGL_Version_3_2; - case '1': - versionFlags |= QPlatformWindowFormat::OpenGL_Version_3_1; - case '0': - break; - default: - versionFlags |= QPlatformWindowFormat::OpenGL_Version_3_1 | - QPlatformWindowFormat::OpenGL_Version_3_2 | - QPlatformWindowFormat::OpenGL_Version_3_3; - break; - } - } else if (versionString.startsWith(QLatin1String("4."))) { - versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1 | - QPlatformWindowFormat::OpenGL_Version_1_2 | - QPlatformWindowFormat::OpenGL_Version_1_3 | - QPlatformWindowFormat::OpenGL_Version_1_4 | - QPlatformWindowFormat::OpenGL_Version_1_5 | - QPlatformWindowFormat::OpenGL_Version_2_0 | - QPlatformWindowFormat::OpenGL_Version_2_1 | - QPlatformWindowFormat::OpenGL_Version_3_0 | - QPlatformWindowFormat::OpenGL_Version_3_1 | - QPlatformWindowFormat::OpenGL_Version_3_2 | - QPlatformWindowFormat::OpenGL_Version_3_3 | - QPlatformWindowFormat::OpenGL_Version_4_0; - } else { - versionFlags |= QPlatformWindowFormat::OpenGL_Version_1_1 | - QPlatformWindowFormat::OpenGL_Version_1_2 | - QPlatformWindowFormat::OpenGL_Version_1_3 | - QPlatformWindowFormat::OpenGL_Version_1_4 | - QPlatformWindowFormat::OpenGL_Version_1_5 | - QPlatformWindowFormat::OpenGL_Version_2_0 | - QPlatformWindowFormat::OpenGL_Version_2_1 | - QPlatformWindowFormat::OpenGL_Version_3_0 | - QPlatformWindowFormat::OpenGL_Version_3_1 | - QPlatformWindowFormat::OpenGL_Version_3_2 | - QPlatformWindowFormat::OpenGL_Version_3_3 | - QPlatformWindowFormat::OpenGL_Version_4_0; - } - } - return versionFlags; -} - -/*! - \enum QGLFormat::OpenGLVersionFlag - \since 4.2 - - This enum describes the various OpenGL versions that are - recognized by Qt. Use the QGLFormat::openGLVersionFlags() function - to identify which versions that are supported at runtime. - - \value OpenGL_Version_None If no OpenGL is present or if no OpenGL context is current. - - \value OpenGL_Version_1_1 OpenGL version 1.1 or higher is present. - - \value OpenGL_Version_1_2 OpenGL version 1.2 or higher is present. - - \value OpenGL_Version_1_3 OpenGL version 1.3 or higher is present. - - \value OpenGL_Version_1_4 OpenGL version 1.4 or higher is present. - - \value OpenGL_Version_1_5 OpenGL version 1.5 or higher is present. - - \value OpenGL_Version_2_0 OpenGL version 2.0 or higher is present. - Note that version 2.0 supports all the functionality of version 1.5. - - \value OpenGL_Version_2_1 OpenGL version 2.1 or higher is present. - - \value OpenGL_Version_3_0 OpenGL version 3.0 or higher is present. - - \value OpenGL_Version_3_1 OpenGL version 3.1 or higher is present. - Note that OpenGL version 3.1 or higher does not necessarily support all the features of - version 3.0 and lower. - - \value OpenGL_Version_3_2 OpenGL version 3.2 or higher is present. - - \value OpenGL_ES_CommonLite_Version_1_0 OpenGL ES version 1.0 Common Lite or higher is present. - - \value OpenGL_ES_Common_Version_1_0 OpenGL ES version 1.0 Common or higher is present. - The Common profile supports all the features of Common Lite. - - \value OpenGL_ES_CommonLite_Version_1_1 OpenGL ES version 1.1 Common Lite or higher is present. - - \value OpenGL_ES_Common_Version_1_1 OpenGL ES version 1.1 Common or higher is present. - The Common profile supports all the features of Common Lite. - - \value OpenGL_ES_Version_2_0 OpenGL ES version 2.0 or higher is present. - Note that OpenGL ES version 2.0 does not support all the features of OpenGL ES 1.x. - So if OpenGL_ES_Version_2_0 is returned, none of the ES 1.x flags are returned. - - See also \l{http://www.opengl.org} for more information about the different - revisions of OpenGL. - - \sa openGLVersionFlags() -*/ - -/*! - \since 4.2 - - Identifies, at runtime, which OpenGL versions that are supported - by the current platform. - - Note that if OpenGL version 1.5 is supported, its predecessors - (i.e., version 1.4 and lower) are also supported. To identify the - support of a particular feature, like multi texturing, test for - the version in which the feature was first introduced (i.e., - version 1.3 in the case of multi texturing) to adapt to the largest - possible group of runtime platforms. - - This function needs a valid current OpenGL context to work; - otherwise it will return OpenGL_Version_None. - - \sa hasOpenGL(), hasOpenGLOverlays() -*/ -QPlatformWindowFormat::OpenGLVersionFlags QPlatformWindowFormat::openGLVersionFlags() -{ -// static bool cachedDefault = false; - static OpenGLVersionFlags defaultVersionFlags = OpenGL_Version_None; -// QGLContext *currentCtx = const_cast(QGLContext::currentContext()); -// QGLTemporaryContext *tmpContext = 0; - -// if (currentCtx && currentCtx->d_func()->version_flags_cached) -// return currentCtx->d_func()->version_flags; - -// if (!currentCtx) { -// if (cachedDefault) { -// return defaultVersionFlags; -// } else { -// if (!hasOpenGL()) -// return defaultVersionFlags; -// tmpContext = new QGLTemporaryContext; -// cachedDefault = true; -// } -// } - -// QString versionString(QLatin1String(reinterpret_cast(glGetString(GL_VERSION)))); -// OpenGLVersionFlags versionFlags = qOpenGLVersionFlagsFromString(versionString); -// if (currentCtx) { -// currentCtx->d_func()->version_flags_cached = true; -// currentCtx->d_func()->version_flags = versionFlags; -// } -// if (tmpContext) { -// defaultVersionFlags = versionFlags; -// delete tmpContext; -// } - -// return versionFlags; - return defaultVersionFlags; -} - - -/*! Returns the default QGLFormat for the application. All QGLWidget objects that are created use this format unless another format is specified, e.g. when they are constructed. @@ -1266,7 +954,7 @@ bool operator==(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b) && a.d->swapInterval == b.d->swapInterval && a.d->majorVersion == b.d->majorVersion && a.d->minorVersion == b.d->minorVersion - && a.d->profile == b.d->profile); + && a.d->windowApi == b.d->windowApi); } diff --git a/src/gui/kernel/qplatformwindowformat_qpa.h b/src/gui/kernel/qplatformwindowformat_qpa.h index 929ad7a..3c5f907 100644 --- a/src/gui/kernel/qplatformwindowformat_qpa.h +++ b/src/gui/kernel/qplatformwindowformat_qpa.h @@ -78,27 +78,11 @@ public: }; Q_DECLARE_FLAGS(FormatOptions, FormatOption) - enum OpenGLVersionFlag { - OpenGL_Version_None = 0x00000000, - OpenGL_Version_1_1 = 0x00000001, - OpenGL_Version_1_2 = 0x00000002, - OpenGL_Version_1_3 = 0x00000004, - OpenGL_Version_1_4 = 0x00000008, - OpenGL_Version_1_5 = 0x00000010, - OpenGL_Version_2_0 = 0x00000020, - OpenGL_Version_2_1 = 0x00000040, - OpenGL_ES_Common_Version_1_0 = 0x00000080, - OpenGL_ES_CommonLite_Version_1_0 = 0x00000100, - OpenGL_ES_Common_Version_1_1 = 0x00000200, - OpenGL_ES_CommonLite_Version_1_1 = 0x00000400, - OpenGL_ES_Version_2_0 = 0x00000800, - OpenGL_Version_3_0 = 0x00001000, - OpenGL_Version_3_1 = 0x00002000, - OpenGL_Version_3_2 = 0x00004000, - OpenGL_Version_3_3 = 0x00008000, - OpenGL_Version_4_0 = 0x00010000 + enum WindowApi { + Raster, + OpenGL, + OpenVG }; - Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag) QPlatformWindowFormat(); QPlatformWindowFormat(FormatOptions options); @@ -136,6 +120,9 @@ public: void setSwapInterval(int interval); int swapInterval() const; + void setWindowApi(QPlatformWindowFormat::WindowApi api); + WindowApi windowApi() const; + bool doubleBuffer() const; void setDoubleBuffer(bool enable); bool depth() const; @@ -164,25 +151,6 @@ public: // static QPlatformWindowFormat defaultOverlayFormat(); // static void setDefaultOverlayFormat(const QPlatformWindowFormat& f); - static bool hasOpenGL(); - static bool hasOpenGLOverlays(); - - void setVersion(int major, int minor); - int majorVersion() const; - int minorVersion() const; - - enum OpenGLContextProfile { - NoProfile, - CoreProfile, - CompatibilityProfile - }; - - void setProfile(OpenGLContextProfile profile); - OpenGLContextProfile profile() const; - - - static OpenGLVersionFlags openGLVersionFlags(); - private: QPlatformWindowFormatPrivate *d; @@ -196,7 +164,6 @@ Q_GUI_EXPORT bool operator==(const QPlatformWindowFormat&, const QPlatformWindow Q_GUI_EXPORT bool operator!=(const QPlatformWindowFormat&, const QPlatformWindowFormat&); Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformWindowFormat::FormatOptions) -Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformWindowFormat::OpenGLVersionFlags) inline bool QPlatformWindowFormat::doubleBuffer() const { -- cgit v0.12 From 4892e8fcebdbdb8a612189682f3a18db6cb51158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 12 Jul 2010 10:34:20 +0200 Subject: Lighthouse egl refactoring Moved the openkode egl code into a convenience directory so it can be used by other plugins --- .../platforms/eglconvenience/qeglconvenience.cpp | 233 +++++++++++++++++++ .../platforms/eglconvenience/qeglconvenience.h | 54 +++++ .../eglconvenience/qeglplatformcontext.cpp | 104 +++++++++ .../platforms/eglconvenience/qeglplatformcontext.h | 66 ++++++ src/plugins/platforms/openkode/openkode.pro | 6 +- .../platforms/openkode/qopenkodeglintegration.cpp | 108 --------- .../platforms/openkode/qopenkodeglintegration.h | 66 ------ .../platforms/openkode/qopenkodeintegration.cpp | 24 +- src/plugins/platforms/openkode/qopenkodewindow.cpp | 250 +-------------------- 9 files changed, 494 insertions(+), 417 deletions(-) create mode 100644 src/plugins/platforms/eglconvenience/qeglconvenience.cpp create mode 100644 src/plugins/platforms/eglconvenience/qeglconvenience.h create mode 100644 src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp create mode 100644 src/plugins/platforms/eglconvenience/qeglplatformcontext.h delete mode 100644 src/plugins/platforms/openkode/qopenkodeglintegration.cpp delete mode 100644 src/plugins/platforms/openkode/qopenkodeglintegration.h diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp new file mode 100644 index 0000000..1064e47 --- /dev/null +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp @@ -0,0 +1,233 @@ +#include "qeglconvenience.h" + +#include + +QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format) +{ + int redSize = format.redBufferSize(); + int greenSize = format.greenBufferSize(); + int blueSize = format.blueBufferSize(); + int alphaSize = format.alphaBufferSize(); + int depthSize = format.depthBufferSize(); + int stencilSize = format.stencilBufferSize(); + int sampleCount = format.samples(); + + // QPlatformWindowFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that + // type has been requested. So we must check QPlatformWindowFormat's booleans too if size is -1: + if (format.alpha() && alphaSize <= 0) + alphaSize = 1; + if (format.depth() && depthSize <= 0) + depthSize = 1; + if (format.stencil() && stencilSize <= 0) + stencilSize = 1; + if (format.sampleBuffers() && sampleCount <= 0) + sampleCount = 1; + + // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide + // the best performance. The EGL config selection algorithm is a bit stange in this regard: + // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard + // 32-bit configs completely from the selection. So it then comes to the sorting algorithm. + // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort + // order is special and described as "by larger _total_ number of color bits.". So EGL will + // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on + // to say "If the requested number of bits in attrib_list for a particular component is 0, + // then the number of bits for that component is not considered". This part of the spec also + // seems to imply that setting the red/green/blue bits to zero means none of the components + // are considered and EGL disregards the entire sorting rule. It then looks to the next + // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being + // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are + // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit, + // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that + // if the application sets the red/green/blue size to 5/6/5 on the QPlatformWindowFormat, + // they will probably get a 32-bit config, even when there's an RGB565 config avaliable. + + // Now normalize the values so -1 becomes 0 + redSize = redSize > 0 ? redSize : 0; + greenSize = greenSize > 0 ? greenSize : 0; + blueSize = blueSize > 0 ? blueSize : 0; + alphaSize = alphaSize > 0 ? alphaSize : 0; + depthSize = depthSize > 0 ? depthSize : 0; + stencilSize = stencilSize > 0 ? stencilSize : 0; + sampleCount = sampleCount > 0 ? sampleCount : 0; + + QVector configAttributes; + + configAttributes.append(EGL_RED_SIZE); + configAttributes.append(redSize); + + configAttributes.append(EGL_GREEN_SIZE); + configAttributes.append(greenSize); + + configAttributes.append(EGL_BLUE_SIZE); + configAttributes.append(blueSize); + + configAttributes.append(EGL_ALPHA_SIZE); + configAttributes.append(alphaSize); + + configAttributes.append(EGL_DEPTH_SIZE); + configAttributes.append(depthSize); + + configAttributes.append(EGL_STENCIL_SIZE); + configAttributes.append(stencilSize); + + configAttributes.append(EGL_SAMPLES); + configAttributes.append(sampleCount); + + configAttributes.append(EGL_SAMPLE_BUFFERS); + configAttributes.append(sampleCount? 1:0); + + return configAttributes; +} + +bool q_reduceConfigAttributes(QVector *configAttributes) +{ + int i = -1; + // Reduce the complexity of a configuration request to ask for less + // because the previous request did not result in success. Returns + // true if the complexity was reduced, or false if no further + // reductions in complexity are possible. + + i = configAttributes->indexOf(EGL_SWAP_BEHAVIOR); + if (i >= 0) { + configAttributes->remove(i,2); + } + +#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT + // For OpenVG, we sometimes try to create a surface using a pre-multiplied format. If we can't + // find a config which supports pre-multiplied formats, remove the flag on the surface type: + + i = configAttributes->indexOf(EGL_SURFACE_TYPE); + if (i >= 0) { + EGLint surfaceType = configAttributes->at(i +1); + if (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) { + surfaceType ^= EGL_VG_ALPHA_FORMAT_PRE_BIT; + configAttributes->replace(i+1,surfaceType); + return true; + } + } +#endif + + // EGL chooses configs with the highest color depth over + // those with smaller (but faster) lower color depths. One + // way around this is to set EGL_BUFFER_SIZE to 16, which + // trumps the others. Of course, there may not be a 16-bit + // config avaliable, so it's the first restraint we remove. + i = configAttributes->indexOf(EGL_BUFFER_SIZE); + if (i >= 0) { + if (configAttributes->at(i+1) == 16) { + configAttributes->remove(i,2); + return true; + } + } + + i = configAttributes->indexOf(EGL_SAMPLE_BUFFERS); + if (i >= 0) { + configAttributes->remove(i,2); + i = configAttributes->indexOf(EGL_SAMPLES); + if (i >= 0) { + configAttributes->remove(i,2); + } + return true; + } + + i = configAttributes->indexOf(EGL_ALPHA_SIZE); + if (i >= 0) { + configAttributes->remove(i,2); +#if defined(EGL_BIND_TO_TEXTURE_RGBA) && defined(EGL_BIND_TO_TEXTURE_RGB) + i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGBA); + if (i >= 0) { + configAttributes->replace(i,EGL_BIND_TO_TEXTURE_RGB); + configAttributes->replace(i+1,TRUE); + + } +#endif + return true; + } + + i = configAttributes->indexOf(EGL_STENCIL_SIZE); + if (i >= 0) { + configAttributes->remove(i,2); + return true; + } + i = configAttributes->indexOf(EGL_DEPTH_SIZE); + if (i >= 0) { + configAttributes->remove(i,2); + return true; + } +#ifdef EGL_BIND_TO_TEXTURE_RGB + i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGB); + if (i >= 0) { + configAttributes->remove(i,2); + return true; + } +#endif + + return false; +} + +EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format) +{ + EGLConfig cfg = 0; + QVector configureAttributes = q_createConfigAttributesFromFormat(format); + configureAttributes.append(EGL_SURFACE_TYPE); //we only support eglconfigs for windows for now + configureAttributes.append(EGL_WINDOW_BIT); + + configureAttributes.append(EGL_RENDERABLE_TYPE); + if (format.windowApi() == QPlatformWindowFormat::OpenVG) { + configureAttributes.append(EGL_OPENVG_BIT); + } else { + configureAttributes.append(EGL_OPENGL_ES2_BIT); + } + + configureAttributes.append(EGL_NONE); + + do { + // Get the number of matching configurations for this set of properties. + EGLint matching = 0; + 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; +// } + + // Fetch all of the matching configurations and find the + // first that matches the pixel format we wanted. + int i = configureAttributes.indexOf(EGL_RED_SIZE); + int confAttrRed = configureAttributes.at(i+1); + i = configureAttributes.indexOf(EGL_GREEN_SIZE); + int confAttrGreen = configureAttributes.at(i+1); + i = configureAttributes.indexOf(EGL_BLUE_SIZE); + int confAttrBlue = configureAttributes.at(i+1); + i = configureAttributes.indexOf(EGL_ALPHA_SIZE); + int confAttrAlpha = configureAttributes.at(i+1); + + EGLint size = matching; + EGLConfig *configs = new EGLConfig [size]; + eglChooseConfig(display, configureAttributes.constData(), configs, size, &matching); + for (EGLint index = 0; index < size; ++index) { + EGLint red, green, blue, alpha; + eglGetConfigAttrib(display, configs[index], EGL_RED_SIZE, &red); + eglGetConfigAttrib(display, configs[index], EGL_GREEN_SIZE, &green); + eglGetConfigAttrib(display, configs[index], EGL_BLUE_SIZE, &blue); + eglGetConfigAttrib(display, configs[index], EGL_ALPHA_SIZE, &alpha); + if (red == confAttrRed && + green == confAttrGreen && + blue == confAttrBlue && + (confAttrAlpha == 0 || + alpha == confAttrAlpha)) { + cfg = configs[index]; + delete [] configs; + return cfg; + } + } + delete [] configs; + } while (q_reduceConfigAttributes(&configureAttributes)); + qDebug() << "RETURNING NULL!"; + return 0; +} diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h new file mode 100644 index 0000000..bd5a6d3 --- /dev/null +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QEGLCONVENIENCE_H +#define QEGLCONVENIENCE_H + +#include + +#include +#include + +QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format); +bool q_reduceConfigAttributes(QVector *configAttributes); +EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format); + + +#endif //QEGLCONVENIENCE_H diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp new file mode 100644 index 0000000..6afeb70 --- /dev/null +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qeglplatformcontext.h" + +#include + +#include +#include + +QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi) + : m_eglDisplay(display) + , m_eglSurface(surface) + , m_eglApi(eglApi) +{ + if (m_eglSurface == EGL_NO_SURFACE) { + qWarning("Createing QEGLPlatformContext with no surface"); + } + + eglBindAPI(m_eglApi); + m_eglContext = eglCreateContext(m_eglDisplay,config, 0,contextAttrs); + if (!m_eglContext) { + qErrnoWarning("QEGLPlatformContext could not create eglContext"); + } +} + +QEGLPlatformContext::~QEGLPlatformContext() +{ + if (m_eglSurface != EGL_NO_SURFACE) { + doneCurrent(); + eglDestroySurface(m_eglDisplay, m_eglSurface); + m_eglSurface = EGL_NO_SURFACE; + } + + if (m_eglContext != EGL_NO_CONTEXT) { + eglDestroyContext(m_eglDisplay, m_eglContext); + m_eglContext = EGL_NO_CONTEXT; + } +} + +void QEGLPlatformContext::makeCurrent() +{ + eglBindAPI(m_eglApi); + bool ok = eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext); + if (!ok) + qWarning() << "QEGLPlatformContext::makeCurrent(" << m_eglSurface << "):" << eglGetError(); +} +void QEGLPlatformContext::doneCurrent() +{ + eglBindAPI(m_eglApi); + bool ok = eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + if (!ok) + qWarning() << "QEGLPlatformContext::doneCurrent():" << eglGetError(); +} +void QEGLPlatformContext::swapBuffers() +{ + eglBindAPI(m_eglApi); + bool ok = eglSwapBuffers(m_eglDisplay, m_eglSurface); + if (!ok) + qWarning() << "QEGLPlatformContext::swapBuffers():" << eglGetError(); +} +void* QEGLPlatformContext::getProcAddress(const QString& procName) +{ + eglBindAPI(m_eglApi); + return (void *)eglGetProcAddress(qPrintable(procName)); +} diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h new file mode 100644 index 0000000..19d155a --- /dev/null +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOPENKODEGLINTEGRATION_H +#define QOPENKODEGLINTEGRATION_H + +#include +#include + +class QEGLPlatformContext : public QPlatformGLContext +{ +public: + QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi); + ~QEGLPlatformContext(); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString& procName); + +private: + EGLContext m_eglContext; + EGLDisplay m_eglDisplay; + EGLSurface m_eglSurface; + EGLenum m_eglApi; +}; + +#endif //QOPENKODEGLINTEGRATION_H diff --git a/src/plugins/platforms/openkode/openkode.pro b/src/plugins/platforms/openkode/openkode.pro index 0614b3b..c039131 100644 --- a/src/plugins/platforms/openkode/openkode.pro +++ b/src/plugins/platforms/openkode/openkode.pro @@ -9,12 +9,14 @@ SOURCES = main.cpp \ qopenkodeintegration.cpp \ qopenkodewindowsurface.cpp \ qopenkodewindow.cpp \ - qopenkodeglintegration.cpp + ../eglconvenience/qeglplatformcontext.cpp \ + ../eglconvenience/qeglconvenience.cpp HEADERS = qopenkodeintegration.h \ qopenkodewindowsurface.h \ qopenkodewindow.h \ - qopenkodeglintegration.h + ../eglconvenience/qeglplatformcontext.h \ + ../eglconvenience/qeglconvenience.h RESOURCES = resources.qrc diff --git a/src/plugins/platforms/openkode/qopenkodeglintegration.cpp b/src/plugins/platforms/openkode/qopenkodeglintegration.cpp deleted file mode 100644 index 4296876..0000000 --- a/src/plugins/platforms/openkode/qopenkodeglintegration.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qopenkodeglintegration.h" - -#include - -#include -#include -#include - -#include - - -QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi) - : m_eglDisplay(display) - , m_eglSurface(surface) - , m_eglApi(eglApi) -{ - if (m_eglSurface == EGL_NO_SURFACE) { - qWarning("Createing QEGLPlatformContext with no surface"); - } - - eglBindAPI(m_eglApi); - m_eglContext = eglCreateContext(m_eglDisplay,config, KD_NULL,contextAttrs); - if (!m_eglContext) { - qErrnoWarning("QEGLPlatformContext could not create eglContext"); - } -} - -QEGLPlatformContext::~QEGLPlatformContext() -{ - if (m_eglSurface != EGL_NO_SURFACE) { - doneCurrent(); - eglDestroySurface(m_eglDisplay, m_eglSurface); - m_eglSurface = EGL_NO_SURFACE; - } - - if (m_eglContext != EGL_NO_CONTEXT) { - eglDestroyContext(m_eglDisplay, m_eglContext); - m_eglContext = EGL_NO_CONTEXT; - } -} - -void QEGLPlatformContext::makeCurrent() -{ - eglBindAPI(m_eglApi); - bool ok = eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext); - if (!ok) - qWarning() << "QEGLPlatformContext::makeCurrent(" << m_eglSurface << "):" << eglGetError(); -} -void QEGLPlatformContext::doneCurrent() -{ - eglBindAPI(m_eglApi); - bool ok = eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - if (!ok) - qWarning() << "QEGLPlatformContext::doneCurrent():" << eglGetError(); -} -void QEGLPlatformContext::swapBuffers() -{ - eglBindAPI(m_eglApi); - bool ok = eglSwapBuffers(m_eglDisplay, m_eglSurface); - if (!ok) - qWarning() << "QEGLPlatformContext::swapBuffers():" << eglGetError(); -} -void* QEGLPlatformContext::getProcAddress(const QString& procName) -{ - eglBindAPI(m_eglApi); - return (void *)eglGetProcAddress(qPrintable(procName)); -} diff --git a/src/plugins/platforms/openkode/qopenkodeglintegration.h b/src/plugins/platforms/openkode/qopenkodeglintegration.h deleted file mode 100644 index 19d155a..0000000 --- a/src/plugins/platforms/openkode/qopenkodeglintegration.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QOPENKODEGLINTEGRATION_H -#define QOPENKODEGLINTEGRATION_H - -#include -#include - -class QEGLPlatformContext : public QPlatformGLContext -{ -public: - QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi); - ~QEGLPlatformContext(); - - void makeCurrent(); - void doneCurrent(); - void swapBuffers(); - void* getProcAddress(const QString& procName); - -private: - EGLContext m_eglContext; - EGLDisplay m_eglDisplay; - EGLSurface m_eglSurface; - EGLenum m_eglApi; -}; - -#endif //QOPENKODEGLINTEGRATION_H diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index eed268e..270763b 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -42,7 +42,6 @@ #include "qopenkodeintegration.h" #include "qopenkodewindowsurface.h" #include "qopenkodewindow.h" -#include "qopenkodeglintegration.h" #include #include @@ -238,8 +237,27 @@ QPlatformWindow *QOpenKODEIntegration::createPlatformWindow(QWidget *tlw, WId ) QWindowSurface *QOpenKODEIntegration::createWindowSurface(QWidget *widget, WId wid) const { -// return new QOpenKODEWindowSurface(widget, wid); - return new QGLWindowSurface(widget); + QWindowSurface *returnSurface = 0; + switch (widget->platformWindowFormat().windowApi()) { + + case QPlatformWindowFormat::Raster: + returnSurface = new QOpenKODEWindowSurface(widget, wid); + break; + + case QPlatformWindowFormat::OpenGL: + returnSurface = new QGLWindowSurface(widget); + break; + + case QPlatformWindowFormat::OpenVG: +// returnSurface = new QVGWindowSurface(widget); + break; + + default: + returnSurface = new QGLWindowSurface(widget); + break; + } + + return returnSurface; } bool QOpenKODEIntegration::hasOpenGL() const diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index f62eae5..2213a8f 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -40,7 +40,8 @@ ****************************************************************************/ #include "qopenkodewindow.h" #include "qopenkodeintegration.h" -#include "qopenkodeglintegration.h" +#include "../eglconvenience/qeglplatformcontext.h" +#include "../eglconvenience/qeglconvenience.h" #include #include @@ -54,251 +55,25 @@ #include #include -QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format) -{ - int redSize = format.redBufferSize(); - int greenSize = format.greenBufferSize(); - int blueSize = format.blueBufferSize(); - int alphaSize = format.alphaBufferSize(); - int depthSize = format.depthBufferSize(); - int stencilSize = format.stencilBufferSize(); - int sampleCount = format.samples(); - - // QPlatformWindowFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that - // type has been requested. So we must check QPlatformWindowFormat's booleans too if size is -1: - if (format.alpha() && alphaSize <= 0) - alphaSize = 1; - if (format.depth() && depthSize <= 0) - depthSize = 1; - if (format.stencil() && stencilSize <= 0) - stencilSize = 1; - if (format.sampleBuffers() && sampleCount <= 0) - sampleCount = 1; - - // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide - // the best performance. The EGL config selection algorithm is a bit stange in this regard: - // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard - // 32-bit configs completely from the selection. So it then comes to the sorting algorithm. - // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort - // order is special and described as "by larger _total_ number of color bits.". So EGL will - // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on - // to say "If the requested number of bits in attrib_list for a particular component is 0, - // then the number of bits for that component is not considered". This part of the spec also - // seems to imply that setting the red/green/blue bits to zero means none of the components - // are considered and EGL disregards the entire sorting rule. It then looks to the next - // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being - // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are - // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit, - // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that - // if the application sets the red/green/blue size to 5/6/5 on the QPlatformWindowFormat, - // they will probably get a 32-bit config, even when there's an RGB565 config avaliable. - - // Now normalize the values so -1 becomes 0 - redSize = redSize > 0 ? redSize : 0; - greenSize = greenSize > 0 ? greenSize : 0; - blueSize = blueSize > 0 ? blueSize : 0; - alphaSize = alphaSize > 0 ? alphaSize : 0; - depthSize = depthSize > 0 ? depthSize : 0; - stencilSize = stencilSize > 0 ? stencilSize : 0; - sampleCount = sampleCount > 0 ? sampleCount : 0; - - QVector configAttributes; - - configAttributes.append(EGL_RED_SIZE); - configAttributes.append(redSize); - - configAttributes.append(EGL_GREEN_SIZE); - configAttributes.append(greenSize); - configAttributes.append(EGL_BLUE_SIZE); - configAttributes.append(blueSize); - - configAttributes.append(EGL_ALPHA_SIZE); - configAttributes.append(alphaSize); - - configAttributes.append(EGL_DEPTH_SIZE); - configAttributes.append(depthSize); - - configAttributes.append(EGL_STENCIL_SIZE); - configAttributes.append(stencilSize); - - configAttributes.append(EGL_SAMPLES); - configAttributes.append(sampleCount); - - configAttributes.append(EGL_SAMPLE_BUFFERS); - configAttributes.append(sampleCount? 1:0); - - return configAttributes; -} -bool q_reduceConfigAttributes(QVector *configAttributes) +QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) + : QPlatformWindow(tlw) { - int i = -1; - // Reduce the complexity of a configuration request to ask for less - // because the previous request did not result in success. Returns - // true if the complexity was reduced, or false if no further - // reductions in complexity are possible. - - i = configAttributes->indexOf(EGL_SWAP_BEHAVIOR); - if (i >= 0) { - configAttributes->remove(i,2); - } -#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT - // For OpenVG, we sometimes try to create a surface using a pre-multiplied format. If we can't - // find a config which supports pre-multiplied formats, remove the flag on the surface type: + if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenVG) { + m_eglApi = EGL_OPENVG_API; + } else { + m_eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); + m_eglContextAttrs.append(2); - i = configAttributes->indexOf(EGL_SURFACE_TYPE); - if (i >= 0) { - EGLint surfaceType = configAttributes->at(i +1); - if (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) { - surfaceType ^= EGL_VG_ALPHA_FORMAT_PRE_BIT; - configAttributes->replace(i+1,surfaceType); - return true; - } + m_eglApi = EGL_OPENGL_ES_API; } -#endif - - // EGL chooses configs with the highest color depth over - // those with smaller (but faster) lower color depths. One - // way around this is to set EGL_BUFFER_SIZE to 16, which - // trumps the others. Of course, there may not be a 16-bit - // config avaliable, so it's the first restraint we remove. - i = configAttributes->indexOf(EGL_BUFFER_SIZE); - if (i >= 0) { - if (configAttributes->at(i+1) == 16) { - configAttributes->remove(i,2); - return true; - } - } - - i = configAttributes->indexOf(EGL_SAMPLE_BUFFERS); - if (i >= 0) { - configAttributes->remove(i,2); - i = configAttributes->indexOf(EGL_SAMPLES); - if (i >= 0) { - configAttributes->remove(i,2); - } - return true; - } - - i = configAttributes->indexOf(EGL_ALPHA_SIZE); - if (i >= 0) { - configAttributes->remove(i,2); -#if defined(EGL_BIND_TO_TEXTURE_RGBA) && defined(EGL_BIND_TO_TEXTURE_RGB) - i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGBA); - if (i >= 0) { - configAttributes->replace(i,EGL_BIND_TO_TEXTURE_RGB); - configAttributes->replace(i+1,TRUE); - - } -#endif - return true; - } - - i = configAttributes->indexOf(EGL_STENCIL_SIZE); - if (i >= 0) { - configAttributes->remove(i,2); - return true; - } - i = configAttributes->indexOf(EGL_DEPTH_SIZE); - if (i >= 0) { - configAttributes->remove(i,2); - return true; - } -#ifdef EGL_BIND_TO_TEXTURE_RGB - i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGB); - if (i >= 0) { - configAttributes->remove(i,2); - return true; - } -#endif - - return false; -} - -EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, EGLenum eglApi) -{ - EGLConfig cfg = 0; - QVector configureAttributes = q_createConfigAttributesFromFormat(format); - configureAttributes.append(EGL_SURFACE_TYPE); - configureAttributes.append(EGL_WINDOW_BIT); - - configureAttributes.append(EGL_RENDERABLE_TYPE); - configureAttributes.append(EGL_OPENGL_ES2_BIT); - - configureAttributes.append(EGL_NONE); - - do { - // Get the number of matching configurations for this set of properties. - EGLint matching = 0; - 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; -// } - - // Fetch all of the matching configurations and find the - // first that matches the pixel format we wanted. - int i = configureAttributes.indexOf(EGL_RED_SIZE); - int confAttrRed = configureAttributes.at(i+1); - i = configureAttributes.indexOf(EGL_GREEN_SIZE); - int confAttrGreen = configureAttributes.at(i+1); - i = configureAttributes.indexOf(EGL_BLUE_SIZE); - int confAttrBlue = configureAttributes.at(i+1); - i = configureAttributes.indexOf(EGL_ALPHA_SIZE); - int confAttrAlpha = configureAttributes.at(i+1); - - EGLint size = matching; - EGLConfig *configs = new EGLConfig [size]; - eglChooseConfig(display, configureAttributes.constData(), configs, size, &matching); - for (EGLint index = 0; index < size; ++index) { - EGLint red, green, blue, alpha; - eglGetConfigAttrib(display, configs[index], EGL_RED_SIZE, &red); - eglGetConfigAttrib(display, configs[index], EGL_GREEN_SIZE, &green); - eglGetConfigAttrib(display, configs[index], EGL_BLUE_SIZE, &blue); - eglGetConfigAttrib(display, configs[index], EGL_ALPHA_SIZE, &alpha); -// qDebug() << "red" << red << confAttrRed; -// qDebug() << "green" << green << confAttrGreen; -// qDebug() << "blue" << blue << confAttrBlue; -// qDebug() << "alpha" << alpha << confAttrAlpha << (confAttrAlpha == 0 || alpha == confAttrAlpha); - if (red == confAttrRed && - green == confAttrGreen && - blue == confAttrBlue && - (confAttrAlpha == 0 || - alpha == confAttrAlpha)) { - cfg = configs[index]; - delete [] configs; - return cfg; - } - } - delete [] configs; - } while (q_reduceConfigAttributes(&configureAttributes)); - qDebug() << "RETURNING NULL!"; - return 0; -} - -QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) - : QPlatformWindow(tlw) -{ + eglBindAPI(m_eglApi); - m_eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); - m_eglContextAttrs.append(2); m_eglContextAttrs.append(EGL_NONE); - -// m_eglWindowAttrs.append(EGL_RENDER_BUFFER); -// m_eglWindowAttrs.append(EGL_BACK_BUFFER); m_eglWindowAttrs.append(EGL_NONE); - m_eglApi = EGL_OPENGL_ES_API; - eglBindAPI(m_eglApi); - QList screens = QApplicationPrivate::platformIntegration()->screens(); //XXXX: jl figure out how to pick the correct screen. // Q_ASSERT(screens.size() > tlw->d_func()->screenNumber); @@ -314,7 +89,7 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) format.setBlueBufferSize(5); tlw->setPlatformWindowFormat(format); - m_eglConfig = q_configFromQPlatformWindowFormat(screen->eglDisplay(),tlw->platformWindowFormat(),m_eglApi); + m_eglConfig = q_configFromQPlatformWindowFormat(screen->eglDisplay(),tlw->platformWindowFormat()); m_kdWindow = kdCreateWindow(screen->eglDisplay(), m_eglConfig, @@ -360,7 +135,6 @@ QOpenKODEWindow::~QOpenKODEWindow() } void QOpenKODEWindow::setGeometry(const QRect &rect) { - qDebug() << "setting geo"; const QRect geo = geometry(); if (geo.size() != rect.size()) { const KDint windowSize[2] = { rect.width(), rect.height() -1 }; -- cgit v0.12 From ad0d0c4b6f7958b3cde01855b0f3b9c68db5253a Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 12 Jul 2010 15:42:55 +0200 Subject: Add full-screen EGL-based GL backend QGLWidget doesn't work yet --- src/plugins/platforms/eglfs/eglintegration.cpp | 469 +++++++++++++++++++++++++ src/plugins/platforms/eglfs/eglintegration.h | 70 ++++ src/plugins/platforms/eglfs/eglintegration.pro | 14 + src/plugins/platforms/eglfs/main.cpp | 72 ++++ 4 files changed, 625 insertions(+) create mode 100644 src/plugins/platforms/eglfs/eglintegration.cpp create mode 100644 src/plugins/platforms/eglfs/eglintegration.h create mode 100644 src/plugins/platforms/eglfs/eglintegration.pro create mode 100644 src/plugins/platforms/eglfs/main.cpp diff --git a/src/plugins/platforms/eglfs/eglintegration.cpp b/src/plugins/platforms/eglfs/eglintegration.cpp new file mode 100644 index 0000000..5ea0bb2 --- /dev/null +++ b/src/plugins/platforms/eglfs/eglintegration.cpp @@ -0,0 +1,469 @@ +/**************************************************************************** +** +** 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 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 "eglintegration.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "../eglconvenience/qeglconvenience.h" + +//#define QEGL_EXTRA_DEBUG +#ifdef QEGL_EXTRA_DEBUG +struct AttrInfo { EGLint attr; const char *name; }; +static struct AttrInfo attrs[] = { + {EGL_BUFFER_SIZE, "EGL_BUFFER_SIZE"}, + {EGL_ALPHA_SIZE, "EGL_ALPHA_SIZE"}, + {EGL_BLUE_SIZE, "EGL_BLUE_SIZE"}, + {EGL_GREEN_SIZE, "EGL_GREEN_SIZE"}, + {EGL_RED_SIZE, "EGL_RED_SIZE"}, + {EGL_DEPTH_SIZE, "EGL_DEPTH_SIZE"}, + {EGL_STENCIL_SIZE, "EGL_STENCIL_SIZE"}, + {EGL_CONFIG_CAVEAT, "EGL_CONFIG_CAVEAT"}, + {EGL_CONFIG_ID, "EGL_CONFIG_ID"}, + {EGL_LEVEL, "EGL_LEVEL"}, + {EGL_MAX_PBUFFER_HEIGHT, "EGL_MAX_PBUFFER_HEIGHT"}, + {EGL_MAX_PBUFFER_PIXELS, "EGL_MAX_PBUFFER_PIXELS"}, + {EGL_MAX_PBUFFER_WIDTH, "EGL_MAX_PBUFFER_WIDTH"}, + {EGL_NATIVE_RENDERABLE, "EGL_NATIVE_RENDERABLE"}, + {EGL_NATIVE_VISUAL_ID, "EGL_NATIVE_VISUAL_ID"}, + {EGL_NATIVE_VISUAL_TYPE, "EGL_NATIVE_VISUAL_TYPE"}, + {EGL_SAMPLES, "EGL_SAMPLES"}, + {EGL_SAMPLE_BUFFERS, "EGL_SAMPLE_BUFFERS"}, + {EGL_SURFACE_TYPE, "EGL_SURFACE_TYPE"}, + {EGL_TRANSPARENT_TYPE, "EGL_TRANSPARENT_TYPE"}, + {EGL_TRANSPARENT_BLUE_VALUE, "EGL_TRANSPARENT_BLUE_VALUE"}, + {EGL_TRANSPARENT_GREEN_VALUE, "EGL_TRANSPARENT_GREEN_VALUE"}, + {EGL_TRANSPARENT_RED_VALUE, "EGL_TRANSPARENT_RED_VALUE"}, + {EGL_BIND_TO_TEXTURE_RGB, "EGL_BIND_TO_TEXTURE_RGB"}, + {EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA"}, + {EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL"}, + {EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL"}, + {-1, 0}}; +#endif //QEGL_EXTRA_DEBUG + + +class QEglScreen; + +class QEglContext : public QPlatformGLContext +{ +public: + QEglContext(QGLFormat& format, QPlatformGLContext* shareContext = 0); + ~QEglContext(); + + virtual void makeCurrent(); + virtual void doneCurrent(); + virtual void swapBuffers(); + virtual void* getProcAddress(const QString& procName); + + EGLContext eglContext() {return m_context;} + QSize size() const { return m_size; } + + QGLFormat format() const { return m_format; } +private: + + EGLContext m_context; + EGLDisplay m_dpy; + EGLSurface m_surface; + QSize m_size; + static bool singleton_watch; + QGLFormat m_format; +}; + +bool QEglContext::singleton_watch = false; + +QEglContext::QEglContext(QGLFormat& format, QPlatformGLContext* shareContext) +{ + if (singleton_watch) + qFatal("There can be only one"); + singleton_watch = true; + + Q_UNUSED(shareContext); + Q_UNUSED(format); + + EGLint major, minor; +#ifdef QEGL_EXTRA_DEBUG + EGLint index; +#endif + if (!eglBindAPI(EGL_OPENGL_ES_API)) { + fprintf(stderr, "Could not bind GL_ES API\n"); + qFatal("EGL error"); + } + + m_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (m_dpy == EGL_NO_DISPLAY) { + fprintf(stderr, "Could not open egl display\n"); + qFatal("EGL error"); + } + fprintf(stderr, "Opened display %p\n", m_dpy); + + if (!eglInitialize(m_dpy, &major, &minor)) { + fprintf(stderr, "Could not initialize egl display\n"); + qFatal("EGL error"); + } + + fprintf(stderr, "Initialized display %d %d\n", major, minor); + + QPlatformWindowFormat platformFormat; + platformFormat.setDepth(16); + platformFormat.setWindowApi(QPlatformWindowFormat::OpenGL); + platformFormat.setRedBufferSize(5); + platformFormat.setGreenBufferSize(6); + platformFormat.setBlueBufferSize(5); + EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat); + +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "Configuration %d matches requirements\n", (int)config); + + for (index = 0; attrs[index].attr != -1; ++index) { + EGLint value; + if (eglGetConfigAttrib(m_dpy, config, attrs[index].attr, &value)) { + printf("\t%s: %d\n", attrs[index].name, (int)value); + } + } + printf("\n"); +#endif + EGLint temp; + EGLint attribList[32]; + + temp = 0; + + attribList[temp++] = EGL_CONTEXT_CLIENT_VERSION; + attribList[temp++] = 2; // GLES version 2 + attribList[temp++] = EGL_NONE; + + + m_context = eglCreateContext(m_dpy, config, NULL, attribList); + if (m_context == EGL_NO_CONTEXT) { + fprintf(stderr, "Could not create the egl context\n"); + eglTerminate(m_dpy); + qFatal("EGL error"); + } + + m_surface = eglCreateWindowSurface(m_dpy, config, 0, NULL); + if (m_surface == EGL_NO_SURFACE) { + fprintf(stderr, "Could not create the egl surface: error = 0x%x\n", eglGetError()); + eglTerminate(m_dpy); + qFatal("EGL error"); + } + + EGLint w,h; + + eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w); + eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h); + fprintf(stderr, "Created surface %dx%d\n", w, h); + + m_size = QSize(w,h); + + +} + +QEglContext::~QEglContext() +{ +#ifdef QEGL_EXTRA_DEBUG + qDebug() << "QEglContext::~QEglContext()"; +#endif +} + +void QEglContext::makeCurrent() +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglContext::makeCurrent\n"); +#endif + if (!eglMakeCurrent(m_dpy, m_surface, m_surface, m_context)) + fprintf(stderr, "Could not make the egl context current\n"); + +#ifdef QEGL_EXTRA_DEBUG + static bool showDebug = true; + if (showDebug) { + showDebug = false; + const char *str = (const char*)glGetString(GL_VENDOR); + qDebug() << "Vendor" << str; + printf("Vendor %s\n", str); + str = (const char*)glGetString(GL_RENDERER); + qDebug() << "Renderer" << str; + printf("Renderer %s\n", str); + str = (const char*)glGetString(GL_VERSION); + qDebug() << "Version" << str; + printf("Version %s\n", str); + + str = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); + qDebug() << "Shader version" << str; + + str = (const char*)glGetString(GL_EXTENSIONS); + qDebug() << "Extensions" << str; + printf("Extensions %s\n", str); + + } +#endif +} + +void QEglContext::doneCurrent() +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglContext::doneCurrent\n"); +#endif + if (!eglMakeCurrent(m_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) + fprintf(stderr, "Could not release the egl context\n"); +} + +void QEglContext::swapBuffers() +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglContext::swapBuffers\n"); +#endif + eglSwapBuffers(m_dpy, m_surface); +} + +void* QEglContext::getProcAddress(const QString& procName) +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglContext::getProcAddress\n"); +#endif + return (void*)eglGetProcAddress(qPrintable(procName)); +} + + +class QEglPaintDevice; +class QEglScreen : public QPlatformScreen +{ +public: + QEglScreen(); + ~QEglScreen() {} + + QRect geometry() const { /*qDebug() << "QEglScreen::geometry()";*/ return m_geometry; } + int depth() const { qDebug() << "QEglScreen::depth()"; return m_depth; } + QImage::Format format() const {qDebug() << "QEglScreen::format()"; return m_format; } + //QSize physicalSize() const { return m_physicalSize; } //### + +public: + QRect m_geometry; + int m_depth; + QImage::Format m_format; + //QSize m_physicalSize; + QEglContext * m_platformContext; +}; + + +class QEglWindow : public QPlatformWindow +{ +public: + QEglWindow(QWidget *w, QEglScreen *screen); + QPlatformGLContext *glContext(); + + void setGeometry(const QRect &); + WId winId() const; + + QGLContext *context() { return m_context; } + QEglPaintDevice *paintDevice() { return m_pd; } +private: + QEglScreen *m_screen; + QEglPaintDevice *m_pd; + QGLContext *m_context; + WId m_winid; +}; + +class QEglPaintDevice : public QGLPaintDevice +{ +public: + QEglPaintDevice(QEglScreen *screen, QEglWindow *window); + + QSize size() const { return m_screen->geometry().size(); } + QGLContext* context() const { return m_window->context();} + + QPaintEngine *paintEngine() const { return qt_qgl_paint_engine(); } + + void beginPaint(){ + QGLPaintDevice::beginPaint(); + } +private: + QEglScreen *m_screen; + QEglWindow * m_window; +}; + + + + +QEglScreen::QEglScreen() + : m_depth(16), m_format(QImage::Format_RGB16), m_platformContext(0) +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglScreen %p\n", this); +#endif + QGLFormat format = QGLFormat::defaultFormat(); + m_platformContext = new QEglContext(format); + + + m_geometry = QRect(QPoint(), m_platformContext->size()); + +} + + + + +QEglPaintDevice::QEglPaintDevice(QEglScreen *screen, QEglWindow *window) + :QGLPaintDevice(), m_screen(screen), m_window(window) +{ +#ifdef QEGL_EXTRA_DEBUG + qDebug() << "QEglPaintDevice" << this << screen << window; +#endif +} + + + +QEglWindow::QEglWindow(QWidget *w, QEglScreen *screen) + : QPlatformWindow(w), m_screen(screen), m_pd(0), m_context(0) +{ + static int serialNo = 0; + m_winid = ++serialNo; +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglWindow %p: %p %p 0x%x\n", this, w, screen, uint(m_winid)); +#endif + m_pd = new QEglPaintDevice(screen, this); + m_context = new QGLContext( screen->m_platformContext->format(), w); + m_context->create(); +} + + +void QEglWindow::setGeometry(const QRect &) +{ + // We only support full-screen windows + QRect rect(m_screen->availableGeometry()); + QWindowSystemInterface::handleGeometryChange(this->widget(), rect); + + QPlatformWindow::setGeometry(rect); +} + +WId QEglWindow::winId() const +{ + return m_winid; +} + + + +QPlatformGLContext *QEglWindow::glContext() +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglWindow::glContext %p\n", m_screen->m_platformContext); +#endif + Q_ASSERT(m_screen); + return m_screen->m_platformContext; +} + +QEglIntegration::QEglIntegration() +{ + m_primaryScreen = new QEglScreen(); + + mScreens.append(m_primaryScreen); +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglIntegration\n"); +#endif +} + +QPixmapData *QEglIntegration::createPixmapData(QPixmapData::PixelType type) const +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglIntegration::createPixmapData %d\n", type); +#endif + return new QGLPixmapData(type); +} + +QPlatformWindow *QEglIntegration::createPlatformWindow(QWidget *widget, WId winId) const +{ + Q_UNUSED(winId); +#ifdef QEGL_EXTRA_DEBUG + qDebug() << "QEglIntegration::createPlatformWindow" << widget; +#endif + return new QEglWindow(widget, m_primaryScreen); +} + + +class QEglWindowSurface : public QWindowSurface +{ +public: + QEglWindowSurface(QWidget *window, QEglScreen *screen); + ~QEglWindowSurface() {} + + QPaintDevice *paintDevice() { return m_window->paintDevice(); } + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void resize(const QSize &size) {} +private: + QEglScreen *m_screen; + QEglWindow *m_window; +}; + +QEglWindowSurface::QEglWindowSurface(QWidget *window, QEglScreen *screen) + :QWindowSurface(window), m_screen(screen), m_window(0) +{ +#ifdef QEGL_EXTRA_DEBUG + qDebug() << "QEglWindowSurface" << window << screen; +#endif + m_window = static_cast(window->platformWindow()); +} + + +void QEglWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); +#ifdef QEGL_EXTRA_DEBUG + qDebug() << "QEglWindowSurface::flush"; +#endif + m_screen->m_platformContext->swapBuffers(); +} + +QWindowSurface *QEglIntegration::createWindowSurface(QWidget *widget, WId winId) const +{ + Q_UNUSED(winId); + +#ifdef QEGL_EXTRA_DEBUG + qDebug() << "QEglIntegration::createWindowSurface" << widget; +#endif + return new QEglWindowSurface(widget, m_primaryScreen); +} diff --git a/src/plugins/platforms/eglfs/eglintegration.h b/src/plugins/platforms/eglfs/eglintegration.h new file mode 100644 index 0000000..7b9b8cf --- /dev/null +++ b/src/plugins/platforms/eglfs/eglintegration.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 EGLINTEGRATION_H +#define EGLINTEGRATION_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QEglScreen; +class QEglIntegration : public QPlatformIntegration +{ +public: + QEglIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + + QList screens() const { return mScreens; } + +private: + QList mScreens; + QEglScreen *m_primaryScreen; +}; + +QT_END_NAMESPACE + + +#endif diff --git a/src/plugins/platforms/eglfs/eglintegration.pro b/src/plugins/platforms/eglfs/eglintegration.pro new file mode 100644 index 0000000..7cd2f05 --- /dev/null +++ b/src/plugins/platforms/eglfs/eglintegration.pro @@ -0,0 +1,14 @@ +TARGET = eglintegration +TEMPLATE = lib +CONFIG += plugin + +QT += opengl + +SOURCES = main.cpp \ + eglintegration.cpp \ + ../eglconvenience/qeglconvenience.cpp +HEADERS = eglintegration.h \ + ../eglconvenience/qeglconvenience.h + +target.path += $$[QT_INSTALL_PLUGINS]/platforms +INSTALLS += target diff --git a/src/plugins/platforms/eglfs/main.cpp b/src/plugins/platforms/eglfs/main.cpp new file mode 100644 index 0000000..adaea78 --- /dev/null +++ b/src/plugins/platforms/eglfs/main.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** 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 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 +#include "eglintegration.h" + +QT_BEGIN_NAMESPACE + +class QEglIntegrationPlugin : public QPlatformIntegrationPlugin +{ +public: + QStringList keys() const; + QPlatformIntegration *create(const QString&, const QStringList&); +}; + +QStringList QEglIntegrationPlugin::keys() const +{ + QStringList list; + list << "EglFS"; + return list; +} + +QPlatformIntegration* QEglIntegrationPlugin::create(const QString& system, const QStringList& paramList) +{ + Q_UNUSED(paramList); + if (system.toLower() == "eglfs") + return new QEglIntegration; + + return 0; +} + +Q_EXPORT_PLUGIN2(eglintegration, QEglIntegrationPlugin) + +QT_END_NAMESPACE -- cgit v0.12 From bc5f5d99078d9ca1f4fc80fc7d0fe753d5ef396a Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 14 Jul 2010 15:51:25 +0200 Subject: Temporary hack so QtOpenGL compiles for Lighthouse --- src/opengl/qgl.cpp | 4 ++-- src/opengl/qwindowsurface_gl.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 4353d4b..2f16b99 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2263,7 +2263,7 @@ static void convertToGLFormatHelper(QImage &dst, const QImage &img, GLenum textu } } -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) QGLExtensionFuncs& QGLContextPrivate::extensionFuncs(const QGLContext *) { return qt_extensionFuncs; @@ -5301,7 +5301,7 @@ void QGLWidgetPrivate::initContext(QGLContext *context, const QGLWidget* shareWi glcx = new QGLContext(QGLFormat::defaultFormat(), q); } -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) Q_GLOBAL_STATIC(QString, qt_gl_lib_name) Q_OPENGL_EXPORT void qt_set_gl_library_name(const QString& name) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 6571a76..8c54fd1 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -499,11 +499,13 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & } } #endif +#ifndef Q_WS_QPA //############################################### if (d_ptr->paintedRegion.boundingRect() != geometry()) { // Emits warning if not supported. Should never happen unless // setPartialUpdateSupport(true) has been called. context()->d_func()->swapRegion(&d_ptr->paintedRegion); } else +#endif context()->swapBuffers(); d_ptr->paintedRegion = QRegion(); -- cgit v0.12 From 1bc01e54e190915d64d2e42a0bc18ee01131b1d5 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 15 Jul 2010 15:12:24 +0200 Subject: Remove qDebug() --- src/plugins/platforms/eglfs/eglintegration.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/eglfs/eglintegration.cpp b/src/plugins/platforms/eglfs/eglintegration.cpp index 5ea0bb2..9470c99 100644 --- a/src/plugins/platforms/eglfs/eglintegration.cpp +++ b/src/plugins/platforms/eglfs/eglintegration.cpp @@ -276,9 +276,9 @@ public: QEglScreen(); ~QEglScreen() {} - QRect geometry() const { /*qDebug() << "QEglScreen::geometry()";*/ return m_geometry; } - int depth() const { qDebug() << "QEglScreen::depth()"; return m_depth; } - QImage::Format format() const {qDebug() << "QEglScreen::format()"; return m_format; } + 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; } //### public: -- cgit v0.12 From d9b023b5d38d858f29e7095aeb25a84f09a19c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 15 Jul 2010 16:57:07 +0200 Subject: Eventloop integration in Lighthouse This is exprimental and does not work with the glib eventloop. --- src/gui/kernel/kernel.pri | 6 +- src/gui/kernel/qeventdispatcher_glib_qpa.cpp | 8 + src/gui/kernel/qeventdispatcher_qpa.cpp | 186 +++++++++++++++++++-- src/gui/kernel/qeventdispatcher_qpa_p.h | 6 +- .../kernel/qplatformeventloopintegration_qpa.cpp | 0 src/gui/kernel/qplatformeventloopintegration_qpa.h | 13 ++ src/gui/kernel/qplatformintegration_qpa.cpp | 5 + src/gui/kernel/qplatformintegration_qpa.h | 5 + src/plugins/platforms/openkode/openkode.pro | 6 +- .../openkode/qopenkodeeventloopintegration.cpp | 29 ++++ .../openkode/qopenkodeeventloopintegration.h | 17 ++ .../platforms/openkode/qopenkodeintegration.cpp | 42 +---- .../platforms/openkode/qopenkodeintegration.h | 4 +- src/plugins/platforms/openkode/qopenkodewindow.cpp | 1 - .../platforms/openkode/qopenkodewindowsurface.cpp | 6 +- 15 files changed, 272 insertions(+), 62 deletions(-) create mode 100644 src/gui/kernel/qplatformeventloopintegration_qpa.cpp create mode 100644 src/gui/kernel/qplatformeventloopintegration_qpa.h create mode 100644 src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp create mode 100644 src/plugins/platforms/openkode/qopenkodeeventloopintegration.h diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 02badee..ba86c1c 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -219,7 +219,8 @@ qpa { kernel/qplatformwindow_qpa.h \ kernel/qplatformwindowformat_qpa.h \ kernel/qplatformglcontext_qpa.h \ - kernel/qdesktopwidget_qpa_p.h + kernel/qdesktopwidget_qpa_p.h \ + kernel/qplatformeventloopintegration_qpa.h SOURCES += \ kernel/qapplication_qpa.cpp \ @@ -238,7 +239,8 @@ qpa { kernel/qplatformintegrationfactory_qpa.cpp \ kernel/qplatformintegrationplugin_qpa.cpp \ kernel/qplatformwindow_qpa.cpp \ - kernel/qplatformwindowformat_qpa.cpp + kernel/qplatformwindowformat_qpa.cpp \ + kernel/qplatformeventloopintegration_qpa.cpp contains(QT_CONFIG, glib) { SOURCES += \ diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp index 9585b26..981991d 100644 --- a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp +++ b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp @@ -133,6 +133,14 @@ QPAEventDispatcherGlib::~QPAEventDispatcherGlib() bool QPAEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags) { + static bool init = false; + if (!init) { + if (QApplicationPrivate::platformIntegration()->createEventLoopIntegration()) { + qWarning("Eventloop integration is not supported by the glib event dispatcher"); + qWarning("Use the UNIX event dispatcher by defining environment variable QT_NO_GLIB=1"); + } + init = true; + } return QEventDispatcherGlib::processEvents(flags); } diff --git a/src/gui/kernel/qeventdispatcher_qpa.cpp b/src/gui/kernel/qeventdispatcher_qpa.cpp index 5740548..f7f3db3 100644 --- a/src/gui/kernel/qeventdispatcher_qpa.cpp +++ b/src/gui/kernel/qeventdispatcher_qpa.cpp @@ -44,24 +44,135 @@ #include "qeventdispatcher_qpa_p.h" #include "private/qeventdispatcher_unix_p.h" #include "qapplication_p.h" -#ifndef QT_NO_THREAD -# include "qmutex.h" -#endif +#include "qplatformeventloopintegration_qpa.h" + #include +#include +#include +#include #include + QT_BEGIN_NAMESPACE QT_USE_NAMESPACE +class Rendezvous +{ +public: + void checkpoint() + { + if (state.testAndSetOrdered(0,1)) { + semaphore.acquire(); + } else if (state.testAndSetAcquire(1,0)) { + semaphore.release(); + } else { + qWarning("Barrier internal error"); + } + } +private: + QSemaphore semaphore; + QAtomicInt state; +}; + +class SelectWorker : public QThread +{ +public: + SelectWorker(QEventDispatcherQPAPrivate *eventDispatcherPrivate) + : QThread(), + m_edPrivate(eventDispatcherPrivate), + m_retVal(0) + { + } + + void setSelectValues(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds) + { + m_nfds = nfds; + m_readfds = readfds; + m_writefds = writefds; + m_exceptfds = exceptfds; + + + } + + int retVal() const { + return m_retVal; + } + +protected: + void run(); + +private: + QEventDispatcherQPAPrivate *m_edPrivate; + int m_retVal; + + int m_nfds; + fd_set *m_readfds, *m_writefds, *m_exceptfds; +}; + class QEventDispatcherQPAPrivate : public QEventDispatcherUNIXPrivate { Q_DECLARE_PUBLIC(QEventDispatcherQPA) public: - inline QEventDispatcherQPAPrivate() - { } -}; + QEventDispatcherQPAPrivate() + : eventLoopIntegration(0), + barrierBeforeBlocking(0), + barrierReturnValue(0), + selectReturnMutex(0), + selectWorkerNeedsSync(true), + selectWorkerHasResult(false), + m_integrationInitialised(false), + m_hasIntegration(false) + { + } + + ~QEventDispatcherQPAPrivate() + { + delete selectWorker; + delete eventLoopIntegration; + delete barrierBeforeBlocking; + delete barrierReturnValue; + delete selectReturnMutex; + } + + bool hasIntegration() const + { + if (!m_integrationInitialised) { + QEventDispatcherQPAPrivate *that = const_cast(this); + if (qApp && (qApp->thread() == QThread::currentThread())) { // guiThread + if (QApplicationPrivate::platformIntegration()) { + that->eventLoopIntegration = QApplicationPrivate::platformIntegration()->createEventLoopIntegration(); + if (that->eventLoopIntegration) { + that->selectWorker = new SelectWorker(that); + that->barrierBeforeBlocking = new Rendezvous; + that->barrierReturnValue = new Rendezvous; + that->selectReturnMutex = new QMutex; + that->selectWorker->start(); + that->m_hasIntegration = true; + if (!QElapsedTimer::isMonotonic()) + qWarning("Having eventloop integration without monotonic timers can lead to undefined behaviour"); + } + } + } + that->m_integrationInitialised = true; + } + return m_hasIntegration; + } + + QPlatformEventLoopIntegration *eventLoopIntegration; + Rendezvous *barrierBeforeBlocking; + Rendezvous *barrierReturnValue; + + QMutex *selectReturnMutex; + bool selectWorkerNeedsSync; + bool selectWorkerHasResult; + + SelectWorker *selectWorker; +private: + bool m_integrationInitialised; + bool m_hasIntegration; +}; QEventDispatcherQPA::QEventDispatcherQPA(QObject *parent) : QEventDispatcherUNIX(*new QEventDispatcherQPAPrivate, parent) @@ -70,10 +181,6 @@ QEventDispatcherQPA::QEventDispatcherQPA(QObject *parent) QEventDispatcherQPA::~QEventDispatcherQPA() { } - - -//#define ZERO_FOR_THE_MOMENT - bool QEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QEventDispatcherQPA); @@ -115,17 +222,24 @@ bool QEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags) bool QEventDispatcherQPA::hasPendingEvents() { extern uint qGlobalPostedEventsCount(); // from qapplication.cpp - return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::userEventsQueued();; + return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::userEventsQueued(); } -void QEventDispatcherQPA::startingUp() +void QEventDispatcherQPA::registerSocketNotifier(QSocketNotifier *notifier) { + Q_D(QEventDispatcherQPA); + QEventDispatcherUNIX::registerSocketNotifier(notifier); + if (d->hasIntegration()) + wakeUp(); } -void QEventDispatcherQPA::closingDown() +void QEventDispatcherQPA::unregisterSocketNotifier(QSocketNotifier *notifier) { - + Q_D(QEventDispatcherQPA); + QEventDispatcherUNIX::unregisterSocketNotifier(notifier); + if (d->hasIntegration()) + wakeUp(); } void QEventDispatcherQPA::flush() @@ -138,7 +252,49 @@ void QEventDispatcherQPA::flush() int QEventDispatcherQPA::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, timeval *timeout) { - return QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout); + Q_D(QEventDispatcherQPA); + int retVal = 0; + if (d->hasIntegration()) { + qint64 timeoutmsec = timeout->tv_sec * 1000 + (timeout->tv_usec/1000); + d->selectReturnMutex->lock(); + if (d->selectWorkerNeedsSync) { + if (d->selectWorkerHasResult) { + retVal = d->selectWorker->retVal(); + d->selectWorkerHasResult = false; + + d->selectReturnMutex->unlock(); + d->barrierReturnValue->checkpoint(); + return retVal; + } else { + d->selectWorkerNeedsSync = false; + d->selectWorker->setSelectValues(nfds,readfds, writefds, exceptfds); + d->barrierBeforeBlocking->checkpoint(); + } + } + d->selectReturnMutex->unlock(); + d->eventLoopIntegration->processEvents(timeoutmsec); + retVal = 0; //is 0 if select has not returned + } else { + retVal = QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout); + } + return retVal; } +void SelectWorker::run() +{ + while(true) { + m_retVal = 0; + m_edPrivate->barrierBeforeBlocking->checkpoint(); // wait for mainthread + int tmpRet = qt_safe_select(m_nfds,m_readfds,m_writefds,m_exceptfds,0); + m_edPrivate->selectReturnMutex->lock(); + m_edPrivate->eventLoopIntegration->wakeup(); + + m_edPrivate->selectWorkerNeedsSync = true; + m_edPrivate->selectWorkerHasResult = true; + m_retVal = tmpRet; + + m_edPrivate->selectReturnMutex->unlock(); + m_edPrivate->barrierReturnValue->checkpoint(); + } +} QT_END_NAMESPACE diff --git a/src/gui/kernel/qeventdispatcher_qpa_p.h b/src/gui/kernel/qeventdispatcher_qpa_p.h index 878daaa..8065c3e 100644 --- a/src/gui/kernel/qeventdispatcher_qpa_p.h +++ b/src/gui/kernel/qeventdispatcher_qpa_p.h @@ -71,10 +71,10 @@ public: bool processEvents(QEventLoop::ProcessEventsFlags flags); bool hasPendingEvents(); - void flush(); + void registerSocketNotifier(QSocketNotifier *notifier); + void unregisterSocketNotifier(QSocketNotifier *notifier); - void startingUp(); - void closingDown(); + void flush(); protected: int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.cpp b/src/gui/kernel/qplatformeventloopintegration_qpa.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.h b/src/gui/kernel/qplatformeventloopintegration_qpa.h new file mode 100644 index 0000000..5e4c227 --- /dev/null +++ b/src/gui/kernel/qplatformeventloopintegration_qpa.h @@ -0,0 +1,13 @@ +#ifndef QPLATFORMEVENTLOOPINTEGRATION_QPA_H +#define QPLATFORMEVENTLOOPINTEGRATION_QPA_H + +#include + +class QPlatformEventLoopIntegration +{ +public: + virtual void processEvents( qint64 msec ) = 0; + virtual void wakeup() = 0; +}; + +#endif // QPLATFORMEVENTLOOPINTEGRATION_QPA_H diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp index 8666911..b3f46ce 100644 --- a/src/gui/kernel/qplatformintegration_qpa.cpp +++ b/src/gui/kernel/qplatformintegration_qpa.cpp @@ -56,6 +56,11 @@ QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, in return QPixmap(); } +QPlatformEventLoopIntegration *QPlatformIntegration::createEventLoopIntegration() const +{ + return 0; +} + bool QPlatformIntegration::hasOpenGL() const { return false; diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h index 8c1659f..11377e7 100644 --- a/src/gui/kernel/qplatformintegration_qpa.h +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -55,6 +55,7 @@ class QPlatformWindow; class QWindowSurface; class QBlittable; class QWidget; +class QPlatformEventLoopIntegration; class Q_GUI_EXPORT QPlatformIntegration { @@ -73,8 +74,12 @@ public: virtual bool isVirtualDesktop() { return false; } virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; +// Experimental + virtual QPlatformEventLoopIntegration *createEventLoopIntegration() const; + virtual bool hasOpenGL() const; + }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/openkode.pro b/src/plugins/platforms/openkode/openkode.pro index c039131..2d90b15 100644 --- a/src/plugins/platforms/openkode/openkode.pro +++ b/src/plugins/platforms/openkode/openkode.pro @@ -10,13 +10,15 @@ SOURCES = main.cpp \ qopenkodewindowsurface.cpp \ qopenkodewindow.cpp \ ../eglconvenience/qeglplatformcontext.cpp \ - ../eglconvenience/qeglconvenience.cpp + ../eglconvenience/qeglconvenience.cpp \ + qopenkodeeventloopintegration.cpp HEADERS = qopenkodeintegration.h \ qopenkodewindowsurface.h \ qopenkodewindow.h \ ../eglconvenience/qeglplatformcontext.h \ - ../eglconvenience/qeglconvenience.h + ../eglconvenience/qeglconvenience.h \ + qopenkodeeventloopintegration.h RESOURCES = resources.qrc diff --git a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp new file mode 100644 index 0000000..467b5b5 --- /dev/null +++ b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp @@ -0,0 +1,29 @@ +#include "qopenkodeeventloopintegration.h" + +#include + +#include + +QOpenKODEEventLoopIntegration::QOpenKODEEventLoopIntegration() +{ + m_kdThread = kdThreadSelf(); +} + +void QOpenKODEEventLoopIntegration::processEvents(qint64 msec) +{ + if (msec == 0) + msec = -1; + const KDEvent *event = kdWaitEvent(msec*1000); + if (event) { + kdDefaultEvent(event); + while ((event = kdWaitEvent(0)) != 0) { + kdDefaultEvent(event); + } + } +} + +void QOpenKODEEventLoopIntegration::wakeup() +{ + KDEvent *event = kdCreateEvent(); + kdPostThreadEvent(event,m_kdThread); +} diff --git a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h new file mode 100644 index 0000000..ef04640 --- /dev/null +++ b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h @@ -0,0 +1,17 @@ +#ifndef QOPENKODEEVENTLOOPINTEGRATION_H +#define QOPENKODEEVENTLOOPINTEGRATION_H + +#include + +class KDThread; +class QOpenKODEEventLoopIntegration : public QPlatformEventLoopIntegration +{ +public: + QOpenKODEEventLoopIntegration(); + void processEvents(qint64 msec); + void wakeup(); +private: + KDThread *m_kdThread; +}; + +#endif // QOPENKODEEVENTLOOPINTEGRATION_H diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index 270763b..5dada28 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -42,6 +42,7 @@ #include "qopenkodeintegration.h" #include "qopenkodewindowsurface.h" #include "qopenkodewindow.h" +#include "qopenkodeeventloopintegration.h" #include #include @@ -184,41 +185,11 @@ static GLuint loadShaders(const QString &vertexShader, const QString &fragmentSh return prog; } -class QOpenKODEEventLoopHelper : public QThread -{ -public: - QOpenKODEEventLoopHelper(QSemaphore *m) - : eventMutex(m) - { - m->acquire(); - } - -protected: - void run() - { - if (kdInitializeNV() == KD_ENOTINITIALIZED) { - qFatal("Did not manage to initialize openkode"); - } - eventMutex->release(); - - const KDEvent *event; - while ((event = kdWaitEvent(-1)) != 0) { - qDebug() << "!!! received event!"; - kdDefaultEvent(event); - } - } - -private: - QSemaphore *eventMutex; -}; - QOpenKODEIntegration::QOpenKODEIntegration() - : eventMutex(1) { - QOpenKODEEventLoopHelper *loop = new QOpenKODEEventLoopHelper(&eventMutex); - loop->start(); - eventMutex.acquire(); // block until initialization done - + if (kdInitializeNV() == KD_ENOTINITIALIZED) { + qFatal("Did not manage to initialize openkode"); + } QOpenKODEScreen *mPrimaryScreen = new QOpenKODEScreen(); mScreens.append(mPrimaryScreen); @@ -265,6 +236,11 @@ bool QOpenKODEIntegration::hasOpenGL() const return true; } +QPlatformEventLoopIntegration *QOpenKODEIntegration::createEventLoopIntegration() const +{ + return new QOpenKODEEventLoopIntegration; +} + GLuint QOpenKODEIntegration::blitterProgram() { static GLuint shaderProgram = 0; diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h index 9029086..0eaf127 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeintegration.h @@ -86,7 +86,8 @@ public: QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; bool hasOpenGL() const; - QPlatformGLContext * createGLContext(); + + QPlatformEventLoopIntegration *createEventLoopIntegration() const; virtual QList screens() const { return mScreens; } @@ -94,7 +95,6 @@ public: private: QList mScreens; - QSemaphore eventMutex; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index 2213a8f..faba2fb 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -60,7 +60,6 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) : QPlatformWindow(tlw) { - if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenVG) { m_eglApi = EGL_OPENVG_API; } else { diff --git a/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp b/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp index a349031..84e27f5 100644 --- a/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp @@ -93,8 +93,6 @@ void QOpenKODEWindowSurface::flush(QWidget *widget, const QRegion ®ion, const y = boundingRect.y(); } - qDebug() << "flush" << widget << offset << region.boundingRect() << mImage.format() << blitImage.format(); - GLuint shaderProgram = QOpenKODEIntegration::blitterProgram(); glUseProgram(shaderProgram); @@ -125,7 +123,7 @@ void QOpenKODEWindowSurface::flush(QWidget *widget, const QRegion ®ion, const glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, mImage.bits()); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, mImage.bits()); // Enable vertex attribute associated with vertex position glEnableVertexAttribArray(posId); @@ -166,7 +164,7 @@ void QOpenKODEWindowSurface::beginPaint(const QRegion ®ion) Q_UNUSED(region); if (mImage.isNull()) { m_platformGLContext = window()->platformWindow()->glContext(); - mImage = QImage(size(),QImage::Format_RGB32); + mImage = QImage(size(),QImage::Format_RGB888); } } -- cgit v0.12 From a7182f757e5414d7baf21fdc098f3f6649e6a1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 20 Jul 2010 13:16:09 +0200 Subject: Cleanup directfb input handling in lighthouse --- src/plugins/platforms/directfb/qdirectfbinput.cpp | 97 +++++++--------------- src/plugins/platforms/directfb/qdirectfbinput.h | 42 +++------- .../platforms/directfb/qdirectfbintegration.cpp | 24 +++++- .../platforms/directfb/qdirectfbintegration.h | 6 +- src/plugins/platforms/directfb/qdirectfbwindow.cpp | 8 +- src/plugins/platforms/directfb/qdirectfbwindow.h | 5 +- 6 files changed, 74 insertions(+), 108 deletions(-) diff --git a/src/plugins/platforms/directfb/qdirectfbinput.cpp b/src/plugins/platforms/directfb/qdirectfbinput.cpp index 90c3348..7101b7b 100644 --- a/src/plugins/platforms/directfb/qdirectfbinput.cpp +++ b/src/plugins/platforms/directfb/qdirectfbinput.cpp @@ -10,89 +10,61 @@ #include -InputSocketWaiter::InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent) - : QThread(parent), m_eventBuffer(eventBuffer),m_shouldStop(false) +QDirectFbInput::QDirectFbInput(QObject *parent) + : QObject(parent), m_shouldStop(false) { - this->start(); -} + m_dfbInterface = QDirectFbConvenience::dfbInterface(); -InputSocketWaiter::~InputSocketWaiter() -{ - m_shouldStop = true; - m_eventBuffer->WakeUp(m_eventBuffer); - m_cleanupMutex.lock(); -} + DFBResult ok = m_dfbInterface->CreateEventBuffer(m_dfbInterface,&m_eventBuffer); + if (ok != DFB_OK) + DirectFBError("Failed to initialise eventbuffer", ok); + + m_dfbInterface->GetDisplayLayer(m_dfbInterface,DLID_PRIMARY, &m_dfbDisplayLayer); -void InputSocketWaiter::continueWaitingForEvents() -{ - m_finishedProcessingEvents.wakeAll(); } -void InputSocketWaiter::run() +void QDirectFbInput::runInputEventLoop() { - m_cleanupMutex.lock(); - while (1) { + while (true) { m_eventBuffer->WaitForEvent(m_eventBuffer); - if (m_shouldStop) + if (m_shouldStop) { + m_waitStop.release(); break; - emit newEvent(); - QMutex waitForProcessingMutex; - waitForProcessingMutex.lock(); - m_finishedProcessingEvents.wait(&waitForProcessingMutex); - } - m_cleanupMutex.unlock(); -} - -QDirectFbInput *QDirectFbInput::instance() -{ - static QDirectFbInput *input = 0; - if (!input) { - input = new QDirectFbInput(); + } + handleEvents(); } - return input; } -QDirectFbInput::QDirectFbInput() - : QObject() +void QDirectFbInput::stopInputEventLoop() { - dfbInterface = QDirectFbConvenience::dfbInterface(); - - DFBResult ok = dfbInterface->CreateEventBuffer(dfbInterface,&eventBuffer); - if (ok != DFB_OK) - DirectFBError("Failed to initialise eventbuffer", ok); - - dfbInterface->GetDisplayLayer(dfbInterface,DLID_PRIMARY, &dfbDisplayLayer); - - m_inputHandler = new InputSocketWaiter(eventBuffer,this); - connect(m_inputHandler,SIGNAL(newEvent()),this,SLOT(handleEvents())); - - connect(QApplication::instance(),SIGNAL(aboutToQuit()),SLOT(applicationEnd())); + m_shouldStop = true; + m_waitStop.acquire(); } void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) { - tlwMap.insert(id,tlw); + m_tlwMap.insert(id,tlw); IDirectFBWindow *window; - dfbDisplayLayer->GetWindow(dfbDisplayLayer,id,&window); + m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,id,&window); - window->AttachEventBuffer(window,eventBuffer); + window->AttachEventBuffer(window,m_eventBuffer); } void QDirectFbInput::removeWindow(WId wId) { IDirectFBWindow *window; - dfbDisplayLayer->GetWindow(dfbDisplayLayer,wId, &window); + m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,wId, &window); - window->DetachEventBuffer(window,eventBuffer); - tlwMap.remove(wId); + window->DetachEventBuffer(window,m_eventBuffer); + m_tlwMap.remove(wId); } void QDirectFbInput::handleEvents() { - DFBResult hasEvent = eventBuffer->HasEvent(eventBuffer); + DFBResult hasEvent = m_eventBuffer->HasEvent(m_eventBuffer); while(hasEvent == DFB_OK){ DFBEvent event; - DFBResult ok = eventBuffer->GetEvent(eventBuffer,&event); + DFBResult ok = m_eventBuffer->GetEvent(m_eventBuffer,&event); if (ok != DFB_OK) DirectFBError("Failed to get event",ok); if (event.clazz == DFEC_WINDOW) { @@ -118,9 +90,8 @@ void QDirectFbInput::handleEvents() } - hasEvent = eventBuffer->HasEvent(eventBuffer); + hasEvent = m_eventBuffer->HasEvent(m_eventBuffer); } - m_inputHandler->continueWaitingForEvents(); } void QDirectFbInput::handleMouseEvents(const DFBEvent &event) @@ -140,22 +111,16 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event) } else if (event.window.type == DWET_BUTTONUP) { window->UngrabPointer(window); } - QWidget *tlw = tlwMap.value(event.window.window_id); + QWidget *tlw = m_tlwMap.value(event.window.window_id); QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons); } -void QDirectFbInput::applicationEnd() -{ - delete m_inputHandler; - m_inputHandler = 0; -} - void QDirectFbInput::handleWheelEvent(const DFBEvent &event) { QPoint p(event.window.cx, event.window.cy); QPoint globalPos = globalPoint(event); long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); - QWidget *tlw = tlwMap.value(event.window.window_id); + QWidget *tlw = m_tlwMap.value(event.window.window_id); QWindowSystemInterface::handleWheelEvent(tlw, timestamp, p, globalPos, event.window.step*120, Qt::Vertical); @@ -172,13 +137,13 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event) QChar character; if (DFB_KEY_TYPE(event.window.key_symbol) == DIKT_UNICODE) character = QChar(event.window.key_symbol); - QWidget *tlw = tlwMap.value(event.window.window_id); + QWidget *tlw = m_tlwMap.value(event.window.window_id); QWindowSystemInterface::handleKeyEvent(tlw, timestamp, type, key, modifiers, character); } void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) { - QWidget *tlw = tlwMap.value(event.window.window_id); + QWidget *tlw = m_tlwMap.value(event.window.window_id); switch (event.window.type) { case DWET_ENTER: QWindowSystemInterface::handleEnterEvent(tlw); @@ -194,7 +159,7 @@ void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const { IDirectFBWindow *window; - dfbDisplayLayer->GetWindow(dfbDisplayLayer,event.window.window_id,&window); + m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,event.window.window_id,&window); int x,y; window->GetPosition(window,&x,&y); return QPoint(event.window.cx +x, event.window.cy + y); diff --git a/src/plugins/platforms/directfb/qdirectfbinput.h b/src/plugins/platforms/directfb/qdirectfbinput.h index 016e7f1..0b2e7ed 100644 --- a/src/plugins/platforms/directfb/qdirectfbinput.h +++ b/src/plugins/platforms/directfb/qdirectfbinput.h @@ -1,9 +1,7 @@ #ifndef QDIRECTFBINPUT_H #define QDIRECTFBINPUT_H -#include -#include -#include +#include #include #include #include @@ -13,53 +11,35 @@ #include -class InputSocketWaiter : public QThread -{ - Q_OBJECT -public: - InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent); - virtual ~InputSocketWaiter(); - void continueWaitingForEvents(); -protected: - void run(); -signals: - void newEvent(); -private: - IDirectFBEventBuffer *m_eventBuffer; - bool m_shouldStop; - QMutex m_cleanupMutex; - QWaitCondition m_finishedProcessingEvents; -}; - class QDirectFbInput : public QObject { Q_OBJECT public: - static QDirectFbInput *instance(); + QDirectFbInput(QObject *parent); void addWindow(DFBWindowID id, QWidget *tlw); void removeWindow(WId wId); public slots: + void runInputEventLoop(); + void stopInputEventLoop(); void handleEvents(); - void applicationEnd(); private: - QDirectFbInput(); - void handleMouseEvents(const DFBEvent &event); void handleWheelEvent(const DFBEvent &event); void handleKeyEvents(const DFBEvent &event); void handleEnterLeaveEvents(const DFBEvent &event); - IDirectFB *dfbInterface; - IDirectFBDisplayLayer *dfbDisplayLayer; - IDirectFBEventBuffer *eventBuffer; + inline QPoint globalPoint(const DFBEvent &event) const; - QHashtlwMap; - inline QPoint globalPoint(const DFBEvent &event) const; + IDirectFB *m_dfbInterface; + IDirectFBDisplayLayer *m_dfbDisplayLayer; + IDirectFBEventBuffer *m_eventBuffer; - InputSocketWaiter *m_inputHandler; + bool m_shouldStop; + QSemaphore m_waitStop; + QHashm_tlwMap; }; #endif // QDIRECTFBINPUT_H diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp index 60fce7e..c47fc8d 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp +++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp @@ -49,9 +49,10 @@ #include #include -#include -#include -#include +#include +#include +#include +#include QT_BEGIN_NAMESPACE @@ -94,8 +95,22 @@ QDirectFbIntegration::QDirectFbIntegration() } delete[] argv; + QDirectFbScreen *primaryScreen = new QDirectFbScreen(0); mScreens.append(primaryScreen); + + mInputRunner = new QThread; + mInput = new QDirectFbInput(0); + mInput->moveToThread(mInputRunner); + QObject::connect(mInputRunner,SIGNAL(started()),mInput,SLOT(runInputEventLoop())); + mInputRunner->start(); +} + +QDirectFbIntegration::~QDirectFbIntegration() +{ + mInput->stopInputEventLoop(); + delete mInputRunner; + delete mInput; } QPixmapData *QDirectFbIntegration::createPixmapData(QPixmapData::PixelType type) const @@ -109,7 +124,8 @@ QPixmapData *QDirectFbIntegration::createPixmapData(QPixmapData::PixelType type) QPlatformWindow *QDirectFbIntegration::createPlatformWindow(QWidget *widget, WId winId) const { Q_UNUSED(winId); - return new QDirectFbWindow(widget); + QDirectFbInput *input = const_cast(mInput);//gah + return new QDirectFbWindow(widget,input); } QWindowSurface *QDirectFbIntegration::createWindowSurface(QWidget *widget, WId winId) const diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.h b/src/plugins/platforms/directfb/qdirectfbintegration.h index c0e770f..27847e2 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.h +++ b/src/plugins/platforms/directfb/qdirectfbintegration.h @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE +class QThread; class QDirectFBCursor; class QDirectFbScreen : public QPlatformScreen @@ -81,6 +82,7 @@ class QDirectFbIntegration : public QPlatformIntegration { public: QDirectFbIntegration(); + ~QDirectFbIntegration(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; @@ -89,10 +91,10 @@ public: QList screens() const { return mScreens; } - - private: QList mScreens; + QDirectFbInput *mInput; + QThread *mInputRunner; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.cpp b/src/plugins/platforms/directfb/qdirectfbwindow.cpp index d88953e..30e6f5a 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindow.cpp +++ b/src/plugins/platforms/directfb/qdirectfbwindow.cpp @@ -45,8 +45,8 @@ #include -QDirectFbWindow::QDirectFbWindow(QWidget *tlw) - : QPlatformWindow(tlw) +QDirectFbWindow::QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler) + : QPlatformWindow(tlw), m_inputHandler(inputhandler) { IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); DFBDisplayLayerConfig layerConfig; @@ -83,12 +83,12 @@ QDirectFbWindow::QDirectFbWindow(QWidget *tlw) DFBWindowID id; m_dfbWindow->GetID(m_dfbWindow, &id); - QDirectFbInput::instance()->addWindow(id,tlw); + m_inputHandler->addWindow(id,tlw); } QDirectFbWindow::~QDirectFbWindow() { - QDirectFbInput::instance()->removeWindow(winId()); + m_inputHandler->removeWindow(winId()); m_dfbWindow->Destroy(m_dfbWindow); } diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.h b/src/plugins/platforms/directfb/qdirectfbwindow.h index d5fd408..b512afd 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindow.h +++ b/src/plugins/platforms/directfb/qdirectfbwindow.h @@ -45,13 +45,14 @@ #include #include "qdirectfbconvenience.h" +#include "qdirectfbinput.h" QT_BEGIN_NAMESPACE class QDirectFbWindow : public QPlatformWindow { public: - QDirectFbWindow(QWidget *tlw); + QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler); ~QDirectFbWindow(); void setGeometry(const QRect &rect); @@ -66,6 +67,8 @@ public: private: IDirectFBWindow *m_dfbWindow; + QDirectFbInput *m_inputHandler; + }; QT_END_NAMESPACE -- cgit v0.12 From 8dd6b648a7cf1625e078e91328ffebfa4a92529c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 20 Jul 2010 16:13:13 +0200 Subject: Add Lighthouse #ifdefs --- tests/auto/qwidget/tst_qwidget.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index f91ad6b..5e39c27 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -357,7 +357,7 @@ private slots: void setClearAndResizeMask(); void maskedUpdate(); -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA) void syntheticEnterLeave(); void taskQTBUG_4055_sendSyntheticEnterLeave(); #endif @@ -1979,7 +1979,7 @@ void tst_QWidget::showMaximized() layouted.showNormal(); QVERIFY(!(layouted.windowState() & Qt::WindowMaximized)); -#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) && !defined(Q_WS_S60) +#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) && !defined(Q_WS_S60) && !defined(Q_WS_QPA) //embedded may choose a different size to fit on the screen. QCOMPARE(layouted.size(), layouted.sizeHint()); #endif @@ -2078,7 +2078,7 @@ void tst_QWidget::showFullScreen() layouted.showNormal(); QVERIFY(!(layouted.windowState() & Qt::WindowFullScreen)); -#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) && !defined (Q_WS_S60) +#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) && !defined (Q_WS_S60) && !defined(Q_WS_QPA) //embedded may choose a different size to fit on the screen. QCOMPARE(layouted.size(), layouted.sizeHint()); #endif @@ -6362,7 +6362,7 @@ void tst_QWidget::compatibilityChildInsertedEvents() EventRecorder::EventList() << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA) << qMakePair(&widget, QEvent::UpdateRequest) #endif ; @@ -6458,7 +6458,7 @@ void tst_QWidget::compatibilityChildInsertedEvents() << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) << qMakePair(&widget, QEvent::Type(QEvent::User + 2)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA) << qMakePair(&widget, QEvent::UpdateRequest) #endif ; @@ -6554,7 +6554,7 @@ void tst_QWidget::compatibilityChildInsertedEvents() << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) << qMakePair(&widget, QEvent::Type(QEvent::User + 2)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA) << qMakePair(&widget, QEvent::UpdateRequest) #endif ; @@ -9167,7 +9167,7 @@ void tst_QWidget::maskedUpdate() QTRY_COMPARE(grandChild.paintedRegion, QRegion(grandChild.rect())); // Full update. } -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_QPA) void tst_QWidget::syntheticEnterLeave() { class MyWidget : public QWidget -- cgit v0.12 From bc786ded04aa316f99cf9ac4cf8b714ee46575b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 20 Jul 2010 14:38:12 +0200 Subject: Made the rest of QWindowSystemInterface callback functions thread safe and cleaned up the headerfile --- src/gui/kernel/kernel.pri | 7 +- src/gui/kernel/qapplication_p.h | 29 +-- src/gui/kernel/qapplication_qpa.cpp | 133 ++++++++------ src/gui/kernel/qeventdispatcher_glib_qpa.cpp | 10 +- src/gui/kernel/qeventdispatcher_qpa.cpp | 10 +- src/gui/kernel/qwindowsysteminterface.cpp | 186 ------------------- src/gui/kernel/qwindowsysteminterface.h | 169 ------------------ src/gui/kernel/qwindowsysteminterface_qpa.cpp | 246 ++++++++++++++++++++++++++ src/gui/kernel/qwindowsysteminterface_qpa.h | 96 ++++++++++ src/gui/kernel/qwindowsysteminterface_qpa_p.h | 201 +++++++++++++++++++++ 10 files changed, 657 insertions(+), 430 deletions(-) delete mode 100644 src/gui/kernel/qwindowsysteminterface.cpp delete mode 100644 src/gui/kernel/qwindowsysteminterface.h create mode 100644 src/gui/kernel/qwindowsysteminterface_qpa.cpp create mode 100644 src/gui/kernel/qwindowsysteminterface_qpa.h create mode 100644 src/gui/kernel/qwindowsysteminterface_qpa_p.h diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index ba86c1c..43b1ab8 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -48,7 +48,7 @@ HEADERS += \ kernel/qgesturemanager_p.h \ kernel/qsoftkeymanager_p.h \ kernel/qsoftkeymanager_common_p.h \ - kernel/qguiplatformplugin_p.h + kernel/qguiplatformplugin_p.h \ SOURCES += \ kernel/qaction.cpp \ @@ -211,7 +211,8 @@ qpa { kernel/qgenericpluginfactory_qpa.h \ kernel/qgenericplugin_qpa.h \ kernel/qeventdispatcher_qpa_p.h \ - kernel/qwindowsysteminterface.h \ + kernel/qwindowsysteminterface_qpa.h \ + kernel/qwindowsysteminterface_qpa_p.h \ kernel/qplatformintegration_qpa.h \ kernel/qplatformscreen_qpa.h \ kernel/qplatformintegrationfactory_qpa_p.h \ @@ -233,7 +234,7 @@ qpa { kernel/qkeymapper_qws.cpp \ kernel/qwidget_qpa.cpp \ kernel/qeventdispatcher_qpa.cpp \ - kernel/qwindowsysteminterface.cpp \ + kernel/qwindowsysteminterface_qpa.cpp \ kernel/qplatformintegration_qpa.cpp \ kernel/qplatformscreen_qpa.cpp \ kernel/qplatformintegrationfactory_qpa.cpp \ diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 68ec648..0602d82 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -78,6 +78,7 @@ #endif #ifdef Q_WS_QPA #include +#include "qwindowsysteminterface_qpa_p.h" #include "QtGui/qplatformintegration_qpa.h" #endif @@ -490,19 +491,27 @@ public: #endif #ifdef Q_WS_QPA - static void processMouseEvent(QWindowSystemInterface::MouseEvent *e); - static void processKeyEvent(QWindowSystemInterface::KeyEvent *e); - static void processWheelEvent(QWindowSystemInterface::WheelEvent *e); - static void processTouchEvent(QWindowSystemInterface::TouchEvent *e); + static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e); + static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e); + static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e); + static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e); - static void processCloseEvent(QWidget *tlw); - static void processGeometryChange(QWidget *tlw, const QRect &newRect); + static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e); - static void processUserEvent(QWindowSystemInterface::UserEvent *e); + static void processMoveEvent(QWindowSystemInterfacePrivate::MoveEvent *e); + static void processResizeEvent(QWindowSystemInterfacePrivate::ResizeEvent *e); - static void reportScreenCount(int count); - static void reportGeometryChange(int screenIndex); - static void reportAvailableGeometryChange(int screenIndex); + static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e); + static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e); + + static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e); + +// static void reportScreenCount(int count); + static void reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e); +// static void reportGeometryChange(int screenIndex); + static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e); +// static void reportAvailableGeometryChange(int screenIndex); + static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e); #endif diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index 2adcfc1..42907ae 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -60,6 +60,7 @@ #include #include #include +#include "qwindowsysteminterface_qpa_p.h" #include #include "qdesktopwidget_qpa_p.h" @@ -86,26 +87,48 @@ static int mousePressX; static int mousePressY; static int mouse_double_click_distance = 5; -void QApplicationPrivate::processUserEvent(QWindowSystemInterface::UserEvent *e) +void QApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e) { switch(e->type) { - case QEvent::MouseButtonDblClick: // if mouse event, calculate appropriate widget and local coordinates - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseMove: - QApplicationPrivate::processMouseEvent(static_cast(e)); + case QWindowSystemInterfacePrivate::Mouse: + QApplicationPrivate::processMouseEvent(static_cast(e)); break; - case QEvent::Wheel: - QApplicationPrivate::processWheelEvent(static_cast(e)); + case QWindowSystemInterfacePrivate::Wheel: + QApplicationPrivate::processWheelEvent(static_cast(e)); break; - case QEvent::KeyPress: - case QEvent::KeyRelease: - QApplicationPrivate::processKeyEvent(static_cast(e)); + case QWindowSystemInterfacePrivate::Key: + QApplicationPrivate::processKeyEvent(static_cast(e)); + break; + case QWindowSystemInterfacePrivate::Touch: + QApplicationPrivate::processTouchEvent(static_cast(e)); + break; + case QWindowSystemInterfacePrivate::Move: + QApplicationPrivate::processMoveEvent(static_cast(e)); + break; + case QWindowSystemInterfacePrivate::Resize: + QApplicationPrivate::processResizeEvent(static_cast(e)); + break; + case QWindowSystemInterfacePrivate::Enter: + QApplicationPrivate::processEnterEvent(static_cast(e)); + break; + case QWindowSystemInterfacePrivate::Leave: + QApplicationPrivate::processLeaveEvent(static_cast(e)); + break; + case QWindowSystemInterfacePrivate::Close: + QApplicationPrivate::processCloseEvent( + static_cast(e)); + break; + case QWindowSystemInterfacePrivate::ScreenCountChange: + QApplicationPrivate::reportScreenCount( + static_cast(e)); break; - case QEvent::TouchBegin: - case QEvent::TouchUpdate: - case QEvent::TouchEnd: - QApplicationPrivate::processTouchEvent(static_cast(e)); + case QWindowSystemInterfacePrivate::ScreenGeometry: + QApplicationPrivate::reportGeometryChange( + static_cast(e)); + break; + case QWindowSystemInterfacePrivate::ScreenAvailableGeometry: + QApplicationPrivate::reportAvailableGeometryChange( + static_cast(e)); break; default: qWarning() << "Unknown user input event type:" << e->type; @@ -570,7 +593,7 @@ void QApplication::setMainWidget(QWidget *mainWidget) } #endif -void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent *e) +void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e) { // qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons(); static QWeakPointer implicit_mouse_grabber; @@ -579,8 +602,9 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent * // move first Qt::MouseButtons stateChange = e->buttons ^ buttons; if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) { - QWindowSystemInterface::MouseEvent * newMouseEvent = new QWindowSystemInterface::MouseEvent(e->widget.data(), e->timestamp, e->localPos, e->globalPos, e->buttons); - QWindowSystemInterfacePrivate::userEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop + QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent = + new QWindowSystemInterfacePrivate::MouseEvent(e->widget.data(), e->timestamp, e->localPos, e->globalPos, e->buttons); + QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop stateChange = Qt::NoButton; } @@ -639,7 +663,7 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent * implicit_mouse_grabber.clear(); //### how should popup mode and implicit mouse grab interact? - } else if (tlw && app_do_modal && !qt_try_modal(tlw, e->type) ) { + } else if (tlw && app_do_modal && !qt_try_modal(tlw, QEvent::MouseButtonRelease) ) { //even if we're blocked by modality, we should deliver the mouse release event.. //### this code is not completely correct: multiple buttons can be pressed simultaneously if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) { @@ -717,7 +741,7 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterface::MouseEvent * //### there's a lot of duplicated logic here -- refactoring required! -void QApplicationPrivate::processWheelEvent(QWindowSystemInterface::WheelEvent *e) +void QApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e) { // QPoint localPoint = ev.pos(); QPoint globalPoint = e->globalPos; @@ -739,7 +763,7 @@ void QApplicationPrivate::processWheelEvent(QWindowSystemInterface::WheelEvent * mouseWidget = mouseWindow; - if (app_do_modal && !qt_try_modal(mouseWindow, e->type) ) { + if (app_do_modal && !qt_try_modal(mouseWindow, QEvent::Wheel) ) { qDebug() << "modal blocked wheel event" << mouseWindow; return; } @@ -759,7 +783,7 @@ void QApplicationPrivate::processWheelEvent(QWindowSystemInterface::WheelEvent * // Remember, Qt convention is: keyboard state is state *before* -void QApplicationPrivate::processKeyEvent(QWindowSystemInterface::KeyEvent *e) +void QApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e) { QWidget *focusW = 0; if (self->inPopupMode()) { @@ -778,50 +802,54 @@ void QApplicationPrivate::processKeyEvent(QWindowSystemInterface::KeyEvent *e) if (!focusW) return; - if (app_do_modal && !qt_try_modal(focusW, e->type)) + if (app_do_modal && !qt_try_modal(focusW, e->keyType)) return; modifiers = e->modifiers; - QKeyEvent ev(e->type, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount); + QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount); QApplication::sendSpontaneousEvent(focusW, &ev); } -void QApplicationPrivate::processGeometryChange(QWidget *tlw, const QRect &newRect) +void QApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e) { - if (!tlw->isWindow()) - return; //geo of native child widgets is controlled by lighthouse - //so we already have sent the events; besides this new rect - //is not mapped to parent + QApplicationPrivate::dispatchEnterLeave(e->enter.data(),0); + qt_last_mouse_receiver = e->enter.data(); +} - QRect cr(tlw->geometry()); +void QApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e) +{ + QApplicationPrivate::dispatchEnterLeave(0,qt_last_mouse_receiver); - bool isResize = cr.size() != newRect.size(); - bool isMove = cr.topLeft() != newRect.topLeft(); - tlw->data->crect = newRect; - if (isResize) { - QResizeEvent e(tlw->data->crect.size(), cr.size()); - QApplication::sendSpontaneousEvent(tlw, &e); - tlw->update(); - } + if (e->leave.data() && !e->leave.data()->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen + QApplicationPrivate::dispatchEnterLeave(0, e->leave.data()); + qt_last_mouse_receiver = 0; - if (isMove) { - //### frame geometry - QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft()); - QApplication::sendSpontaneousEvent(tlw, &e); - } } -void QApplicationPrivate::processCloseEvent(QWidget *tlw) +void QApplicationPrivate::processMoveEvent(QWindowSystemInterfacePrivate::MoveEvent *moveEvent) +{ + QMoveEvent e(moveEvent->moved.data()->geometry().topLeft(), moveEvent->newPos); + QApplication::sendSpontaneousEvent(moveEvent->moved.data(), &e); +} + +void QApplicationPrivate::processResizeEvent(QWindowSystemInterfacePrivate::ResizeEvent *e) +{ + QResizeEvent resizeEvent(e->sizeChanged.data()->data->crect.size(), e->newSize); + QApplication::sendSpontaneousEvent(e->sizeChanged.data(), &resizeEvent); + e->sizeChanged.data()->update(); +} + +void QApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e) { - tlw->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent); + e->topLevel.data()->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent); } -void QApplicationPrivate::processTouchEvent(QWindowSystemInterface::TouchEvent *e) +void QApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e) { translateRawTouchEvent(e->widget.data(), e->devType, e->points); } -void QApplicationPrivate::reportScreenCount(int count) +void QApplicationPrivate::reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e) { // This operation only makes sense after the QApplication constructor runs if (QCoreApplication::startingUp()) @@ -830,10 +858,10 @@ void QApplicationPrivate::reportScreenCount(int count) QApplication::desktop()->d_func()->updateScreenList(); // signal anything listening for creation or deletion of screens QDesktopWidget *desktop = QApplication::desktop(); - emit desktop->screenCountChanged(count); + emit desktop->screenCountChanged(e->count); } -void QApplicationPrivate::reportGeometryChange(int screenIndex) +void QApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e) { // This operation only makes sense after the QApplication constructor runs if (QCoreApplication::startingUp()) @@ -843,7 +871,7 @@ void QApplicationPrivate::reportGeometryChange(int screenIndex) // signal anything listening for screen geometry changes QDesktopWidget *desktop = QApplication::desktop(); - emit desktop->resized(screenIndex); + emit desktop->resized(e->index); // make sure maximized and fullscreen windows are updated QWidgetList list = QApplication::topLevelWidgets(); @@ -856,7 +884,8 @@ void QApplicationPrivate::reportGeometryChange(int screenIndex) } } -void QApplicationPrivate::reportAvailableGeometryChange(int screenIndex) +void QApplicationPrivate::reportAvailableGeometryChange( + QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e) { // This operation only makes sense after the QApplication constructor runs if (QCoreApplication::startingUp()) @@ -866,7 +895,7 @@ void QApplicationPrivate::reportAvailableGeometryChange(int screenIndex) // signal anything listening for screen geometry changes QDesktopWidget *desktop = QApplication::desktop(); - emit desktop->workAreaResized(screenIndex); + emit desktop->workAreaResized(e->index); // make sure maximized and fullscreen windows are updated QWidgetList list = QApplication::topLevelWidgets(); diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp index 981991d..01d40ca 100644 --- a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp +++ b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp @@ -64,7 +64,7 @@ static gboolean userEventSourcePrepare(GSource *s, gint *timeout) Q_UNUSED(s) Q_UNUSED(timeout) - return QWindowSystemInterfacePrivate::userEventsQueued() > 0; + return QWindowSystemInterfacePrivate::windowSystemEventsQueued() > 0; } static gboolean userEventSourceCheck(GSource *source) @@ -76,9 +76,9 @@ static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer) { GUserEventSource * source = reinterpret_cast(s); - QWindowSystemInterface::UserEvent * event; - while (QWindowSystemInterfacePrivate::userEventsQueued()) { - event = QWindowSystemInterfacePrivate::getUserEvent(); + QWindowSystemInterfacePrivate::WindowSystemEvent * event; + while (QWindowSystemInterfacePrivate::windowSystemEventsQueued()) { + event = QWindowSystemInterfacePrivate::getWindowSystemEvent(); if (!event) break; @@ -87,7 +87,7 @@ static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer) delete event; continue; } - QApplicationPrivate::processUserEvent(event); + QApplicationPrivate::processWindowSystemEvent(event); delete event; } diff --git a/src/gui/kernel/qeventdispatcher_qpa.cpp b/src/gui/kernel/qeventdispatcher_qpa.cpp index f7f3db3..4464036 100644 --- a/src/gui/kernel/qeventdispatcher_qpa.cpp +++ b/src/gui/kernel/qeventdispatcher_qpa.cpp @@ -191,11 +191,11 @@ bool QEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags) QApplication::sendPostedEvents(); while (!d->interrupt) { // also flushes output buffer ###can be optimized - QWindowSystemInterface::UserEvent *event; + QWindowSystemInterfacePrivate::WindowSystemEvent *event; if (!(flags & QEventLoop::ExcludeUserInputEvents) - && QWindowSystemInterfacePrivate::userEventsQueued() > 0) { + && QWindowSystemInterfacePrivate::windowSystemEventsQueued() > 0) { // process a pending user input event - event = QWindowSystemInterfacePrivate::getUserEvent(); + event = QWindowSystemInterfacePrivate::getWindowSystemEvent(); if (!event) break; } else { @@ -208,7 +208,7 @@ bool QEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags) } nevents++; - QApplicationPrivate::processUserEvent(event); + QApplicationPrivate::processWindowSystemEvent(event); delete event; } @@ -222,7 +222,7 @@ bool QEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags) bool QEventDispatcherQPA::hasPendingEvents() { extern uint qGlobalPostedEventsCount(); // from qapplication.cpp - return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::userEventsQueued(); + return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::windowSystemEventsQueued(); } void QEventDispatcherQPA::registerSocketNotifier(QSocketNotifier *notifier) diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp deleted file mode 100644 index 4cf9ded..0000000 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************** -** -** 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 "qwindowsysteminterface.h" -#include "qapplication_p.h" -#include - -QT_BEGIN_NAMESPACE - - -QTime QWindowSystemInterface::eventTime; - -//------------------------------------------------------------ -// -// Callback functions for plugins: -// - -QList QWindowSystemInterfacePrivate::userEventQueue; -QMutex QWindowSystemInterfacePrivate::queueMutex; - -extern QPointer qt_last_mouse_receiver; -/*! - -\a tlw == 0 means that \a ev is in global coords only - - -*/ - - -void QWindowSystemInterface::handleEnterEvent(QWidget *tlw) -{ - if (tlw) { - QApplicationPrivate::dispatchEnterLeave(tlw, 0); - qt_last_mouse_receiver = tlw; - } -} - -void QWindowSystemInterface::handleLeaveEvent(QWidget *tlw) -{ - QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver); - if (tlw && !tlw->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen - QApplicationPrivate::dispatchEnterLeave(0, tlw); - qt_last_mouse_receiver = 0; -} - -void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect) -{ - if (tlw) - QApplicationPrivate::processGeometryChange(tlw, newRect); -} - - -void QWindowSystemInterface::handleCloseEvent(QWidget *tlw) -{ - if (tlw) - QApplicationPrivate::processCloseEvent(tlw); -} - -void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) -{ - MouseEvent * e = new MouseEvent(tlw, timestamp, local, global, b); - QWindowSystemInterfacePrivate::queueUserEvent(e); -} - -void QWindowSystemInterface::handleKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) -{ - KeyEvent * e = new KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count); - QWindowSystemInterfacePrivate::queueUserEvent(e); -} - -void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) -{ - WheelEvent *e = new WheelEvent(tlw, timestamp, local, global, d, o); - QWindowSystemInterfacePrivate::queueUserEvent(e); -} - -QWindowSystemInterface::UserEvent * QWindowSystemInterfacePrivate::getUserEvent() -{ - queueMutex.lock(); - QWindowSystemInterface::UserEvent *ret; - if (userEventQueue.isEmpty()) - ret = 0; - else - ret = userEventQueue.takeFirst(); - queueMutex.unlock(); - return ret; -} - -void QWindowSystemInterfacePrivate::queueUserEvent(QWindowSystemInterface::UserEvent *ev) -{ - queueMutex.lock(); - userEventQueue.append(ev); - queueMutex.unlock(); - - QAbstractEventDispatcher *dispatcher = QApplicationPrivate::qt_qpa_core_dispatcher(); - if (dispatcher) - dispatcher->wakeUp(); -} - -void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points) -{ - if (!points.size()) // Touch events must have at least one point - return; - - QList touchPoints; - Qt::TouchPointStates states; - QTouchEvent::TouchPoint p; - - int primaryPoint = -1; - QList::const_iterator point = points.constBegin(); - QList::const_iterator end = points.constEnd(); - while (point != end) { - p.setId(point->id); - p.setPressure(point->pressure); - states |= point->state; - Qt::TouchPointStates state = point->state; - if (point->isPrimary) { - state |= Qt::TouchPointPrimary; - primaryPoint = point->id; - } - p.setState(state); - p.setRect(point->area); - p.setScreenPos(point->area.center()); - p.setNormalizedPos(point->normalPosition); - - touchPoints.append(p); - ++point; - } - - TouchEvent *e = new TouchEvent(tlw, timestamp, type, devType, touchPoints); - QWindowSystemInterfacePrivate::queueUserEvent(e); -} - -void QWindowSystemInterface::handleScreenGeometryChange(int screenIndex) -{ - QApplicationPrivate::reportGeometryChange(screenIndex); -} - -void QWindowSystemInterface::handleScreenAvailableGeometryChange(int screenIndex) -{ - QApplicationPrivate::reportAvailableGeometryChange(screenIndex); -} - -void QWindowSystemInterface::handleScreenCountChange(int count) -{ - QApplicationPrivate::reportScreenCount(count); -} - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h deleted file mode 100644 index 614f983..0000000 --- a/src/gui/kernel/qwindowsysteminterface.h +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** 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 QWINDOWSYSTEMINTERFACE_H -#define QWINDOWSYSTEMINTERFACE_H - -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class Q_GUI_EXPORT QWindowSystemInterface -{ -public: - static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { - handleMouseEvent(w, eventTime.elapsed(), local, global, b); - } - - static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b); - - static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { - handleKeyEvent(w, eventTime.elapsed(), t, k, mods, text, autorep, count); - } - - 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 handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { - handleWheelEvent(w, eventTime.elapsed(), local, global, d, o); - } - - static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o); - - struct TouchPoint { - int id; // for application use - bool isPrimary; // for application use - QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1) - QRectF area; // the touched area, centered at position in screen coordinates - qreal pressure; // 0 to 1 - Qt::TouchPointStates state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released} - }; - - static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points) { - handleTouchEvent(w, eventTime.elapsed(), type, devType, points); - } - - static void handleTouchEvent(QWidget *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points); - - // delivered directly by the plugin via spontaneous events - static void handleGeometryChange(QWidget *w, const QRect &newRect); - static void handleCloseEvent(QWidget *w); - static void handleEnterEvent(QWidget *w); - static void handleLeaveEvent(QWidget *w); - - // Changes to the screen - static void handleScreenGeometryChange(int screenIndex); - static void handleScreenAvailableGeometryChange(int screenIndex); - static void handleScreenCountChange(int count); - - class UserEvent { - public: - UserEvent(QWidget * w, ulong time, QEvent::Type t) - { widget = QWeakPointer(w); type = t; timestamp = time; } - QWeakPointer widget; - QEvent::Type type; - unsigned long timestamp; - }; - - class MouseEvent : public UserEvent { - public: - MouseEvent(QWidget * w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b) - : UserEvent(w, time, QEvent::MouseMove){ localPos = local; globalPos = global; buttons = b; } - QPoint localPos; - QPoint globalPos; - Qt::MouseButtons buttons; - }; - - class WheelEvent : public UserEvent { - public: - WheelEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) - : UserEvent(w, time, QEvent::Wheel) { localPos = local; globalPos = global; delta = d; orient = o; } - int delta; - QPoint localPos; - QPoint globalPos; - Qt::Orientation orient; - }; - - class KeyEvent : public UserEvent { - 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, t){ key = k; unicode = text; repeat = autorep; repeatCount = count; modifiers = mods; } - int key; - QString unicode; - bool repeat; - ushort repeatCount; - Qt::KeyboardModifiers modifiers; - }; - - class TouchEvent : public UserEvent { - public: - TouchEvent(QWidget *w, ulong time, QEvent::Type t, QTouchEvent::DeviceType d, const QList &p) - :UserEvent(w, time, t) { devType = d; points = p; } - QTouchEvent::DeviceType devType; - QList points; - }; - -private: - static QTime eventTime; - -}; - -class QWindowSystemInterfacePrivate { -public: - static QList userEventQueue; - static QMutex queueMutex; - - static int userEventsQueued() { queueMutex.lock(); int ret = userEventQueue.count(); queueMutex.unlock(); return ret; } - static QWindowSystemInterface::UserEvent * getUserEvent(); - static void queueUserEvent(QWindowSystemInterface::UserEvent *ev); -}; - -QT_END_NAMESPACE -QT_END_HEADER -#endif // QWINDOWSYSTEMINTERFACE_H diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp new file mode 100644 index 0000000..dd78e8e --- /dev/null +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -0,0 +1,246 @@ +/**************************************************************************** +** +** 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 "qwindowsysteminterface_qpa.h" +#include "qwindowsysteminterface_qpa_p.h" +#include "qapplication_p.h" +#include + +QT_BEGIN_NAMESPACE + + +QTime QWindowSystemInterfacePrivate::eventTime; + +//------------------------------------------------------------ +// +// Callback functions for plugins: +// + +QList QWindowSystemInterfacePrivate::windowSystemEventQueue; +QMutex QWindowSystemInterfacePrivate::queueMutex; + +extern QPointer qt_last_mouse_receiver; + + +void QWindowSystemInterface::handleEnterEvent(QWidget *tlw) +{ + if (tlw) { + QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); + } +} + +void QWindowSystemInterface::handleLeaveEvent(QWidget *tlw) +{ + QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(tlw); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); +} + +void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect) +{ + if (!tlw) + return; + if (!tlw->isWindow()) + return; //geo of native child widgets is controlled by lighthouse + //so we already have sent the events; besides this new rect + //is not mapped to parent + + QRect cr(tlw->geometry()); + + bool isResize = cr.size() != newRect.size(); + bool isMove = cr.topLeft() != newRect.topLeft(); + if (isResize) { + QWindowSystemInterfacePrivate::ResizeEvent *resizeEvent = + new QWindowSystemInterfacePrivate::ResizeEvent(tlw,newRect.size()); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(resizeEvent); + } + + if (isMove) { + QWindowSystemInterfacePrivate::MoveEvent *moveEvent = + new QWindowSystemInterfacePrivate::MoveEvent(tlw,newRect.topLeft()); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(moveEvent); + } +} + + +void QWindowSystemInterface::handleCloseEvent(QWidget *tlw) +{ + if (tlw) { + QWindowSystemInterfacePrivate::CloseEvent *e = + new QWindowSystemInterfacePrivate::CloseEvent(tlw); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); + } +} + +/*! + +\a tlw == 0 means that \a ev is in global coords only + + +*/ +void QWindowSystemInterface::handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { + unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); + handleMouseEvent(w, time, local, global, b); +} + +void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) +{ + QWindowSystemInterfacePrivate::MouseEvent * e = + new QWindowSystemInterfacePrivate::MouseEvent(tlw, timestamp, local, global, b); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); +} + +void QWindowSystemInterface::handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) { + unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); + handleKeyEvent(w, time, t, k, mods, text, autorep, count); +} + +void QWindowSystemInterface::handleKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) +{ + QWindowSystemInterfacePrivate::KeyEvent * e = + new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, 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); +} + +void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) +{ + QWindowSystemInterfacePrivate::WheelEvent *e = + new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, d, o); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); +} + +int QWindowSystemInterfacePrivate::windowSystemEventsQueued() +{ + queueMutex.lock(); + int ret = windowSystemEventQueue.count(); + queueMutex.unlock(); + return ret; +} + +QWindowSystemInterfacePrivate::WindowSystemEvent * QWindowSystemInterfacePrivate::getWindowSystemEvent() +{ + queueMutex.lock(); + QWindowSystemInterfacePrivate::WindowSystemEvent *ret; + if (windowSystemEventQueue.isEmpty()) + ret = 0; + else + ret = windowSystemEventQueue.takeFirst(); + queueMutex.unlock(); + return ret; +} + +void QWindowSystemInterfacePrivate::queueWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev) +{ + queueMutex.lock(); + windowSystemEventQueue.append(ev); + queueMutex.unlock(); + + QAbstractEventDispatcher *dispatcher = QApplicationPrivate::qt_qpa_core_dispatcher(); + if (dispatcher) + dispatcher->wakeUp(); +} + +void QWindowSystemInterface::handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points) { + unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); + handleTouchEvent(w, time, type, devType, points); +} + +void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points) +{ + if (!points.size()) // Touch events must have at least one point + return; + + QList touchPoints; + Qt::TouchPointStates states; + QTouchEvent::TouchPoint p; + + int primaryPoint = -1; + QList::const_iterator point = points.constBegin(); + QList::const_iterator end = points.constEnd(); + while (point != end) { + p.setId(point->id); + p.setPressure(point->pressure); + states |= point->state; + Qt::TouchPointStates state = point->state; + if (point->isPrimary) { + state |= Qt::TouchPointPrimary; + primaryPoint = point->id; + } + p.setState(state); + p.setRect(point->area); + p.setScreenPos(point->area.center()); + p.setNormalizedPos(point->normalPosition); + + touchPoints.append(p); + ++point; + } + + QWindowSystemInterfacePrivate::TouchEvent *e = + new QWindowSystemInterfacePrivate::TouchEvent(tlw, timestamp, type, devType, touchPoints); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); +} + +void QWindowSystemInterface::handleScreenGeometryChange(int screenIndex) +{ + QWindowSystemInterfacePrivate::ScreenGeometryEvent *e = + new QWindowSystemInterfacePrivate::ScreenGeometryEvent(screenIndex); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); +} + +void QWindowSystemInterface::handleScreenAvailableGeometryChange(int screenIndex) +{ + QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e = + new QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent(screenIndex); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); +} + +void QWindowSystemInterface::handleScreenCountChange(int count) +{ + QWindowSystemInterfacePrivate::ScreenCountEvent *e = + new QWindowSystemInterfacePrivate::ScreenCountEvent(count); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h new file mode 100644 index 0000000..e57fa8e --- /dev/null +++ b/src/gui/kernel/qwindowsysteminterface_qpa.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** 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 QWINDOWSYSTEMINTERFACE_H +#define QWINDOWSYSTEMINTERFACE_H + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class Q_GUI_EXPORT QWindowSystemInterface +{ +public: + static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b); + static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b); + + 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 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); + + struct TouchPoint { + int id; // for application use + bool isPrimary; // for application use + QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1) + QRectF area; // the touched area, centered at position in screen coordinates + qreal pressure; // 0 to 1 + Qt::TouchPointStates state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released} + }; + + static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points); + static void handleTouchEvent(QWidget *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points); + + // delivered directly by the plugin via spontaneous events + static void handleGeometryChange(QWidget *w, const QRect &newRect); + static void handleCloseEvent(QWidget *w); + static void handleEnterEvent(QWidget *w); + static void handleLeaveEvent(QWidget *w); + + // Changes to the screen + static void handleScreenGeometryChange(int screenIndex); + static void handleScreenAvailableGeometryChange(int screenIndex); + static void handleScreenCountChange(int count); +}; + +QT_END_NAMESPACE +QT_END_HEADER +#endif // QWINDOWSYSTEMINTERFACE_H diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h new file mode 100644 index 0000000..90d1702 --- /dev/null +++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h @@ -0,0 +1,201 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 QWINDOWSYSTEMINTERFACE_QPA_P_H +#define QWINDOWSYSTEMINTERFACE_QPA_P_H + +#include "qwindowsysteminterface_qpa.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QWindowSystemInterfacePrivate { +public: + Q_ENUMS(EventType); + + enum EventType { + Close, + Resize, + Move, + Enter, + Leave, + Mouse, + Wheel, + Key, + Touch, + ScreenGeometry, + ScreenAvailableGeometry, + ScreenCountChange + }; + + class WindowSystemEvent { + public: + WindowSystemEvent(EventType t) + : type(t) { } + EventType type; + }; + + class CloseEvent : public WindowSystemEvent { + public: + CloseEvent(QWidget *tlw) + : WindowSystemEvent(Close), topLevel(tlw) { } + QWeakPointer topLevel; + }; + + class ResizeEvent : public WindowSystemEvent { + public: + ResizeEvent(QWidget *sizeChanged, const QSize &newSize) + : WindowSystemEvent(Resize), sizeChanged(sizeChanged), newSize(newSize) + { } + QWeakPointer sizeChanged; + QSize newSize; + }; + + class MoveEvent : public WindowSystemEvent { + public: + MoveEvent(QWidget *moved, const QPoint &newPos) + : WindowSystemEvent(Move), moved(moved), newPos(newPos) + { } + QWeakPointer moved; + QPoint newPos; + }; + + class EnterEvent : public WindowSystemEvent { + public: + EnterEvent(QWidget *enter) + : WindowSystemEvent(Enter), enter(enter) + { } + QWeakPointer enter; + }; + + class LeaveEvent : public WindowSystemEvent { + public: + LeaveEvent(QWidget *leave) + : WindowSystemEvent(Leave), leave(leave) + { } + QWeakPointer leave; + }; + + class UserEvent : public WindowSystemEvent { + public: + UserEvent(QWidget * w, ulong time, EventType t) + : WindowSystemEvent(t), widget(w), timestamp(time) { } + QWeakPointer widget; + unsigned long timestamp; + }; + + class MouseEvent : public UserEvent { + public: + MouseEvent(QWidget * w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b) + : UserEvent(w, time, Mouse), localPos(local), globalPos(global), buttons(b) { } + QPoint localPos; + QPoint globalPos; + Qt::MouseButtons buttons; + }; + + class WheelEvent : public UserEvent { + public: + WheelEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) + : UserEvent(w, time, Wheel), delta(d), localPos(local), globalPos(global), orient(o) { } + int delta; + QPoint localPos; + QPoint globalPos; + Qt::Orientation orient; + }; + + class KeyEvent : public UserEvent { + 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) { } + int key; + QString unicode; + bool repeat; + ushort repeatCount; + Qt::KeyboardModifiers modifiers; + QEvent::Type keyType; + }; + + class TouchEvent : public UserEvent { + public: + TouchEvent(QWidget *w, ulong time, QEvent::Type t, QTouchEvent::DeviceType d, const QList &p) + :UserEvent(w, time, Touch), devType(d), points(p), touchType(t) { } + QTouchEvent::DeviceType devType; + QList points; + QEvent::Type touchType; + + }; + + class ScreenCountEvent : public WindowSystemEvent { + public: + ScreenCountEvent (int count) + : WindowSystemEvent(ScreenCountChange) , count(count) { } + int count; + }; + + class ScreenGeometryEvent : public WindowSystemEvent { + public: + ScreenGeometryEvent(int index) + : WindowSystemEvent(ScreenGeometry), index(index) { } + int index; + }; + + class ScreenAvailableGeometryEvent : public WindowSystemEvent { + public: + ScreenAvailableGeometryEvent(int index) + : WindowSystemEvent(ScreenAvailableGeometry), index(index) { } + int index; + }; + + static QList windowSystemEventQueue; + static QMutex queueMutex; + + static int windowSystemEventsQueued(); + static WindowSystemEvent * getWindowSystemEvent(); + static void queueWindowSystemEvent(WindowSystemEvent *ev); + + static QTime eventTime; +}; + +QT_END_HEADER +QT_END_NAMESPACE + +#endif // QWINDOWSYSTEMINTERFACE_QPA_P_H -- cgit v0.12 From a17b1d7c18737de1b3c6122a1f9766cbaa0d7c26 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 21 Jul 2010 10:14:18 +0200 Subject: Less ugly hack to make QtOpenGL compile on Lighthouse This cleans up after commit bc5f5d99078d9ca1f4fc80fc7d0fe753d5ef396a --- src/gui/painting/qwindowsurface_p.h | 1 + src/opengl/qwindowsurface_gl.cpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h index da02f5a..c845021 100644 --- a/src/gui/painting/qwindowsurface_p.h +++ b/src/gui/painting/qwindowsurface_p.h @@ -86,6 +86,7 @@ public: #else virtual void resize(const QSize &size); QSize size() const; + inline QRect geometry() const { return QRect(QPoint(), size()); } //### cleanup before Qt 5 #endif virtual bool scroll(const QRegion &area, int dx, int dy); diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 8c54fd1..6571a76 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -499,13 +499,11 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & } } #endif -#ifndef Q_WS_QPA //############################################### if (d_ptr->paintedRegion.boundingRect() != geometry()) { // Emits warning if not supported. Should never happen unless // setPartialUpdateSupport(true) has been called. context()->d_func()->swapRegion(&d_ptr->paintedRegion); } else -#endif context()->swapBuffers(); d_ptr->paintedRegion = QRegion(); -- cgit v0.12 From 22edd932bb5af334bbe1a1774604332eee14814f Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 21 Jul 2010 12:24:02 +0200 Subject: Don't turn off exceptions by default in Lighthouse --- configure | 3 --- 1 file changed, 3 deletions(-) diff --git a/configure b/configure index 97f7fb2..a7f545a 100755 --- a/configure +++ b/configure @@ -7007,9 +7007,6 @@ fi if [ "$CFG_EXCEPTIONS" = "unspecified" -a "$PLATFORM_QWS" = "yes" ]; then CFG_EXCEPTIONS=no fi -if [ "$CFG_EXCEPTIONS" = "unspecified" -a "$PLATFORM_QPA" = "yes" ]; then - CFG_EXCEPTIONS=no -fi if [ "$CFG_EXCEPTIONS" != "no" ]; then QTCONFIG_CONFIG="$QTCONFIG_CONFIG exceptions" -- cgit v0.12 From 705f497bc21863b2bb580d39aabe371622f937aa Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 21 Jul 2010 12:40:42 +0200 Subject: Skip QSound autotest on Lighthouse QSound is not implemented. --- tests/auto/qsound/tst_qsound.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/auto/qsound/tst_qsound.cpp b/tests/auto/qsound/tst_qsound.cpp index eda99a1..295ed91 100644 --- a/tests/auto/qsound/tst_qsound.cpp +++ b/tests/auto/qsound/tst_qsound.cpp @@ -63,6 +63,9 @@ private slots: void tst_QSound::checkFinished() { +#if defined(Q_WS_QPA) + QSKIP("QSound is not implemented on Lighthouse", SkipAll); +#else QSound sound(SRCDIR"4.wav"); sound.setLoops(3); sound.play(); @@ -72,15 +75,17 @@ void tst_QSound::checkFinished() QEXPECT_FAIL("", "QSound buggy on embedded (task QTBUG-157)", Abort); #endif QVERIFY(sound.isFinished() ); +#endif } void tst_QSound::staticPlay() { QSKIP("Test disabled -- only for manual purposes", SkipAll); - +#if !defined(Q_WS_QPA) // Check that you hear sound with static play also. QSound::play(SRCDIR"4.wav"); QTest::qWait(2000); +#endif } QTEST_MAIN(tst_QSound); -- cgit v0.12 From e485492385d5d02b170617251678a7d28d39c8d9 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 21 Jul 2010 13:31:33 +0200 Subject: Header file cleanup Make the "headers" autotest pass on Lighthouse --- src/gui/kernel/qplatformwindowformat_qpa.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qplatformwindowformat_qpa.h b/src/gui/kernel/qplatformwindowformat_qpa.h index 3c5f907..09c3520 100644 --- a/src/gui/kernel/qplatformwindowformat_qpa.h +++ b/src/gui/kernel/qplatformwindowformat_qpa.h @@ -41,7 +41,7 @@ #ifndef QPLATFORMWINDOWFORMAT_QPA_H #define QPLATFORMWINDOWFORMAT_QPA_H -#include +#include QT_BEGIN_HEADER -- cgit v0.12 From 3d0c33f70fb60095f9a1065eceb1ae1aa854af2d Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 21 Jul 2010 16:07:13 +0200 Subject: Autotest fixes for Lighthouse --- tests/auto/qwidget/tst_qwidget.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 5e39c27..6450793 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -2167,7 +2167,10 @@ void tst_QWidget::resizeEvent() wParent.show(); QCOMPARE (wChild.m_resizeEventCount, 1); // initial resize event before paint wParent.hide(); - wChild.resize(QSize(640,480)); + QSize safeSize(640,480); + if (wChild.size() == safeSize) + safeSize.setWidth(639); + wChild.resize(safeSize); QCOMPARE (wChild.m_resizeEventCount, 1); wParent.show(); QCOMPARE (wChild.m_resizeEventCount, 2); @@ -2178,7 +2181,10 @@ void tst_QWidget::resizeEvent() wTopLevel.show(); QCOMPARE (wTopLevel.m_resizeEventCount, 1); // initial resize event before paint for toplevels wTopLevel.hide(); - wTopLevel.resize(QSize(640,480)); + QSize safeSize(640,480); + if (wTopLevel.size() == safeSize) + safeSize.setWidth(639); + wTopLevel.resize(safeSize); QCOMPARE (wTopLevel.m_resizeEventCount, 1); wTopLevel.show(); QCOMPARE (wTopLevel.m_resizeEventCount, 2); @@ -3375,6 +3381,10 @@ void tst_QWidget::widgetAt() #if defined(Q_OS_SYMBIAN) QEXPECT_FAIL("", "Symbian/S60 does only support rectangular regions", Continue); //See also task 147191 #endif +#if defined(Q_WS_QPA) + QEXPECT_FAIL("", "Window mask not implemented on Lighthouse", Continue); +#endif + QTRY_COMPARE(QApplication::widgetAt(100,100)->objectName(), w1->objectName()); QTRY_COMPARE(QApplication::widgetAt(101,101)->objectName(), w2->objectName()); @@ -3393,6 +3403,9 @@ void tst_QWidget::widgetAt() #if defined(Q_OS_SYMBIAN) QEXPECT_FAIL("", "Symbian/S60 does only support rectangular regions", Continue); //See also task 147191 #endif +#if defined(Q_WS_QPA) + QEXPECT_FAIL("", "Window mask not implemented on Lighthouse", Continue); +#endif QTRY_VERIFY(QApplication::widgetAt(100,100) == w1); QTRY_VERIFY(QApplication::widgetAt(101,101) == w2); -- cgit v0.12 From 77d17d054b8baff411613206a099af36f8e0bc43 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 21 Jul 2010 16:07:34 +0200 Subject: Quick-and-dirty grabWindoe() implementation for the VNC plugin --- src/plugins/platforms/vnc/qvncintegration.cpp | 44 +++++++++++++++++++++------ src/plugins/platforms/vnc/qvncintegration.h | 2 ++ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp index 16fa5bb..331c16a 100644 --- a/src/plugins/platforms/vnc/qvncintegration.cpp +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -156,16 +156,6 @@ QPixmapData *QVNCIntegration::createPixmapData(QPixmapData::PixelType type) cons return new QRasterPixmapData(type); } -// QWindowSurface *QVNCIntegration::createWindowSurface(QWidget *widget) const -// { -// if (widget->windowType() == Qt::Desktop) -// return 0; // Don't create an explicit window surface for the destkop. -// QFbWindowSurface * surface; -// surface = new QFbWindowSurface(mPrimaryScreen, widget); -// mPrimaryScreen->addWindowSurface(surface); -// return surface; -// } - QWindowSurface *QVNCIntegration::createWindowSurface(QWidget *widget, WId) const { QFbWindowSurface * surface; @@ -192,6 +182,40 @@ QPlatformWindow *QVNCIntegration::createPlatformWindow(QWidget *widget, WId /*wi return w; } +QPixmap QVNCIntegration::grabWindow(WId window, int x, int y, int width, int height) const +{ +// qDebug() << "QVNCIntegration::grabWindow" << window << x << y << width << height; + + if (window == 0) { //desktop + QImage *desktopImage = mPrimaryScreen->image(); + if (x==0 && y == 0 && width < 0 && height < 0) { + return QPixmap::fromImage(*desktopImage); + } + if (width < 0) + width = desktopImage->width() - x; + if (height < 0) + height = desktopImage->height() - y; + int bytesPerPixel = desktopImage->depth()/8; //We don't support 1, 2, or 4 bpp + QImage img(desktopImage->scanLine(y) + bytesPerPixel*x, width, height, desktopImage->bytesPerLine(), desktopImage->format()); + return QPixmap::fromImage(img); + } + QWidget *win = QWidget::find(window); + if (win) { + QRect r = win->geometry(); + if (width < 0) + width = r.width() - x; + if (height < 0) + height = r.height() - y; + QImage *desktopImage = mPrimaryScreen->image(); + int bytesPerPixel = desktopImage->depth()/8; //We don't support 1, 2, or 4 bpp + + QImage img(desktopImage->scanLine(r.top() + y) + bytesPerPixel*(r.left()+x), width, height, desktopImage->bytesPerLine(), desktopImage->format()); + return QPixmap::fromImage(img); + } + return QPixmap(); +} + + void QVNCIntegration::moveToScreen(QWidget *window, int screen) { if (virtualDesktop) { // all windows exist on all screens in virtual desktop mode diff --git a/src/plugins/platforms/vnc/qvncintegration.h b/src/plugins/platforms/vnc/qvncintegration.h index d49e051..241993d 100644 --- a/src/plugins/platforms/vnc/qvncintegration.h +++ b/src/plugins/platforms/vnc/qvncintegration.h @@ -84,6 +84,8 @@ public: QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + QPixmap grabWindow(WId window, int x, int y, int width, int height) const; + QList screens() const { return mScreens; } bool isVirtualDesktop() { return virtualDesktop; } -- cgit v0.12 From 96f1f3d575a12967657bb534ee5accc04d52984e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 21 Jul 2010 09:58:25 +0200 Subject: Removed createBlittable factory function from PlatformIntegration and moved it onto QBlittablePixmap making the class abstract. The creator function was seen as to spesialised to be part of the PlatformIntegration class, and belonged to the QBlittablePixmap class anyway since that was the PixmapData type you would need to return to use the blitter api. Also removed the cross platform examples as they are more confusing than anything else. For usage of QBlittable look in the directfb platform integration plugin. --- src/gui/image/qpixmap_blitter.cpp | 10 +-- src/gui/image/qpixmap_blitter_p.h | 3 +- src/gui/kernel/qapplication_p.h | 4 +- src/gui/kernel/qplatformintegration_qpa.cpp | 3 - src/gui/kernel/qplatformintegration_qpa.h | 2 +- src/gui/painting/painting.pri | 6 +- src/gui/painting/qblittable_p.h | 3 +- src/gui/painting/qgraphicssystem.cpp | 3 - src/gui/painting/qgraphicssystem_p.h | 1 - .../painting/qwindowsurface_rasterblittable.cpp | 26 ------- .../painting/qwindowsurface_rasterblittable_p.h | 21 ------ .../gfxdrivers/blittableqvfb/blittableqvfb.pro | 28 -------- src/plugins/gfxdrivers/blittableqvfb/main.cpp | 81 ---------------------- .../gfxdrivers/blittableqvfb/qblittable_image.h | 48 ------------- .../blittableqvfb/qgraphicssystem_blittableqvfb.h | 47 ------------- .../blittableqvfb/qscreen_blittableqvfb.h | 14 ---- .../blittableqvfb/qwindowsurface_qwsblittable.cpp | 0 .../blittableqvfb/qwindowsurface_qwsblittable.h | 36 ---------- .../graphicssystems/blittable/blittable.pro | 11 --- src/plugins/graphicssystems/blittable/main.cpp | 73 ------------------- .../graphicssystems/blittable/qblittable_image.h | 48 ------------- .../blittable/qgraphicssystem_blittable.h | 53 -------------- src/plugins/platforms/directfb/qdirectfbblitter.h | 6 ++ .../platforms/directfb/qdirectfbintegration.cpp | 2 +- .../platforms/directfb/qdirectfbwindowsurface.cpp | 2 +- 25 files changed, 21 insertions(+), 510 deletions(-) delete mode 100644 src/gui/painting/qwindowsurface_rasterblittable.cpp delete mode 100644 src/gui/painting/qwindowsurface_rasterblittable_p.h delete mode 100644 src/plugins/gfxdrivers/blittableqvfb/blittableqvfb.pro delete mode 100644 src/plugins/gfxdrivers/blittableqvfb/main.cpp delete mode 100644 src/plugins/gfxdrivers/blittableqvfb/qblittable_image.h delete mode 100644 src/plugins/gfxdrivers/blittableqvfb/qgraphicssystem_blittableqvfb.h delete mode 100644 src/plugins/gfxdrivers/blittableqvfb/qscreen_blittableqvfb.h delete mode 100644 src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.cpp delete mode 100644 src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.h delete mode 100644 src/plugins/graphicssystems/blittable/blittable.pro delete mode 100644 src/plugins/graphicssystems/blittable/main.cpp delete mode 100644 src/plugins/graphicssystems/blittable/qblittable_image.h delete mode 100644 src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index d91a269..9a7ebe2 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -14,8 +14,8 @@ QT_BEGIN_NAMESPACE static int global_ser_no = 0; -QBlittablePixmapData::QBlittablePixmapData(QPixmapData::PixelType type) - : QPixmapData(type,BlitterClass), m_engine(0), m_blittable(0) +QBlittablePixmapData::QBlittablePixmapData() + : QPixmapData(QPixmapData::PixmapType,BlitterClass), m_engine(0), m_blittable(0) #ifdef QT_BLITTER_RASTEROVERLAY ,m_rasterOverlay(0), m_unmergedCopy(0) #endif //QT_BLITTER_RASTEROVERLAY @@ -37,11 +37,7 @@ QBlittable *QBlittablePixmapData::blittable() const { if (!m_blittable) { QBlittablePixmapData *that = const_cast(this); -#ifdef Q_WS_QPA //####jl: graphics system nor platformintegration should have createBlittable - that->m_blittable = QApplicationPrivate::platformIntegration()->createBlittable(QSize(w,h)); -#else - that->m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QSize(w,h)); -#endif + that->m_blittable = this->createBlittable(QSize(w,h)); } return m_blittable; diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index b9f7630..e404199 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -11,9 +11,10 @@ class Q_GUI_EXPORT QBlittablePixmapData : public QPixmapData { // Q_DECLARE_PRIVATE(QBlittablePixmapData); public: - QBlittablePixmapData(QPixmapData::PixelType type); + QBlittablePixmapData(); ~QBlittablePixmapData(); + virtual QBlittable *createBlittable(const QSize &size) const = 0; QBlittable *blittable() const; void setBlittable(QBlittable *blittable); diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 0602d82..de97f62 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -432,8 +432,10 @@ public: static QPalette *set_pal; static QGraphicsSystem *graphics_system; static QString graphics_system_name; - static QPlatformIntegration *platform_integration; static bool runtime_graphics_system; +#ifdef Q_WS_QPA + static QPlatformIntegration *platform_integration; +#endif private: static QFont *app_font; // private for a reason! Always use QApplication::font() instead! diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp index b3f46ce..b4987f2 100644 --- a/src/gui/kernel/qplatformintegration_qpa.cpp +++ b/src/gui/kernel/qplatformintegration_qpa.cpp @@ -43,9 +43,6 @@ QT_BEGIN_NAMESPACE -QBlittable *QPlatformIntegration::createBlittable(const QSize &) const -{ return 0; } - QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, int height) const { Q_UNUSED(window); diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h index 11377e7..f6f10a8 100644 --- a/src/gui/kernel/qplatformintegration_qpa.h +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -66,7 +66,6 @@ public: virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; virtual QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const = 0; virtual QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const = 0; - virtual QBlittable *createBlittable(const QSize &size) const; virtual void moveToScreen(QWidget *window, int screen) {Q_UNUSED(window); Q_UNUSED(screen);} // Window System functions @@ -77,6 +76,7 @@ public: // Experimental virtual QPlatformEventLoopIntegration *createEventLoopIntegration() const; +// should it be hasGLContext? virtual bool hasOpenGL() const; diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 7ef6598..92c4e84 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -125,16 +125,14 @@ embedded { painting/qgraphicssystem_runtime_p.h \ painting/qgraphicssystemfactory_p.h \ painting/qgraphicssystemplugin_p.h \ - painting/qwindowsurface_raster_p.h \ - painting/qwindowsurface_rasterblittable_p.h \ + painting/qwindowsurface_raster_p.h SOURCES += \ painting/qgraphicssystem_raster.cpp \ painting/qgraphicssystem_runtime.cpp \ painting/qgraphicssystemfactory.cpp \ painting/qgraphicssystemplugin.cpp \ - painting/qwindowsurface_raster.cpp \ - painting/qwindowsurface_rasterblittable.cpp \ + painting/qwindowsurface_raster.cpp } unix:x11 { diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h index 645f37e..71e80af 100644 --- a/src/gui/painting/qblittable_p.h +++ b/src/gui/painting/qblittable_p.h @@ -2,7 +2,8 @@ #define QBLITTABLE_P_H #include -#include +#include + #ifndef QT_NO_BLITTABLE QT_BEGIN_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp index a03bdab..f594136 100644 --- a/src/gui/painting/qgraphicssystem.cpp +++ b/src/gui/painting/qgraphicssystem.cpp @@ -63,9 +63,6 @@ QGraphicsSystem::~QGraphicsSystem() { } -QBlittable *QGraphicsSystem::createBlittable(const QSize &) const -{ return 0; } - QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType type) { #ifdef Q_WS_QWS diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index 0d84886..a75ea61 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -70,7 +70,6 @@ public: virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; virtual QPixmapData *createPixmapData(QPixmapData *origin); virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0; - virtual QBlittable *createBlittable(const QSize &size) const; virtual ~QGraphicsSystem(); diff --git a/src/gui/painting/qwindowsurface_rasterblittable.cpp b/src/gui/painting/qwindowsurface_rasterblittable.cpp deleted file mode 100644 index 56a79ba..0000000 --- a/src/gui/painting/qwindowsurface_rasterblittable.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "qwindowsurface_rasterblittable_p.h" - -#include -#include - -QRasterBlittableWindowSurface::QRasterBlittableWindowSurface(QWidget *widget) - : QRasterWindowSurface(widget), - m_currentImage(0), - m_blittable(0), - m_pmData(new QBlittablePixmapData(QPixmapData::PixmapType)), - m_pixmap(new QPixmap(m_pmData)) -{ -} - -QPaintDevice *QRasterBlittableWindowSurface::paintDevice() -{ - QPaintDevice *device = QRasterWindowSurface::paintDevice(); - if (m_currentImage != device) { - if (device->devType() == QInternal::Image) { - m_currentImage = static_cast(device); - m_blittable = createBlittable(m_currentImage); - m_pmData->setBlittable(m_blittable); - } - } - return m_pixmap; -} diff --git a/src/gui/painting/qwindowsurface_rasterblittable_p.h b/src/gui/painting/qwindowsurface_rasterblittable_p.h deleted file mode 100644 index 1e697c7..0000000 --- a/src/gui/painting/qwindowsurface_rasterblittable_p.h +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -class QBlittable; -class QBlittablePixmapData; - -class Q_GUI_EXPORT QRasterBlittableWindowSurface : public QRasterWindowSurface -{ -public: - QRasterBlittableWindowSurface(QWidget *widget); - - virtual QBlittable *createBlittable(QImage *rasterSurface) = 0; - - QPaintDevice *paintDevice(); - -private: - QImage *m_currentImage; - QBlittable *m_blittable; - QBlittablePixmapData *m_pmData; - QPixmap *m_pixmap; -}; diff --git a/src/plugins/gfxdrivers/blittableqvfb/blittableqvfb.pro b/src/plugins/gfxdrivers/blittableqvfb/blittableqvfb.pro deleted file mode 100644 index d6a2018..0000000 --- a/src/plugins/gfxdrivers/blittableqvfb/blittableqvfb.pro +++ /dev/null @@ -1,28 +0,0 @@ -TARGET = qscreenblittablevfb -include(../../qpluginbase.pri) - -DEFINES += QT_QWS_QVFB QT_QWS_MOUSE_QVFB QT_QWS_KBD_QVFB - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers - -HEADERS = qgraphicssystem_blittableqvfb.h \ - qscreen_blittableqvfb.h \ - qwindowsurface_qwsblittable.h \ - qblittable_image.h - -SOURCES = main.cpp \ - qwindowsurface_qwsblittable.cpp - -#include qvfb sources -HEADERS += \ - $$QT_SOURCE_TREE/src/gui/embedded/qscreenvfb_qws.h \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdvfb_qws.h \ - $$QT_SOURCE_TREE/src/gui/embedded/qmousevfb_qws.h - -SOURCES += \ - $$QT_SOURCE_TREE/src/gui/embedded/qscreenvfb_qws.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdvfb_qws.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qmousevfb_qws.cpp - -target.path += $$[QT_INSTALL_PLUGINS]/gfxdrivers -INSTALLS += target diff --git a/src/plugins/gfxdrivers/blittableqvfb/main.cpp b/src/plugins/gfxdrivers/blittableqvfb/main.cpp deleted file mode 100644 index b6d2603..0000000 --- a/src/plugins/gfxdrivers/blittableqvfb/main.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** 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 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 -#include -#include "qscreen_blittableqvfb.h" - -#ifndef QT_NO_LIBRARY -QT_BEGIN_NAMESPACE - -class ScreenBlittableVfbDriver : public QScreenDriverPlugin -{ -public: - ScreenBlittableVfbDriver(); - - QStringList keys() const; - QScreen *create(const QString&, int displayId); -}; - -ScreenBlittableVfbDriver::ScreenBlittableVfbDriver() -: QScreenDriverPlugin() -{ -} - -QStringList ScreenBlittableVfbDriver::keys() const -{ - QStringList list; - list << "BlittableQVFb"; - return list; -} - -QScreen* ScreenBlittableVfbDriver::create(const QString& driver, int displayId) -{ - if (driver.toLower() == "blittableqvfb") - return new QBlittableVFbScreen(displayId); - - return 0; -} - -Q_EXPORT_PLUGIN2(qscreenblittablevfb, ScreenBlittableVfbDriver) - -QT_END_NAMESPACE -#endif //QT_NO_LIBRARY diff --git a/src/plugins/gfxdrivers/blittableqvfb/qblittable_image.h b/src/plugins/gfxdrivers/blittableqvfb/qblittable_image.h deleted file mode 100644 index 3f8dc69..0000000 --- a/src/plugins/gfxdrivers/blittableqvfb/qblittable_image.h +++ /dev/null @@ -1,48 +0,0 @@ -#include - -#include - - -class QImageBlittable : public QBlittable -{ -public: - QImageBlittable(QImage *image, bool deleteImage) - : QBlittable(image->size(), QBlittable::Capabilities(QBlittable::SolidRectCapability - |QBlittable::SourcePixmapCapability - |QBlittable::SourceOverPixmapCapability - |QBlittable::SourceOverScaledPixmapCapability)), - m_image(image), m_deleteImage(deleteImage) - { - - } - - ~QImageBlittable() { - if (m_deleteImage) - delete m_image; - } - - void fillRect(const QRectF &rect, const QColor &color) - { - QPainter p(lock()); - p.fillRect(rect,color); - } - void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &source) - { - //here it is possible to do a pixmap.pixmapData()->buffer() - //but is like this to show how to get the the blitter - QPixmapData *data = pixmap.pixmapData(); - Q_ASSERT(data->width() && data->height()); - Q_ASSERT(data->classId() == QPixmapData::BlitterClass); - QBlittablePixmapData *blittableData = static_cast(data); - - QPainter p(lock()); - p.drawImage(rect, *blittableData->blittable()->lock(),source); - } - -protected: - QImage *doLock() { return m_image; } - void doUnlock() { } -private: - QImage *m_image; - bool m_deleteImage; -}; diff --git a/src/plugins/gfxdrivers/blittableqvfb/qgraphicssystem_blittableqvfb.h b/src/plugins/gfxdrivers/blittableqvfb/qgraphicssystem_blittableqvfb.h deleted file mode 100644 index 89940d0..0000000 --- a/src/plugins/gfxdrivers/blittableqvfb/qgraphicssystem_blittableqvfb.h +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include -#include -#include - -#include "qwindowsurface_qwsblittable.h" -#include "qblittable_image.h" -#include - -class QBlittableVFbGraphicsSystem : public QGraphicsSystem -{ -public: - QPixmapData *createPixmapData(QPixmapData::PixelType type) const - { - if (type == QPixmapData::PixmapType) { - return new QBlittablePixmapData(type); - } else { - return new QRasterPixmapData(type); - } - } - - QWindowSurface *createWindowSurface(QWidget *widget) const - { - if (QApplication::type() == QApplication::GuiServer) - return new QWSBlittableMemSurface(widget); - else - return QScreen::instance()->createSurface(widget); - } - - QBlittable *createBlittable(const QSize &size) const - { - QImage *image = new QImage(size,QImage::Format_ARGB32); - return new QImageBlittable(image,true); - } - - static QGraphicsSystem *instance() - { - static QGraphicsSystem *system = 0; - if (!system) { - system = new QBlittableVFbGraphicsSystem; - } - return system; - } - -private: - QBlittableVFbGraphicsSystem() { } -}; diff --git a/src/plugins/gfxdrivers/blittableqvfb/qscreen_blittableqvfb.h b/src/plugins/gfxdrivers/blittableqvfb/qscreen_blittableqvfb.h deleted file mode 100644 index 645aeec..0000000 --- a/src/plugins/gfxdrivers/blittableqvfb/qscreen_blittableqvfb.h +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include "qgraphicssystem_blittableqvfb.h" - -class QBlittableVFbScreen : public QVFbScreen -{ -public: - explicit QBlittableVFbScreen(int display_id) - : QVFbScreen(display_id) - { - setGraphicsSystem(QBlittableVFbGraphicsSystem::instance()); - - } - -}; diff --git a/src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.cpp b/src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.h b/src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.h deleted file mode 100644 index b955322..0000000 --- a/src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.h +++ /dev/null @@ -1,36 +0,0 @@ -#include "qblittable_image.h" - -#include -#include - -class QBlittablePixmapData; - -class Q_GUI_EXPORT QWSBlittableMemSurface : public QWSLocalMemSurface -{ -public: - QWSBlittableMemSurface( QWidget *window ) - : QWSLocalMemSurface(window), - m_currentPaintDevice(0), - pmData(new QBlittablePixmapData(QPixmapData::PixmapType)), - pm(pmData) - { - } - - QPaintDevice *paintDevice() - { - if (QWSLocalMemSurface::paintDevice() != m_currentPaintDevice) { - QPaintDevice *device = QWSLocalMemSurface::paintDevice(); - if (device->devType() == QInternal::Image) { - img = *static_cast(device); - pmData->setBlittable(new QImageBlittable(&img,false)); - } - } - return ± - } - -private: - QPaintDevice *m_currentPaintDevice; - QBlittablePixmapData *pmData; - QPixmap pm; -}; - diff --git a/src/plugins/graphicssystems/blittable/blittable.pro b/src/plugins/graphicssystems/blittable/blittable.pro deleted file mode 100644 index 34c4165..0000000 --- a/src/plugins/graphicssystems/blittable/blittable.pro +++ /dev/null @@ -1,11 +0,0 @@ -TARGET = qblittablegraphicssystem -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - -SOURCES = main.cpp -HEADERS = qblittable_image.h \ - qgraphicssystem_blittable.h - -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -INSTALLS += target diff --git a/src/plugins/graphicssystems/blittable/main.cpp b/src/plugins/graphicssystems/blittable/main.cpp deleted file mode 100644 index 06c3189..0000000 --- a/src/plugins/graphicssystems/blittable/main.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** 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 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 - -#include "qgraphicssystem_blittable.h" - -QT_BEGIN_NAMESPACE - -class QBlittableGraphicsSystemPlugin : public QGraphicsSystemPlugin -{ -public: - QStringList keys() const; - QGraphicsSystem *create(const QString&); -}; - -QStringList QBlittableGraphicsSystemPlugin::keys() const -{ - QStringList list; - list << QLatin1String("Blittable"); - return list; -} - -QGraphicsSystem* QBlittableGraphicsSystemPlugin::create(const QString& system) -{ - if (system.toLower() == QLatin1String("blittable")) { - return new QBlittableGraphicsSystem; - } - - return 0; -} - -Q_EXPORT_PLUGIN2(blittable, QBlittableGraphicsSystemPlugin) - -QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/blittable/qblittable_image.h b/src/plugins/graphicssystems/blittable/qblittable_image.h deleted file mode 100644 index 3f8dc69..0000000 --- a/src/plugins/graphicssystems/blittable/qblittable_image.h +++ /dev/null @@ -1,48 +0,0 @@ -#include - -#include - - -class QImageBlittable : public QBlittable -{ -public: - QImageBlittable(QImage *image, bool deleteImage) - : QBlittable(image->size(), QBlittable::Capabilities(QBlittable::SolidRectCapability - |QBlittable::SourcePixmapCapability - |QBlittable::SourceOverPixmapCapability - |QBlittable::SourceOverScaledPixmapCapability)), - m_image(image), m_deleteImage(deleteImage) - { - - } - - ~QImageBlittable() { - if (m_deleteImage) - delete m_image; - } - - void fillRect(const QRectF &rect, const QColor &color) - { - QPainter p(lock()); - p.fillRect(rect,color); - } - void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &source) - { - //here it is possible to do a pixmap.pixmapData()->buffer() - //but is like this to show how to get the the blitter - QPixmapData *data = pixmap.pixmapData(); - Q_ASSERT(data->width() && data->height()); - Q_ASSERT(data->classId() == QPixmapData::BlitterClass); - QBlittablePixmapData *blittableData = static_cast(data); - - QPainter p(lock()); - p.drawImage(rect, *blittableData->blittable()->lock(),source); - } - -protected: - QImage *doLock() { return m_image; } - void doUnlock() { } -private: - QImage *m_image; - bool m_deleteImage; -}; diff --git a/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h b/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h deleted file mode 100644 index d45907f..0000000 --- a/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include -#include -#include -#include - -#include "qblittable_image.h" - -class QImageBlittableWindowSurface : public QRasterBlittableWindowSurface -{ -public: - QImageBlittableWindowSurface(QWidget *widget) - : QRasterBlittableWindowSurface(widget) - {} - - QBlittable *createBlittable(QImage *rasterSurface) - { - return new QImageBlittable(rasterSurface,false); - } - -}; - -class QBlittableGraphicsSystem : public QGraphicsSystem -{ -public: - ~QBlittableGraphicsSystem() { } - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const - { - if (type == QPixmapData::PixmapType) - return new QBlittablePixmapData(type); - else - return new QRasterPixmapData(type); - } - - QWindowSurface *createWindowSurface(QWidget *widget) const - { - return new QImageBlittableWindowSurface(widget); - } - - QBlittable *createBlittable(const QSize &size) const - { - QImage *image = new QImage(size, QImage::Format_ARGB32_Premultiplied); - return new QImageBlittable(image,true); - } - - QList screens() - { return m_screens; } - - QList m_screens; -}; - - diff --git a/src/plugins/platforms/directfb/qdirectfbblitter.h b/src/plugins/platforms/directfb/qdirectfbblitter.h index 85a303a..2a39912 100644 --- a/src/plugins/platforms/directfb/qdirectfbblitter.h +++ b/src/plugins/platforms/directfb/qdirectfbblitter.h @@ -26,4 +26,10 @@ protected: friend class QDirectFbConvenience; }; +class QDirectFbBlitterPixmapData : public QBlittablePixmapData +{ +public: + QBlittable *createBlittable(const QSize &size) const { return new QDirectFbBlitter(size); } +}; + #endif // QDIRECTFBBLITTER_H diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp index c47fc8d..b19a1d9 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp +++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp @@ -118,7 +118,7 @@ QPixmapData *QDirectFbIntegration::createPixmapData(QPixmapData::PixelType type) if (type == QPixmapData::BitmapType) return new QRasterPixmapData(type); else - return new QBlittablePixmapData(type); + return new QDirectFbBlitterPixmapData; } QPlatformWindow *QDirectFbIntegration::createPlatformWindow(QWidget *widget, WId winId) const diff --git a/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp b/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp index 4ca9a72..271d061 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp @@ -63,7 +63,7 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window, WId wId) dfbWindow->GetSurface(dfbWindow,&m_dfbSurface); //WRONGSIZE QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect().size(), m_dfbSurface); - m_pmdata = new QBlittablePixmapData(QPixmapData::PixmapType); + m_pmdata = new QDirectFbBlitterPixmapData; m_pmdata->setBlittable(blitter); m_pixmap = new QPixmap(m_pmdata); } -- cgit v0.12 From 733ea3622dc6feb06979bade95318664a94a6e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 22 Jul 2010 12:03:52 +0200 Subject: Fix Resize bug introduced by bc786ded04aa316f99cf9ac4cf8b714ee46575b5 --- src/gui/kernel/qapplication_qpa.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index 42907ae..a433ccd 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -828,12 +828,14 @@ void QApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Leave void QApplicationPrivate::processMoveEvent(QWindowSystemInterfacePrivate::MoveEvent *moveEvent) { - QMoveEvent e(moveEvent->moved.data()->geometry().topLeft(), moveEvent->newPos); - QApplication::sendSpontaneousEvent(moveEvent->moved.data(), &e); + moveEvent->moved.data()->data->crect.setTopLeft(moveEvent->newPos); + QMoveEvent e(moveEvent->moved.data()->geometry().topLeft(), moveEvent->newPos); + QApplication::sendSpontaneousEvent(moveEvent->moved.data(), &e); } void QApplicationPrivate::processResizeEvent(QWindowSystemInterfacePrivate::ResizeEvent *e) { + e->sizeChanged.data()->data->crect.setSize(e->newSize); QResizeEvent resizeEvent(e->sizeChanged.data()->data->crect.size(), e->newSize); QApplication::sendSpontaneousEvent(e->sizeChanged.data(), &resizeEvent); e->sizeChanged.data()->update(); -- cgit v0.12 From ec0ce7be116f0c4f854ef1efbb90d22f7c76aa4d Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 22 Jul 2010 14:53:02 +0200 Subject: Don't crash if widget is deleted before event is processed --- src/gui/kernel/qapplication_qpa.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index a433ccd..d289dee 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -828,6 +828,10 @@ void QApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Leave void QApplicationPrivate::processMoveEvent(QWindowSystemInterfacePrivate::MoveEvent *moveEvent) { + if (moveEvent->moved.isNull()) { + //qDebug() << "QApplicationPrivate::processMoveEvent NULL"; + return; + } moveEvent->moved.data()->data->crect.setTopLeft(moveEvent->newPos); QMoveEvent e(moveEvent->moved.data()->geometry().topLeft(), moveEvent->newPos); QApplication::sendSpontaneousEvent(moveEvent->moved.data(), &e); @@ -835,6 +839,10 @@ void QApplicationPrivate::processMoveEvent(QWindowSystemInterfacePrivate::MoveEv void QApplicationPrivate::processResizeEvent(QWindowSystemInterfacePrivate::ResizeEvent *e) { + if (e->sizeChanged.isNull()) { + //qDebug() << "QApplicationPrivate::processResizeEvent NULL"; + return; + } e->sizeChanged.data()->data->crect.setSize(e->newSize); QResizeEvent resizeEvent(e->sizeChanged.data()->data->crect.size(), e->newSize); QApplication::sendSpontaneousEvent(e->sizeChanged.data(), &resizeEvent); @@ -843,6 +851,10 @@ void QApplicationPrivate::processResizeEvent(QWindowSystemInterfacePrivate::Resi void QApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e) { + if (e->topLevel.isNull()) { + //qDebug() << "QApplicationPrivate::processCloseEvent NULL"; + return; + } e->topLevel.data()->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent); } -- cgit v0.12 From d15e6a32aeced893a5b5b790f3235cc7b3e0b9af Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 22 Jul 2010 14:53:53 +0200 Subject: Implement reparenting a created toplevel window --- src/gui/kernel/qwidget_qpa.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index 4229a05..ac868eb 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -60,7 +60,7 @@ void setParentForChildrenOfWidget(QPlatformWindow *window, const QWidget *widget for (int i = 0; i < children.size(); i++) { if (children.at(i)->isWidgetType()) { const QWidget *childWidget = qobject_cast(children.at(i)); - if (childWidget) { // should not be nessesary + if (childWidget) { // should not be necessary if (childWidget->platformWindow()) { childWidget->platformWindow()->setParent(window); } else { @@ -179,6 +179,12 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) } bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); + + // Reparenting toplevel to child + if (!(f&Qt::Window) && (oldFlags&Qt::Window)) { + //qDebug() << "setParent_sys() change from toplevel"; + q->destroy(); + } data.window_flags = f; q->setAttribute(Qt::WA_WState_Created, false); @@ -190,12 +196,11 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) if (QPlatformWindow *window = q->platformWindow()) data.window_flags = window->setWindowFlags(data.window_flags); } - // XXX Reparenting child to toplevel or vice versa ### + + // Reparenting child to toplevel if ((f&Qt::Window) && !(oldFlags&Qt::Window)) { //qDebug() << "setParent_sys() change to toplevel"; - q->create(); //### this cannot be right - } else if ((f&Qt::Window) && !(oldFlags&Qt::Window)) { - qDebug() << "######## setParent_sys() change from toplevel not implemented ########"; + q->create(); //### too early: this ought to happen at show() time } -- cgit v0.12 From be08fbc13f7370b6cc0c34660b4d1c16e4fdd3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 23 Jul 2010 10:24:06 +0200 Subject: Handle behavior change in resize and move events in Lighthouse Dont post the resize event and move event seperatly on the windowsystemintegration event queue, but as one event which will be processed in one go. --- src/gui/kernel/qapplication_p.h | 3 +- src/gui/kernel/qapplication_qpa.cpp | 47 ++++++++++++++------------- src/gui/kernel/qwidget_qpa.cpp | 1 + src/gui/kernel/qwindowsysteminterface_qpa.cpp | 24 ++------------ src/gui/kernel/qwindowsysteminterface_qpa_p.h | 22 ++++--------- 5 files changed, 35 insertions(+), 62 deletions(-) diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index de97f62..933e0ab 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -500,8 +500,7 @@ public: static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e); - static void processMoveEvent(QWindowSystemInterfacePrivate::MoveEvent *e); - static void processResizeEvent(QWindowSystemInterfacePrivate::ResizeEvent *e); + static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e); static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e); static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e); diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index d289dee..26ae82d 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -102,11 +102,8 @@ void QApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate case QWindowSystemInterfacePrivate::Touch: QApplicationPrivate::processTouchEvent(static_cast(e)); break; - case QWindowSystemInterfacePrivate::Move: - QApplicationPrivate::processMoveEvent(static_cast(e)); - break; - case QWindowSystemInterfacePrivate::Resize: - QApplicationPrivate::processResizeEvent(static_cast(e)); + case QWindowSystemInterfacePrivate::GeometryChange: + QApplicationPrivate::processGeometryChangeEvent(static_cast(e)); break; case QWindowSystemInterfacePrivate::Enter: QApplicationPrivate::processEnterEvent(static_cast(e)); @@ -826,27 +823,33 @@ void QApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Leave } -void QApplicationPrivate::processMoveEvent(QWindowSystemInterfacePrivate::MoveEvent *moveEvent) + +void QApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e) { - if (moveEvent->moved.isNull()) { - //qDebug() << "QApplicationPrivate::processMoveEvent NULL"; - return; + if (e->tlw.isNull()) + return; + QWidget *tlw = e->tlw.data(); + if (!tlw->isWindow()) + return; //geo of native child widgets is controlled by lighthouse + //so we already have sent the events; besides this new rect + //is not mapped to parent + + QRect newRect = e->newGeometry; + QRect cr(tlw->geometry()); + bool isResize = cr.size() != newRect.size(); + bool isMove = cr.topLeft() != newRect.topLeft(); + tlw->data->crect = newRect; + if (isResize) { + QResizeEvent e(tlw->data->crect.size(), cr.size()); + QApplication::sendSpontaneousEvent(tlw, &e); + tlw->update(); } - moveEvent->moved.data()->data->crect.setTopLeft(moveEvent->newPos); - QMoveEvent e(moveEvent->moved.data()->geometry().topLeft(), moveEvent->newPos); - QApplication::sendSpontaneousEvent(moveEvent->moved.data(), &e); -} -void QApplicationPrivate::processResizeEvent(QWindowSystemInterfacePrivate::ResizeEvent *e) -{ - if (e->sizeChanged.isNull()) { - //qDebug() << "QApplicationPrivate::processResizeEvent NULL"; - return; + if (isMove) { + //### frame geometry + QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft()); + QApplication::sendSpontaneousEvent(tlw, &e); } - e->sizeChanged.data()->data->crect.setSize(e->newSize); - QResizeEvent resizeEvent(e->sizeChanged.data()->data->crect.size(), e->newSize); - QApplication::sendSpontaneousEvent(e->sizeChanged.data(), &resizeEvent); - e->sizeChanged.data()->update(); } void QApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e) diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index ac868eb..1b7d9d2 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -128,6 +128,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) if (windowType() != Qt::Desktop) { if (destroyWindow && isWindow()) { +//### jl: delete all child windows... QTLWExtra *topData = d->maybeTopData(); if (topData) { delete topData->platformWindow; diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index dd78e8e..c49bd36 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -75,28 +75,8 @@ void QWindowSystemInterface::handleLeaveEvent(QWidget *tlw) void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect) { - if (!tlw) - return; - if (!tlw->isWindow()) - return; //geo of native child widgets is controlled by lighthouse - //so we already have sent the events; besides this new rect - //is not mapped to parent - - QRect cr(tlw->geometry()); - - bool isResize = cr.size() != newRect.size(); - bool isMove = cr.topLeft() != newRect.topLeft(); - if (isResize) { - QWindowSystemInterfacePrivate::ResizeEvent *resizeEvent = - new QWindowSystemInterfacePrivate::ResizeEvent(tlw,newRect.size()); - QWindowSystemInterfacePrivate::queueWindowSystemEvent(resizeEvent); - } - - if (isMove) { - QWindowSystemInterfacePrivate::MoveEvent *moveEvent = - new QWindowSystemInterfacePrivate::MoveEvent(tlw,newRect.topLeft()); - QWindowSystemInterfacePrivate::queueWindowSystemEvent(moveEvent); - } + QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h index 90d1702..5f3ac5d 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h @@ -53,8 +53,7 @@ public: enum EventType { Close, - Resize, - Move, + GeometryChange, Enter, Leave, Mouse, @@ -80,22 +79,13 @@ public: QWeakPointer topLevel; }; - class ResizeEvent : public WindowSystemEvent { + class GeometryChangeEvent : public WindowSystemEvent { public: - ResizeEvent(QWidget *sizeChanged, const QSize &newSize) - : WindowSystemEvent(Resize), sizeChanged(sizeChanged), newSize(newSize) + GeometryChangeEvent(QWidget *tlw, const QRect &newGeometry) + : WindowSystemEvent(GeometryChange), tlw(tlw), newGeometry(newGeometry) { } - QWeakPointer sizeChanged; - QSize newSize; - }; - - class MoveEvent : public WindowSystemEvent { - public: - MoveEvent(QWidget *moved, const QPoint &newPos) - : WindowSystemEvent(Move), moved(moved), newPos(newPos) - { } - QWeakPointer moved; - QPoint newPos; + QWeakPointer tlw; + QRect newGeometry; }; class EnterEvent : public WindowSystemEvent { -- cgit v0.12 From 699d74a9fae0b2d03e5c74bfb9590f6f0809ef4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 23 Jul 2010 09:46:23 +0200 Subject: Make it possible to have shared contexts to Lighthouse This adds a getter to QPlatformGLContext for the "default shared context". The setter is protected as it is the plugins responsibillity to create it or not. QPlatformWindowFormat has also gotten a pointer to a QPlatformGLContext for a non default shared context. Only implemented shared contexts in testlite for now. --- src/gui/kernel/kernel.pri | 3 +- src/gui/kernel/qapplication_qpa.cpp | 4 +- src/gui/kernel/qplatformglcontext_qpa.cpp | 54 +++++++++ src/gui/kernel/qplatformglcontext_qpa.h | 5 + src/gui/kernel/qplatformintegration_qpa.h | 6 +- src/gui/kernel/qplatformwindowformat_qpa.cpp | 37 ++++-- src/gui/kernel/qplatformwindowformat_qpa.h | 17 ++- src/gui/kernel/qwidget.cpp | 2 + src/gui/kernel/qwidget_qpa.cpp | 2 +- src/opengl/qgl_qpa.cpp | 3 + src/plugins/platforms/testlite/qglxintegration.cpp | 133 +++++++++++++++------ src/plugins/platforms/testlite/qglxintegration.h | 18 ++- src/plugins/platforms/testlite/qtestlitewindow.cpp | 43 +++---- 13 files changed, 247 insertions(+), 80 deletions(-) create mode 100644 src/gui/kernel/qplatformglcontext_qpa.cpp diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 43b1ab8..9941b1b 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -241,7 +241,8 @@ qpa { kernel/qplatformintegrationplugin_qpa.cpp \ kernel/qplatformwindow_qpa.cpp \ kernel/qplatformwindowformat_qpa.cpp \ - kernel/qplatformeventloopintegration_qpa.cpp + kernel/qplatformeventloopintegration_qpa.cpp \ + kernel/qplatformglcontext_qpa.cpp contains(QT_CONFIG, glib) { SOURCES += \ diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index 26ae82d..e5b5396 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -510,7 +510,7 @@ void qt_init(QApplicationPrivate *priv, int type) } QList pluginList; - QString platformName = qgetenv("QT_QPA_PLATFORM"); + QString platformName = QLatin1String(qgetenv("QT_QPA_PLATFORM")); // Get command line params @@ -526,7 +526,7 @@ void qt_init(QApplicationPrivate *priv, int type) appFont = argv[i]; } else if (arg == "-platform") { if (++i < argc) - platformName = argv[i]; + platformName = QLatin1String(argv[i]); } else if (arg == "-plugin") { if (++i < argc) pluginList << argv[i]; diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp new file mode 100644 index 0000000..a2ffbf3 --- /dev/null +++ b/src/gui/kernel/qplatformglcontext_qpa.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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 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 "qplatformglcontext_qpa.h" + +static QPlatformGLContext *staticSharedContext = 0; + +void QPlatformGLContext::setDefaultSharedContext(QPlatformGLContext *sharedContext) +{ + staticSharedContext = sharedContext; +} + +QPlatformGLContext *QPlatformGLContext::defaultSharedContext() +{ + return staticSharedContext; +} diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h index dcfd54c..9f3bfb3 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.h +++ b/src/gui/kernel/qplatformglcontext_qpa.h @@ -58,6 +58,11 @@ public: virtual void swapBuffers() = 0; virtual void* getProcAddress(const QString& procName) = 0; + static QPlatformGLContext *defaultSharedContext(); + +protected: + static void setDefaultSharedContext(QPlatformGLContext *sharedContext); + }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h index f6f10a8..9f7367e 100644 --- a/src/gui/kernel/qplatformintegration_qpa.h +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -73,10 +73,12 @@ public: virtual bool isVirtualDesktop() { return false; } virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; -// Experimental +// Experimental in mainthread eventloop integration +// This should only be used if it is only possible to do window system event processing in +// the gui thread. All of the functions in QWindowSystemInterface are thread safe. virtual QPlatformEventLoopIntegration *createEventLoopIntegration() const; -// should it be hasGLContext? +//jl:XXX should it be hasGLContext and do we need it at all? virtual bool hasOpenGL() const; diff --git a/src/gui/kernel/qplatformwindowformat_qpa.cpp b/src/gui/kernel/qplatformwindowformat_qpa.cpp index bc234ab..9d86948 100644 --- a/src/gui/kernel/qplatformwindowformat_qpa.cpp +++ b/src/gui/kernel/qplatformwindowformat_qpa.cpp @@ -50,7 +50,8 @@ public: : ref(1) , opts(QPlatformWindowFormat::DoubleBuffer | QPlatformWindowFormat::DepthBuffer | QPlatformWindowFormat::Rgba | QPlatformWindowFormat::DirectRendering - | QPlatformWindowFormat::StencilBuffer | QPlatformWindowFormat::DeprecatedFunctions) + | QPlatformWindowFormat::StencilBuffer | QPlatformWindowFormat::DeprecatedFunctions + | QPlatformWindowFormat::UseDefaultSharedContext) , depthSize(-1) , accumSize(-1) , stencilSize(-1) @@ -60,9 +61,8 @@ public: , alphaSize(-1) , numSamples(-1) , swapInterval(-1) - , majorVersion(1) - , minorVersion(0) , windowApi(QPlatformWindowFormat::Raster) + , sharedContext(0) { } @@ -78,9 +78,8 @@ public: alphaSize(other->alphaSize), numSamples(other->numSamples), swapInterval(other->swapInterval), - majorVersion(other->majorVersion), - minorVersion(other->minorVersion), - windowApi(other->windowApi) + windowApi(other->windowApi), + sharedContext(other->sharedContext) { } QAtomicInt ref; @@ -94,9 +93,8 @@ public: int alphaSize; int numSamples; int swapInterval; - int majorVersion; - int minorVersion; QPlatformWindowFormat::WindowApi windowApi; + QPlatformGLContext *sharedContext; }; /*! @@ -519,6 +517,16 @@ void QPlatformWindowFormat::setSampleBuffers(bool enable) setOption(enable ? QPlatformWindowFormat::SampleBuffers : QPlatformWindowFormat::NoSampleBuffers); } +void QPlatformWindowFormat::setUseDefaultSharedContext(bool enable) +{ + if (enable) { + setOption(QPlatformWindowFormat::UseDefaultSharedContext); + d->sharedContext = 0; + } else { + setOption(QPlatformWindowFormat::NoDefaultSharedContext); + } +} + /*! Returns the number of samples per pixel when multisampling is enabled. By default, the highest number of samples that is @@ -595,6 +603,17 @@ QPlatformWindowFormat::WindowApi QPlatformWindowFormat::windowApi() const return d->windowApi; } +void QPlatformWindowFormat::setSharedContext(QPlatformGLContext *context) +{ + setUseDefaultSharedContext(false); + d->sharedContext = context; +} + +QPlatformGLContext *QPlatformWindowFormat::sharedGLContext() const +{ + return d->sharedContext; +} + ///*! // \fn bool QGLFormat::hasOverlay() const @@ -952,8 +971,6 @@ bool operator==(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b) && a.d->blueSize == b.d->blueSize && a.d->numSamples == b.d->numSamples && a.d->swapInterval == b.d->swapInterval - && a.d->majorVersion == b.d->majorVersion - && a.d->minorVersion == b.d->minorVersion && a.d->windowApi == b.d->windowApi); } diff --git a/src/gui/kernel/qplatformwindowformat_qpa.h b/src/gui/kernel/qplatformwindowformat_qpa.h index 3c5f907..37e628d 100644 --- a/src/gui/kernel/qplatformwindowformat_qpa.h +++ b/src/gui/kernel/qplatformwindowformat_qpa.h @@ -64,6 +64,7 @@ public: HasOverlay = 0x0100, SampleBuffers = 0x0200, DeprecatedFunctions = 0x0400, + UseDefaultSharedContext = 0x0800, SingleBuffer = DoubleBuffer << 16, NoDepthBuffer = DepthBuffer << 16, ColorIndex = Rgba << 16, @@ -74,7 +75,9 @@ public: IndirectRendering = DirectRendering << 16, NoOverlay = HasOverlay << 16, NoSampleBuffers = SampleBuffers << 16, - NoDeprecatedFunctions = DeprecatedFunctions << 16 + NoDeprecatedFunctions = DeprecatedFunctions << 16, + NoDefaultSharedContext = UseDefaultSharedContext << 16 + }; Q_DECLARE_FLAGS(FormatOptions, FormatOption) @@ -123,6 +126,9 @@ public: void setWindowApi(QPlatformWindowFormat::WindowApi api); WindowApi windowApi() const; + void setSharedContext(QPlatformGLContext *context); + QPlatformGLContext *sharedGLContext() const; + bool doubleBuffer() const; void setDoubleBuffer(bool enable); bool depth() const; @@ -139,6 +145,8 @@ public: void setStereo(bool enable); bool directRendering() const; void setDirectRendering(bool enable); + bool useDefaultSharedContext() const; + void setUseDefaultSharedContext(bool enable); // bool hasOverlay() const; // void setOverlay(bool enable); @@ -148,9 +156,6 @@ public: static QPlatformWindowFormat defaultFormat(); static void setDefaultFormat(const QPlatformWindowFormat& f); -// static QPlatformWindowFormat defaultOverlayFormat(); -// static void setDefaultOverlayFormat(const QPlatformWindowFormat& f); - private: QPlatformWindowFormatPrivate *d; @@ -215,6 +220,10 @@ inline bool QPlatformWindowFormat::sampleBuffers() const return testOption(QPlatformWindowFormat::SampleBuffers); } +inline bool QPlatformWindowFormat::useDefaultSharedContext() const +{ + return testOption(QPlatformWindowFormat::UseDefaultSharedContext); +} QT_END_NAMESPACE diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 958c476..c236c60 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2410,7 +2410,9 @@ WId QWidget::winId() const qDebug() << "QWidget::winId: creating native window for" << this; #endif QWidget *that = const_cast(this); +#ifndef Q_WS_QPA that->setAttribute(Qt::WA_NativeWindow); +#endif that->d_func()->createWinId(); return that->data->winid; } diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index 1b7d9d2..104c529 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -182,7 +182,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); // Reparenting toplevel to child - if (!(f&Qt::Window) && (oldFlags&Qt::Window)) { + if (!(f&Qt::Window) && (oldFlags&Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) { //qDebug() << "setParent_sys() change from toplevel"; q->destroy(); } diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index aa124fe..0fc885c 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -66,6 +66,9 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) }else { QWidget *widget = static_cast(d->paintDevice); if (!widget->platformWindow()){ + QPlatformWindowFormat format = widget->platformWindowFormat(); + format.setWindowApi(QPlatformWindowFormat::OpenGL); + widget->setPlatformWindowFormat(format); widget->winId();//make window } d->platformContext = widget->platformWindow()->glContext(); diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index ba89dbd..4d807b0 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -57,8 +57,12 @@ QT_BEGIN_NAMESPACE -GLXFBConfig qt_glx_integration_choose_config(MyDisplay* xd, QGLFormat& format, int drawableType) +QMutex QGLXGLContext::m_defaultSharedContextMutex(QMutex::Recursive); + +QVector QGLXGLContext::buildSpec(const QPlatformWindowFormat &format) { + QVector spec(48); + int i = 0; int depthSize = 0; int stencilSize = 0; int sampleSize = 0; @@ -70,33 +74,30 @@ GLXFBConfig qt_glx_integration_choose_config(MyDisplay* xd, QGLFormat& format, i if (format.sampleBuffers()) sampleSize = (format.samples() == -1) ? 1 : format.samples(); - int configAttribs[] = { - GLX_DRAWABLE_TYPE, drawableType, - GLX_LEVEL, format.plane(), - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_DOUBLEBUFFER, format.doubleBuffer() ? True : False, - GLX_STEREO, format.stereo() ? True : False, - - GLX_DEPTH_SIZE, depthSize, - GLX_STENCIL_SIZE, stencilSize, - GLX_SAMPLE_BUFFERS_ARB, sampleSize, - - GLX_RED_SIZE, (format.redBufferSize() == -1) ? 1 : format.redBufferSize(), - GLX_GREEN_SIZE, (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize(), - GLX_BLUE_SIZE, (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize(), - GLX_ALPHA_SIZE, (format.alphaBufferSize() == -1) ? 0 : format.alphaBufferSize(), - - GLX_ACCUM_RED_SIZE, (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(), - GLX_ACCUM_GREEN_SIZE, (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(), - GLX_ACCUM_BLUE_SIZE, (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(), - GLX_ACCUM_ALPHA_SIZE, (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(), - XNone - }; + spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_WINDOW_BIT; + spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT; + spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False; + spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False; - GLXFBConfig *configs; - int configCount = 0; - configs = glXChooseFBConfig(xd->display, xd->screen, configAttribs, &configCount); + spec[i++] = GLX_DEPTH_SIZE; spec[i++] = depthSize; + spec[i++] = GLX_STENCIL_SIZE; spec[i++] = stencilSize; + spec[i++] = GLX_SAMPLE_BUFFERS_ARB; spec[i++] = sampleSize; + 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(); + spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 0 : format.alphaBufferSize(); + + spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(); + spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(); + spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(); + spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(); + spec[i++] = XNone; + return spec; +} + +GLXFBConfig QGLXGLContext::findConfig(const GLXFBConfig *configs, int configCount, const QPlatformWindowFormat &format, const MyDisplay *xd) +{ if (!configs) return 0; @@ -121,31 +122,60 @@ GLXFBConfig qt_glx_integration_choose_config(MyDisplay* xd, QGLFormat& format, i } else break; // Just choose the first in the list if there's no alpha requested } - - // TODO: Populate the QGLFormat with the values of the GLXFBConfig - - XFree(configs); return chosenConfig; } -QGLXGLContext::QGLXGLContext(WId winId, MyDisplay *xd, QGLFormat& format, QPlatformGLContext* shareContext) +QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindowFormat &format) : QPlatformGLContext() , m_xd(xd) - , m_drawable((Drawable)winId) - , m_config(0) + , m_drawable((Drawable)window) , m_context(0) { + if (!QPlatformGLContext::defaultSharedContext()) { + if (m_defaultSharedContextMutex.tryLock()){ + createDefaultSharedContex(xd); + m_defaultSharedContextMutex.unlock(); + } else { + m_defaultSharedContextMutex.lock(); //wait to the the shared context is created + m_defaultSharedContextMutex.unlock(); + } + } + + QPlatformGLContext *sharePlatformContext; + if (format.useDefaultSharedContext()) { + sharePlatformContext = QPlatformGLContext::defaultSharedContext(); + } else { + sharePlatformContext = format.sharedGLContext(); + } GLXContext shareGlxContext = 0; - if (shareContext) - shareGlxContext = static_cast(shareContext)->glxContext(); + if (sharePlatformContext) + shareGlxContext = static_cast(sharePlatformContext)->glxContext(); - m_config = qt_glx_integration_choose_config(m_xd, format, GLX_WINDOW_BIT); + QVector spec = buildSpec(format); + int confcount = 0; + GLXFBConfig *configs; + configs = glXChooseFBConfig(xd->display,xd->screen,spec.constData(),&confcount); + if (confcount) + { + GLXFBConfig config = findConfig(configs,confcount,format,xd); + m_context = glXCreateNewContext(xd->display,config,GLX_RGBA_TYPE,shareGlxContext,TRUE); + XFree(configs); + } else { + qFatal("Warning no context created"); + } - m_context = glXCreateNewContext(m_xd->display, m_config, GLX_RGBA_TYPE, shareGlxContext, True); #ifdef MYX11_DEBUG qDebug() << "QGLXGLContext::create context" << m_context; #endif +// TODO: Populate the QGLFormat with the values of the GLXFBConfig + +} + +QGLXGLContext::QGLXGLContext(MyDisplay *display, Drawable drawable, GLXContext context) + : QPlatformGLContext(), m_xd(display), m_drawable(drawable), m_context(context) +{ + } QGLXGLContext::~QGLXGLContext() @@ -156,6 +186,35 @@ QGLXGLContext::~QGLXGLContext() } } +void QGLXGLContext::createDefaultSharedContex(MyDisplay *xd) +{ + int x = 0; + int y = 0; + int w = 3; + int h = 3; + + Window sharedWindow = XCreateSimpleWindow(xd->display, xd->rootWindow(), + x, y, w, h, 0 /*border_width*/, + xd->blackPixel(), xd->whitePixel()); + GLXContext context; + QPlatformWindowFormat format; + QVector spec = buildSpec(format); + int confcount = 0; + GLXFBConfig *configs; + configs = glXChooseFBConfig(xd->display,xd->screen,spec.constData(),&confcount); + if (confcount) + { + GLXFBConfig config = findConfig(configs,confcount,format,xd); + context = glXCreateNewContext(xd->display,config,GLX_RGBA_TYPE,0,TRUE); + XFree(configs); + QPlatformGLContext *sharedContext = new QGLXGLContext(xd,sharedWindow,context); + QPlatformGLContext::setDefaultSharedContext(sharedContext); + } else { + qFatal("Warning no shared context created"); + } + +} + void QGLXGLContext::makeCurrent() { #ifdef MYX11_DEBUG diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h index 6d9a216..decbe36 100644 --- a/src/plugins/platforms/testlite/qglxintegration.h +++ b/src/plugins/platforms/testlite/qglxintegration.h @@ -42,7 +42,13 @@ #ifndef Q_GLX_CONTEXT_H #define Q_GLX_CONTEXT_H +#include "qtestlitewindow.h" + #include +#include + +#include + #include QT_BEGIN_NAMESPACE @@ -52,7 +58,7 @@ class MyDisplay; class QGLXGLContext : public QPlatformGLContext { public: - QGLXGLContext(WId winId, MyDisplay *xd, QGLFormat& format, QPlatformGLContext* shareContext); + QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindowFormat &format); ~QGLXGLContext(); virtual void makeCurrent(); @@ -61,11 +67,19 @@ public: virtual void* getProcAddress(const QString& procName); GLXContext glxContext() {return m_context;} + + private: + static QVector buildSpec(const QPlatformWindowFormat &format); + static GLXFBConfig findConfig(const GLXFBConfig *configs,int configCount, const QPlatformWindowFormat &format, const MyDisplay *xd); + MyDisplay *m_xd; Drawable m_drawable; - GLXFBConfig m_config; GLXContext m_context; + + QGLXGLContext (MyDisplay *display, Drawable drawable, GLXContext context); + static QMutex m_defaultSharedContextMutex; + static void createDefaultSharedContex(MyDisplay *xd); }; diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index 0f6c921..f774458 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -84,8 +84,6 @@ static bool seen_badwindow; static Atom wmProtocolsAtom; static Atom wmDeleteWindowAtom; - - class MyX11CursorNode { public: @@ -155,14 +153,26 @@ QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration xd = platformIntegration->xd; xd->windowList.append(this); { - int x = 0; - int y = 0; - int w = 300; - int h = 300; //### - - x_window = XCreateSimpleWindow(xd->display, xd->rootWindow(), - x, y, w, h, 0 /*border_width*/, - xd->blackPixel(), xd->whitePixel()); + int x = window->x(); + int y = window->y(); + int w = window->width(); + int h = window->height(); + +// int n, i; +// if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL) { +// x_visualInfo = QGLXGLContext::findVisual(window->platformWindowFormat(),xd); + +// XSetWindowAttributes a; +// a.background_pixel = xd->whitePixel(); +// a.border_pixel = xd->blackPixel(); +// x_window = XCreateWindow(xd->display, xd->rootWindow(),x, y, w, h, +// 0, visualInfo()->depth, InputOutput, visualInfo()->visual, +// CWBackPixel|CWBorderPixel, &a); +// } else { + x_window = XCreateSimpleWindow(xd->display, xd->rootWindow(), + x, y, w, h, 0 /*border_width*/, + xd->blackPixel(), xd->whitePixel()); +// } #ifdef MYX11_DEBUG qDebug() << "QTestLiteWindow::QTestLiteWindow creating" << hex << x_window << window; @@ -187,16 +197,7 @@ QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration wmProtocolsAtom, XA_ATOM, 32, PropModeAppend, (unsigned char *) &wmDeleteWindowAtom, 1); - - - setWindowTitle(QLatin1String("Qt Lighthouse")); - currentCursor = -1; - - setWindowFlags(window->windowFlags()); //##### This should not be the plugin's responsibility - - - //xw->windowTL = this; } @@ -209,6 +210,7 @@ QTestLiteWindow::~QTestLiteWindow() XDestroyWindow(xd->display, x_window); xd->windowList.removeAll(this); + delete mGLContext; } @@ -1019,8 +1021,7 @@ QPlatformGLContext *QTestLiteWindow::glContext() QPlatformGLContext *QTestLiteWindow::createGLContext() { - QGLFormat format; - QPlatformGLContext *context = new QGLXGLContext(x_window, xd, format, 0); + QPlatformGLContext *context = new QGLXGLContext(x_window, xd, widget()->platformWindowFormat()); return context; } -- cgit v0.12 From 4fb48f92e7553e8854c943e6117875c2e2b393f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 26 Jul 2010 08:09:04 +0200 Subject: Destroy subwindows in lighthouse --- src/gui/kernel/qwidget_qpa.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index 104c529..3584f87 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -116,8 +116,6 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO void QWidget::destroy(bool destroyWindow, bool destroySubWindows) { Q_D(QWidget); - //### jl: subwindows now enabled - Q_UNUSED(destroySubWindows); if ((windowType() == Qt::Popup)) qApp->d_func()->closePopup(this); @@ -127,8 +125,18 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) QApplication::setActiveWindow(0); if (windowType() != Qt::Desktop) { - if (destroyWindow && isWindow()) { -//### jl: delete all child windows... + if (destroySubWindows) { + QObjectList childList(children()); + for (int i = 0; i < childList.size(); i++) { + QWidget *widget = qobject_cast(childList.at(i)); + if (widget && widget->testAttribute(Qt::WA_NativeWindow)) { + if (widget->platformWindow()) { + widget->destroy(); + } + } + } + } + if (destroyWindow) { QTLWExtra *topData = d->maybeTopData(); if (topData) { delete topData->platformWindow; -- cgit v0.12 From 11a16e38df8022b41aae0d41a67e8b5542801d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 26 Jul 2010 08:15:22 +0200 Subject: fix QGLContext::reset in lighthouse --- src/opengl/qgl_qpa.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 0fc885c..917842b 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -87,8 +87,10 @@ void QGLContext::reset() doneCurrent(); if (d->platformContext) { - //dont delete. This will be done by the platform - d->platformContext = 0; + if (d->paintDevice && d->paintDevice->devType() == QInternal::Widget) { + QWidget *widget = static_cast(d->paintDevice); + widget->destroy(); + } } d->crWin = false; -- cgit v0.12 From 925fc21fcfdb48093032921e76c9274512699a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 26 Jul 2010 08:18:18 +0200 Subject: Added QGLFormat to QPlatformWindowFormat conversion --- src/gui/kernel/qplatformwindowformat_qpa.cpp | 68 +++++++++++++-------------- src/opengl/qgl_qpa.cpp | 70 ++++++++++++++++++++++++++-- 2 files changed, 100 insertions(+), 38 deletions(-) diff --git a/src/gui/kernel/qplatformwindowformat_qpa.cpp b/src/gui/kernel/qplatformwindowformat_qpa.cpp index 9d86948..1112ba9 100644 --- a/src/gui/kernel/qplatformwindowformat_qpa.cpp +++ b/src/gui/kernel/qplatformwindowformat_qpa.cpp @@ -98,8 +98,8 @@ public: }; /*! - \class QGLFormat - \brief The QGLFormat class specifies the display format of an OpenGL + \class QPlatformWindowFormat + \brief The QPlatformWindowFormat class specifies the display format of an OpenGL rendering context. \ingroup painting-3D @@ -133,7 +133,7 @@ public: different platforms, and some format options may have higher precedence than others. - You create and tell a QGLFormat object what rendering options you + You create and tell a QPlatformWindowFormat object what rendering options you want from an OpenGL rendering context. OpenGL drivers or accelerated hardware may or may not support @@ -143,7 +143,7 @@ public: context with the nearest subset of features. There are different ways to define the display characteristics of - a rendering context. One is to create a QGLFormat and make it the + a rendering context. One is to create a QPlatformWindowFormat and make it the default for the entire application: \snippet doc/src/snippets/code/src_opengl_qgl.cpp 0 @@ -164,7 +164,7 @@ public: */ /*! - Constructs a QGLFormat object with the following default settings: + Constructs a QPlatformWindowFormat object with the following default settings: \list \i \link setDoubleBuffer() Double buffer:\endlink Enabled. \i \link setDepth() Depth buffer:\endlink Enabled. @@ -187,7 +187,7 @@ QPlatformWindowFormat::QPlatformWindowFormat() /*! - Creates a QGLFormat object that is a copy of the current + Creates a QPlatformWindowFormat object that is a copy of the current defaultFormat(). If \a options is not 0, the default format is modified by the @@ -257,7 +257,7 @@ QPlatformWindowFormat &QPlatformWindowFormat::operator=(const QPlatformWindowFor } /*! - Destroys the QGLFormat. + Destroys the QPlatformWindowFormat. */ QPlatformWindowFormat::~QPlatformWindowFormat() { @@ -266,7 +266,7 @@ QPlatformWindowFormat::~QPlatformWindowFormat() } /*! - \fn bool QGLFormat::doubleBuffer() const + \fn bool QPlatformWindowFormat::doubleBuffer() const Returns true if double buffering is enabled; otherwise returns false. Double buffering is enabled by default. @@ -297,7 +297,7 @@ void QPlatformWindowFormat::setDoubleBuffer(bool enable) /*! - \fn bool QGLFormat::depth() const + \fn bool QPlatformWindowFormat::depth() const Returns true if the depth buffer is enabled; otherwise returns false. The depth buffer is enabled by default. @@ -327,7 +327,7 @@ void QPlatformWindowFormat::setDepth(bool enable) /*! - \fn bool QGLFormat::rgba() const + \fn bool QPlatformWindowFormat::rgba() const Returns true if RGBA color mode is set. Returns false if color index mode is set. The default color mode is RGBA. @@ -358,7 +358,7 @@ void QPlatformWindowFormat::setRgba(bool enable) /*! - \fn bool QGLFormat::alpha() const + \fn bool QPlatformWindowFormat::alpha() const Returns true if the alpha buffer in the framebuffer is enabled; otherwise returns false. The alpha buffer is disabled by default. @@ -386,7 +386,7 @@ void QPlatformWindowFormat::setAlpha(bool enable) /*! - \fn bool QGLFormat::accum() const + \fn bool QPlatformWindowFormat::accum() const Returns true if the accumulation buffer is enabled; otherwise returns false. The accumulation buffer is disabled by default. @@ -413,7 +413,7 @@ void QPlatformWindowFormat::setAccum(bool enable) /*! - \fn bool QGLFormat::stencil() const + \fn bool QPlatformWindowFormat::stencil() const Returns true if the stencil buffer is enabled; otherwise returns false. The stencil buffer is enabled by default. @@ -440,7 +440,7 @@ void QPlatformWindowFormat::setStencil(bool enable) /*! - \fn bool QGLFormat::stereo() const + \fn bool QPlatformWindowFormat::stereo() const Returns true if stereo buffering is enabled; otherwise returns false. Stereo buffering is disabled by default. @@ -467,7 +467,7 @@ void QPlatformWindowFormat::setStereo(bool enable) /*! - \fn bool QGLFormat::directRendering() const + \fn bool QPlatformWindowFormat::directRendering() const Returns true if direct rendering is enabled; otherwise returns false. @@ -496,7 +496,7 @@ void QPlatformWindowFormat::setDirectRendering(bool enable) } /*! - \fn bool QGLFormat::sampleBuffers() const + \fn bool QPlatformWindowFormat::sampleBuffers() const Returns true if multisample buffer support is enabled; otherwise returns false. @@ -550,7 +550,7 @@ void QPlatformWindowFormat::setSamples(int numSamples) { detach(); if (numSamples < 0) { - qWarning("QGLFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples); + qWarning("QPlatformWindowFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples); return; } d->numSamples = numSamples; @@ -615,7 +615,7 @@ QPlatformGLContext *QPlatformWindowFormat::sharedGLContext() const } ///*! -// \fn bool QGLFormat::hasOverlay() const +// \fn bool QPlatformWindowFormat::hasOverlay() const // Returns true if overlay plane is enabled; otherwise returns false. @@ -680,7 +680,7 @@ void QPlatformWindowFormat::setDepthBufferSize(int size) { detach(); if (size < 0) { - qWarning("QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size); + qWarning("QPlatformWindowFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size); return; } d->depthSize = size; @@ -708,7 +708,7 @@ void QPlatformWindowFormat::setRedBufferSize(int size) { detach(); if (size < 0) { - qWarning("QGLFormat::setRedBufferSize: Cannot set negative red buffer size %d", size); + qWarning("QPlatformWindowFormat::setRedBufferSize: Cannot set negative red buffer size %d", size); return; } d->redSize = size; @@ -737,7 +737,7 @@ void QPlatformWindowFormat::setGreenBufferSize(int size) { detach(); if (size < 0) { - qWarning("QGLFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size); + qWarning("QPlatformWindowFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size); return; } d->greenSize = size; @@ -766,7 +766,7 @@ void QPlatformWindowFormat::setBlueBufferSize(int size) { detach(); if (size < 0) { - qWarning("QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size); + qWarning("QPlatformWindowFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size); return; } d->blueSize = size; @@ -794,7 +794,7 @@ void QPlatformWindowFormat::setAlphaBufferSize(int size) { detach(); if (size < 0) { - qWarning("QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size); + qWarning("QPlatformWindowFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size); return; } d->alphaSize = size; @@ -821,7 +821,7 @@ void QPlatformWindowFormat::setAccumBufferSize(int size) { detach(); if (size < 0) { - qWarning("QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size); + qWarning("QPlatformWindowFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size); return; } d->accumSize = size; @@ -847,7 +847,7 @@ void QPlatformWindowFormat::setStencilBufferSize(int size) { detach(); if (size < 0) { - qWarning("QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size); + qWarning("QPlatformWindowFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size); return; } d->stencilSize = size; @@ -865,13 +865,13 @@ int QPlatformWindowFormat::stencilBufferSize() const } /*! - Returns the default QGLFormat for the application. All QGLWidget + Returns the default QPlatformWindowFormat for the application. All QGLWidget objects that are created use this format unless another format is specified, e.g. when they are constructed. If no special default format has been set using setDefaultFormat(), the default format is the same as that created - with QGLFormat(). + with QPlatformWindowFormat(). \sa setDefaultFormat() */ @@ -882,7 +882,7 @@ QPlatformWindowFormat QPlatformWindowFormat::defaultFormat() } /*! - Sets a new default QGLFormat for the application to \a f. For + Sets a new default QPlatformWindowFormat for the application to \a f. For example, to set single buffering as the default instead of double buffering, your main() might contain code like this: \snippet doc/src/snippets/code/src_opengl_qgl.cpp 4 @@ -897,7 +897,7 @@ void QPlatformWindowFormat::setDefaultFormat(const QPlatformWindowFormat &f) /*! - Returns the default QGLFormat for overlay contexts. + Returns the default QPlatformWindowFormat for overlay contexts. The default overlay format is: \list @@ -923,7 +923,7 @@ void QPlatformWindowFormat::setDefaultFormat(const QPlatformWindowFormat &f) //} ///*! -// Sets a new default QGLFormat for overlay contexts to \a f. This +// Sets a new default QPlatformWindowFormat for overlay contexts to \a f. This // format is used whenever a QGLWidget is created with a format that // hasOverlay() enabled. @@ -953,10 +953,10 @@ void QPlatformWindowFormat::setDefaultFormat(const QPlatformWindowFormat &f) /*! - Returns true if all the options of the two QGLFormat objects + Returns true if all the options of the two QPlatformWindowFormat objects \a a and \a b are equal; otherwise returns false. - \relates QGLFormat + \relates QPlatformWindowFormat */ bool operator==(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b) @@ -976,10 +976,10 @@ bool operator==(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b) /*! - Returns false if all the options of the two QGLFormat objects + Returns false if all the options of the two QPlatformWindowFormat objects \a a and \a b are equal; otherwise returns true. - \relates QGLFormat + \relates QPlatformWindowFormat */ bool operator!=(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b) diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 917842b..8fa210b 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -52,6 +52,67 @@ QT_BEGIN_NAMESPACE +static QGLFormat qt_platformwindowformat_to_glformat(const QPlatformWindowFormat &format) +{ + QGLFormat retFormat; + retFormat.setAccum(format.accum()); + if (format.accumBufferSize() >= 0) + retFormat.setAccumBufferSize(format.accumBufferSize()); + retFormat.setAlpha(format.alpha()); + if (format.alphaBufferSize() >= 0) + retFormat.setAlphaBufferSize(format.alphaBufferSize()); + if (format.blueBufferSize() >= 0) + retFormat.setBlueBufferSize(format.blueBufferSize()); + retFormat.setDepth(format.depth()); + if (format.depthBufferSize() >= 0) + retFormat.setDepthBufferSize(format.depthBufferSize()); + retFormat.setDirectRendering(format.directRendering()); + retFormat.setDoubleBuffer(format.doubleBuffer()); + if (format.greenBufferSize() >= 0) + retFormat.setGreenBufferSize(format.greenBufferSize()); + if (format.redBufferSize() >= 0) + retFormat.setRedBufferSize(format.redBufferSize()); + retFormat.setRgba(format.rgba()); + retFormat.setSampleBuffers(format.sampleBuffers()); + retFormat.setSamples(format.sampleBuffers()); + retFormat.setStencil(format.stencil()); + if (format.stencilBufferSize() >= 0) + retFormat.setStencilBufferSize(format.stencilBufferSize()); + retFormat.setStereo(format.stereo()); + retFormat.setSwapInterval(format.swapInterval()); + return retFormat; +} + +static QPlatformWindowFormat qt_glformat_to_platformwindowformat(const QGLFormat &format) +{ + QPlatformWindowFormat retFormat; + retFormat.setAccum(format.accum()); + if (format.accumBufferSize() >= 0) + retFormat.setAccumBufferSize(format.accumBufferSize()); + retFormat.setAlpha(format.alpha()); + if (format.alphaBufferSize() >= 0) + retFormat.setAlphaBufferSize(format.alphaBufferSize()); + if (format.blueBufferSize() >= 0) + retFormat.setBlueBufferSize(format.blueBufferSize()); + retFormat.setDepth(format.depth()); + if (format.depthBufferSize() >= 0) + retFormat.setDepthBufferSize(format.depthBufferSize()); + retFormat.setDirectRendering(format.directRendering()); + retFormat.setDoubleBuffer(format.doubleBuffer()); + if (format.greenBufferSize() >= 0) + retFormat.setGreenBufferSize(format.greenBufferSize()); + if (format.redBufferSize() >= 0) + retFormat.setRedBufferSize(format.redBufferSize()); + retFormat.setRgba(format.rgba()); + retFormat.setSampleBuffers(format.sampleBuffers()); + retFormat.setSamples(format.sampleBuffers()); + retFormat.setStencil(format.stencil()); + if (format.stencilBufferSize() >= 0) + retFormat.setStencilBufferSize(format.stencilBufferSize()); + retFormat.setStereo(format.stereo()); + retFormat.setSwapInterval(format.swapInterval()); + return retFormat; +} bool QGLFormat::hasOpenGL() { @@ -61,14 +122,15 @@ bool QGLFormat::hasOpenGL() bool QGLContext::chooseContext(const QGLContext* shareContext) { Q_D(QGLContext); - if (!d->paintDevice && d->paintDevice->devType() != QInternal::Widget) { + if (!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) { d->valid = false; }else { QWidget *widget = static_cast(d->paintDevice); if (!widget->platformWindow()){ - QPlatformWindowFormat format = widget->platformWindowFormat(); - format.setWindowApi(QPlatformWindowFormat::OpenGL); - widget->setPlatformWindowFormat(format); + QGLFormat glformat = format(); + QPlatformWindowFormat winFormat = qt_glformat_to_platformwindowformat(glformat); + winFormat.setWindowApi(QPlatformWindowFormat::OpenGL); + widget->setPlatformWindowFormat(winFormat); widget->winId();//make window } d->platformContext = widget->platformWindow()->glContext(); -- cgit v0.12 From f3ae27721ad0e71923e8538370731f91acb53601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 26 Jul 2010 09:34:10 +0200 Subject: Renamed files in EGLFS platform plugin --- src/plugins/platforms/eglfs/eglfs.pro | 16 + src/plugins/platforms/eglfs/eglintegration.cpp | 469 ---------------------- src/plugins/platforms/eglfs/eglintegration.h | 70 ---- src/plugins/platforms/eglfs/eglintegration.pro | 14 - src/plugins/platforms/eglfs/main.cpp | 2 +- src/plugins/platforms/eglfs/qeglfsintegration.cpp | 469 ++++++++++++++++++++++ src/plugins/platforms/eglfs/qeglfsintegration.h | 70 ++++ 7 files changed, 556 insertions(+), 554 deletions(-) create mode 100644 src/plugins/platforms/eglfs/eglfs.pro delete mode 100644 src/plugins/platforms/eglfs/eglintegration.cpp delete mode 100644 src/plugins/platforms/eglfs/eglintegration.h delete mode 100644 src/plugins/platforms/eglfs/eglintegration.pro create mode 100644 src/plugins/platforms/eglfs/qeglfsintegration.cpp create mode 100644 src/plugins/platforms/eglfs/qeglfsintegration.h diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro new file mode 100644 index 0000000..2cc5997 --- /dev/null +++ b/src/plugins/platforms/eglfs/eglfs.pro @@ -0,0 +1,16 @@ +TARGET = qeglfs +TEMPLATE = lib +CONFIG += plugin + +QT += opengl + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms + +SOURCES = main.cpp \ + qeglfsintegration.cpp \ + ../eglconvenience/qeglconvenience.cpp +HEADERS = qeglfsintegration.h \ + ../eglconvenience/qeglconvenience.h + +target.path += $$[QT_INSTALL_PLUGINS]/platforms +INSTALLS += target diff --git a/src/plugins/platforms/eglfs/eglintegration.cpp b/src/plugins/platforms/eglfs/eglintegration.cpp deleted file mode 100644 index 9470c99..0000000 --- a/src/plugins/platforms/eglfs/eglintegration.cpp +++ /dev/null @@ -1,469 +0,0 @@ -/**************************************************************************** -** -** 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 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 "eglintegration.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "../eglconvenience/qeglconvenience.h" - -//#define QEGL_EXTRA_DEBUG -#ifdef QEGL_EXTRA_DEBUG -struct AttrInfo { EGLint attr; const char *name; }; -static struct AttrInfo attrs[] = { - {EGL_BUFFER_SIZE, "EGL_BUFFER_SIZE"}, - {EGL_ALPHA_SIZE, "EGL_ALPHA_SIZE"}, - {EGL_BLUE_SIZE, "EGL_BLUE_SIZE"}, - {EGL_GREEN_SIZE, "EGL_GREEN_SIZE"}, - {EGL_RED_SIZE, "EGL_RED_SIZE"}, - {EGL_DEPTH_SIZE, "EGL_DEPTH_SIZE"}, - {EGL_STENCIL_SIZE, "EGL_STENCIL_SIZE"}, - {EGL_CONFIG_CAVEAT, "EGL_CONFIG_CAVEAT"}, - {EGL_CONFIG_ID, "EGL_CONFIG_ID"}, - {EGL_LEVEL, "EGL_LEVEL"}, - {EGL_MAX_PBUFFER_HEIGHT, "EGL_MAX_PBUFFER_HEIGHT"}, - {EGL_MAX_PBUFFER_PIXELS, "EGL_MAX_PBUFFER_PIXELS"}, - {EGL_MAX_PBUFFER_WIDTH, "EGL_MAX_PBUFFER_WIDTH"}, - {EGL_NATIVE_RENDERABLE, "EGL_NATIVE_RENDERABLE"}, - {EGL_NATIVE_VISUAL_ID, "EGL_NATIVE_VISUAL_ID"}, - {EGL_NATIVE_VISUAL_TYPE, "EGL_NATIVE_VISUAL_TYPE"}, - {EGL_SAMPLES, "EGL_SAMPLES"}, - {EGL_SAMPLE_BUFFERS, "EGL_SAMPLE_BUFFERS"}, - {EGL_SURFACE_TYPE, "EGL_SURFACE_TYPE"}, - {EGL_TRANSPARENT_TYPE, "EGL_TRANSPARENT_TYPE"}, - {EGL_TRANSPARENT_BLUE_VALUE, "EGL_TRANSPARENT_BLUE_VALUE"}, - {EGL_TRANSPARENT_GREEN_VALUE, "EGL_TRANSPARENT_GREEN_VALUE"}, - {EGL_TRANSPARENT_RED_VALUE, "EGL_TRANSPARENT_RED_VALUE"}, - {EGL_BIND_TO_TEXTURE_RGB, "EGL_BIND_TO_TEXTURE_RGB"}, - {EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA"}, - {EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL"}, - {EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL"}, - {-1, 0}}; -#endif //QEGL_EXTRA_DEBUG - - -class QEglScreen; - -class QEglContext : public QPlatformGLContext -{ -public: - QEglContext(QGLFormat& format, QPlatformGLContext* shareContext = 0); - ~QEglContext(); - - virtual void makeCurrent(); - virtual void doneCurrent(); - virtual void swapBuffers(); - virtual void* getProcAddress(const QString& procName); - - EGLContext eglContext() {return m_context;} - QSize size() const { return m_size; } - - QGLFormat format() const { return m_format; } -private: - - EGLContext m_context; - EGLDisplay m_dpy; - EGLSurface m_surface; - QSize m_size; - static bool singleton_watch; - QGLFormat m_format; -}; - -bool QEglContext::singleton_watch = false; - -QEglContext::QEglContext(QGLFormat& format, QPlatformGLContext* shareContext) -{ - if (singleton_watch) - qFatal("There can be only one"); - singleton_watch = true; - - Q_UNUSED(shareContext); - Q_UNUSED(format); - - EGLint major, minor; -#ifdef QEGL_EXTRA_DEBUG - EGLint index; -#endif - if (!eglBindAPI(EGL_OPENGL_ES_API)) { - fprintf(stderr, "Could not bind GL_ES API\n"); - qFatal("EGL error"); - } - - m_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (m_dpy == EGL_NO_DISPLAY) { - fprintf(stderr, "Could not open egl display\n"); - qFatal("EGL error"); - } - fprintf(stderr, "Opened display %p\n", m_dpy); - - if (!eglInitialize(m_dpy, &major, &minor)) { - fprintf(stderr, "Could not initialize egl display\n"); - qFatal("EGL error"); - } - - fprintf(stderr, "Initialized display %d %d\n", major, minor); - - QPlatformWindowFormat platformFormat; - platformFormat.setDepth(16); - platformFormat.setWindowApi(QPlatformWindowFormat::OpenGL); - platformFormat.setRedBufferSize(5); - platformFormat.setGreenBufferSize(6); - platformFormat.setBlueBufferSize(5); - EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat); - -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "Configuration %d matches requirements\n", (int)config); - - for (index = 0; attrs[index].attr != -1; ++index) { - EGLint value; - if (eglGetConfigAttrib(m_dpy, config, attrs[index].attr, &value)) { - printf("\t%s: %d\n", attrs[index].name, (int)value); - } - } - printf("\n"); -#endif - EGLint temp; - EGLint attribList[32]; - - temp = 0; - - attribList[temp++] = EGL_CONTEXT_CLIENT_VERSION; - attribList[temp++] = 2; // GLES version 2 - attribList[temp++] = EGL_NONE; - - - m_context = eglCreateContext(m_dpy, config, NULL, attribList); - if (m_context == EGL_NO_CONTEXT) { - fprintf(stderr, "Could not create the egl context\n"); - eglTerminate(m_dpy); - qFatal("EGL error"); - } - - m_surface = eglCreateWindowSurface(m_dpy, config, 0, NULL); - if (m_surface == EGL_NO_SURFACE) { - fprintf(stderr, "Could not create the egl surface: error = 0x%x\n", eglGetError()); - eglTerminate(m_dpy); - qFatal("EGL error"); - } - - EGLint w,h; - - eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w); - eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h); - fprintf(stderr, "Created surface %dx%d\n", w, h); - - m_size = QSize(w,h); - - -} - -QEglContext::~QEglContext() -{ -#ifdef QEGL_EXTRA_DEBUG - qDebug() << "QEglContext::~QEglContext()"; -#endif -} - -void QEglContext::makeCurrent() -{ -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglContext::makeCurrent\n"); -#endif - if (!eglMakeCurrent(m_dpy, m_surface, m_surface, m_context)) - fprintf(stderr, "Could not make the egl context current\n"); - -#ifdef QEGL_EXTRA_DEBUG - static bool showDebug = true; - if (showDebug) { - showDebug = false; - const char *str = (const char*)glGetString(GL_VENDOR); - qDebug() << "Vendor" << str; - printf("Vendor %s\n", str); - str = (const char*)glGetString(GL_RENDERER); - qDebug() << "Renderer" << str; - printf("Renderer %s\n", str); - str = (const char*)glGetString(GL_VERSION); - qDebug() << "Version" << str; - printf("Version %s\n", str); - - str = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); - qDebug() << "Shader version" << str; - - str = (const char*)glGetString(GL_EXTENSIONS); - qDebug() << "Extensions" << str; - printf("Extensions %s\n", str); - - } -#endif -} - -void QEglContext::doneCurrent() -{ -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglContext::doneCurrent\n"); -#endif - if (!eglMakeCurrent(m_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) - fprintf(stderr, "Could not release the egl context\n"); -} - -void QEglContext::swapBuffers() -{ -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglContext::swapBuffers\n"); -#endif - eglSwapBuffers(m_dpy, m_surface); -} - -void* QEglContext::getProcAddress(const QString& procName) -{ -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglContext::getProcAddress\n"); -#endif - return (void*)eglGetProcAddress(qPrintable(procName)); -} - - -class QEglPaintDevice; -class QEglScreen : public QPlatformScreen -{ -public: - QEglScreen(); - ~QEglScreen() {} - - 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; } //### - -public: - QRect m_geometry; - int m_depth; - QImage::Format m_format; - //QSize m_physicalSize; - QEglContext * m_platformContext; -}; - - -class QEglWindow : public QPlatformWindow -{ -public: - QEglWindow(QWidget *w, QEglScreen *screen); - QPlatformGLContext *glContext(); - - void setGeometry(const QRect &); - WId winId() const; - - QGLContext *context() { return m_context; } - QEglPaintDevice *paintDevice() { return m_pd; } -private: - QEglScreen *m_screen; - QEglPaintDevice *m_pd; - QGLContext *m_context; - WId m_winid; -}; - -class QEglPaintDevice : public QGLPaintDevice -{ -public: - QEglPaintDevice(QEglScreen *screen, QEglWindow *window); - - QSize size() const { return m_screen->geometry().size(); } - QGLContext* context() const { return m_window->context();} - - QPaintEngine *paintEngine() const { return qt_qgl_paint_engine(); } - - void beginPaint(){ - QGLPaintDevice::beginPaint(); - } -private: - QEglScreen *m_screen; - QEglWindow * m_window; -}; - - - - -QEglScreen::QEglScreen() - : m_depth(16), m_format(QImage::Format_RGB16), m_platformContext(0) -{ -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglScreen %p\n", this); -#endif - QGLFormat format = QGLFormat::defaultFormat(); - m_platformContext = new QEglContext(format); - - - m_geometry = QRect(QPoint(), m_platformContext->size()); - -} - - - - -QEglPaintDevice::QEglPaintDevice(QEglScreen *screen, QEglWindow *window) - :QGLPaintDevice(), m_screen(screen), m_window(window) -{ -#ifdef QEGL_EXTRA_DEBUG - qDebug() << "QEglPaintDevice" << this << screen << window; -#endif -} - - - -QEglWindow::QEglWindow(QWidget *w, QEglScreen *screen) - : QPlatformWindow(w), m_screen(screen), m_pd(0), m_context(0) -{ - static int serialNo = 0; - m_winid = ++serialNo; -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglWindow %p: %p %p 0x%x\n", this, w, screen, uint(m_winid)); -#endif - m_pd = new QEglPaintDevice(screen, this); - m_context = new QGLContext( screen->m_platformContext->format(), w); - m_context->create(); -} - - -void QEglWindow::setGeometry(const QRect &) -{ - // We only support full-screen windows - QRect rect(m_screen->availableGeometry()); - QWindowSystemInterface::handleGeometryChange(this->widget(), rect); - - QPlatformWindow::setGeometry(rect); -} - -WId QEglWindow::winId() const -{ - return m_winid; -} - - - -QPlatformGLContext *QEglWindow::glContext() -{ -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglWindow::glContext %p\n", m_screen->m_platformContext); -#endif - Q_ASSERT(m_screen); - return m_screen->m_platformContext; -} - -QEglIntegration::QEglIntegration() -{ - m_primaryScreen = new QEglScreen(); - - mScreens.append(m_primaryScreen); -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglIntegration\n"); -#endif -} - -QPixmapData *QEglIntegration::createPixmapData(QPixmapData::PixelType type) const -{ -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglIntegration::createPixmapData %d\n", type); -#endif - return new QGLPixmapData(type); -} - -QPlatformWindow *QEglIntegration::createPlatformWindow(QWidget *widget, WId winId) const -{ - Q_UNUSED(winId); -#ifdef QEGL_EXTRA_DEBUG - qDebug() << "QEglIntegration::createPlatformWindow" << widget; -#endif - return new QEglWindow(widget, m_primaryScreen); -} - - -class QEglWindowSurface : public QWindowSurface -{ -public: - QEglWindowSurface(QWidget *window, QEglScreen *screen); - ~QEglWindowSurface() {} - - QPaintDevice *paintDevice() { return m_window->paintDevice(); } - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void resize(const QSize &size) {} -private: - QEglScreen *m_screen; - QEglWindow *m_window; -}; - -QEglWindowSurface::QEglWindowSurface(QWidget *window, QEglScreen *screen) - :QWindowSurface(window), m_screen(screen), m_window(0) -{ -#ifdef QEGL_EXTRA_DEBUG - qDebug() << "QEglWindowSurface" << window << screen; -#endif - m_window = static_cast(window->platformWindow()); -} - - -void QEglWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(region); - Q_UNUSED(offset); -#ifdef QEGL_EXTRA_DEBUG - qDebug() << "QEglWindowSurface::flush"; -#endif - m_screen->m_platformContext->swapBuffers(); -} - -QWindowSurface *QEglIntegration::createWindowSurface(QWidget *widget, WId winId) const -{ - Q_UNUSED(winId); - -#ifdef QEGL_EXTRA_DEBUG - qDebug() << "QEglIntegration::createWindowSurface" << widget; -#endif - return new QEglWindowSurface(widget, m_primaryScreen); -} diff --git a/src/plugins/platforms/eglfs/eglintegration.h b/src/plugins/platforms/eglfs/eglintegration.h deleted file mode 100644 index 7b9b8cf..0000000 --- a/src/plugins/platforms/eglfs/eglintegration.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** 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 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 EGLINTEGRATION_H -#define EGLINTEGRATION_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QEglScreen; -class QEglIntegration : public QPlatformIntegration -{ -public: - QEglIntegration(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; - QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; - - QList screens() const { return mScreens; } - -private: - QList mScreens; - QEglScreen *m_primaryScreen; -}; - -QT_END_NAMESPACE - - -#endif diff --git a/src/plugins/platforms/eglfs/eglintegration.pro b/src/plugins/platforms/eglfs/eglintegration.pro deleted file mode 100644 index 7cd2f05..0000000 --- a/src/plugins/platforms/eglfs/eglintegration.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = eglintegration -TEMPLATE = lib -CONFIG += plugin - -QT += opengl - -SOURCES = main.cpp \ - eglintegration.cpp \ - ../eglconvenience/qeglconvenience.cpp -HEADERS = eglintegration.h \ - ../eglconvenience/qeglconvenience.h - -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target diff --git a/src/plugins/platforms/eglfs/main.cpp b/src/plugins/platforms/eglfs/main.cpp index adaea78..e1731e8 100644 --- a/src/plugins/platforms/eglfs/main.cpp +++ b/src/plugins/platforms/eglfs/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include -#include "eglintegration.h" +#include "qeglfsintegration.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp new file mode 100644 index 0000000..4d17980 --- /dev/null +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -0,0 +1,469 @@ +/**************************************************************************** +** +** 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 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 "qeglfsintegration.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "../eglconvenience/qeglconvenience.h" + +//#define QEGL_EXTRA_DEBUG +#ifdef QEGL_EXTRA_DEBUG +struct AttrInfo { EGLint attr; const char *name; }; +static struct AttrInfo attrs[] = { + {EGL_BUFFER_SIZE, "EGL_BUFFER_SIZE"}, + {EGL_ALPHA_SIZE, "EGL_ALPHA_SIZE"}, + {EGL_BLUE_SIZE, "EGL_BLUE_SIZE"}, + {EGL_GREEN_SIZE, "EGL_GREEN_SIZE"}, + {EGL_RED_SIZE, "EGL_RED_SIZE"}, + {EGL_DEPTH_SIZE, "EGL_DEPTH_SIZE"}, + {EGL_STENCIL_SIZE, "EGL_STENCIL_SIZE"}, + {EGL_CONFIG_CAVEAT, "EGL_CONFIG_CAVEAT"}, + {EGL_CONFIG_ID, "EGL_CONFIG_ID"}, + {EGL_LEVEL, "EGL_LEVEL"}, + {EGL_MAX_PBUFFER_HEIGHT, "EGL_MAX_PBUFFER_HEIGHT"}, + {EGL_MAX_PBUFFER_PIXELS, "EGL_MAX_PBUFFER_PIXELS"}, + {EGL_MAX_PBUFFER_WIDTH, "EGL_MAX_PBUFFER_WIDTH"}, + {EGL_NATIVE_RENDERABLE, "EGL_NATIVE_RENDERABLE"}, + {EGL_NATIVE_VISUAL_ID, "EGL_NATIVE_VISUAL_ID"}, + {EGL_NATIVE_VISUAL_TYPE, "EGL_NATIVE_VISUAL_TYPE"}, + {EGL_SAMPLES, "EGL_SAMPLES"}, + {EGL_SAMPLE_BUFFERS, "EGL_SAMPLE_BUFFERS"}, + {EGL_SURFACE_TYPE, "EGL_SURFACE_TYPE"}, + {EGL_TRANSPARENT_TYPE, "EGL_TRANSPARENT_TYPE"}, + {EGL_TRANSPARENT_BLUE_VALUE, "EGL_TRANSPARENT_BLUE_VALUE"}, + {EGL_TRANSPARENT_GREEN_VALUE, "EGL_TRANSPARENT_GREEN_VALUE"}, + {EGL_TRANSPARENT_RED_VALUE, "EGL_TRANSPARENT_RED_VALUE"}, + {EGL_BIND_TO_TEXTURE_RGB, "EGL_BIND_TO_TEXTURE_RGB"}, + {EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA"}, + {EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL"}, + {EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL"}, + {-1, 0}}; +#endif //QEGL_EXTRA_DEBUG + + +class QEglScreen; + +class QEglContext : public QPlatformGLContext +{ +public: + QEglContext(QGLFormat& format, QPlatformGLContext* shareContext = 0); + ~QEglContext(); + + virtual void makeCurrent(); + virtual void doneCurrent(); + virtual void swapBuffers(); + virtual void* getProcAddress(const QString& procName); + + EGLContext eglContext() {return m_context;} + QSize size() const { return m_size; } + + QGLFormat format() const { return m_format; } +private: + + EGLContext m_context; + EGLDisplay m_dpy; + EGLSurface m_surface; + QSize m_size; + static bool singleton_watch; + QGLFormat m_format; +}; + +bool QEglContext::singleton_watch = false; + +QEglContext::QEglContext(QGLFormat& format, QPlatformGLContext* shareContext) +{ + if (singleton_watch) + qFatal("There can be only one"); + singleton_watch = true; + + Q_UNUSED(shareContext); + Q_UNUSED(format); + + EGLint major, minor; +#ifdef QEGL_EXTRA_DEBUG + EGLint index; +#endif + if (!eglBindAPI(EGL_OPENGL_ES_API)) { + fprintf(stderr, "Could not bind GL_ES API\n"); + qFatal("EGL error"); + } + + m_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (m_dpy == EGL_NO_DISPLAY) { + fprintf(stderr, "Could not open egl display\n"); + qFatal("EGL error"); + } + fprintf(stderr, "Opened display %p\n", m_dpy); + + if (!eglInitialize(m_dpy, &major, &minor)) { + fprintf(stderr, "Could not initialize egl display\n"); + qFatal("EGL error"); + } + + fprintf(stderr, "Initialized display %d %d\n", major, minor); + + QPlatformWindowFormat platformFormat; + platformFormat.setDepth(16); + platformFormat.setWindowApi(QPlatformWindowFormat::OpenGL); + platformFormat.setRedBufferSize(5); + platformFormat.setGreenBufferSize(6); + platformFormat.setBlueBufferSize(5); + EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat); + +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "Configuration %d matches requirements\n", (int)config); + + for (index = 0; attrs[index].attr != -1; ++index) { + EGLint value; + if (eglGetConfigAttrib(m_dpy, config, attrs[index].attr, &value)) { + printf("\t%s: %d\n", attrs[index].name, (int)value); + } + } + printf("\n"); +#endif + EGLint temp; + EGLint attribList[32]; + + temp = 0; + + attribList[temp++] = EGL_CONTEXT_CLIENT_VERSION; + attribList[temp++] = 2; // GLES version 2 + attribList[temp++] = EGL_NONE; + + + m_context = eglCreateContext(m_dpy, config, NULL, attribList); + if (m_context == EGL_NO_CONTEXT) { + fprintf(stderr, "Could not create the egl context\n"); + eglTerminate(m_dpy); + qFatal("EGL error"); + } + + m_surface = eglCreateWindowSurface(m_dpy, config, 0, NULL); + if (m_surface == EGL_NO_SURFACE) { + fprintf(stderr, "Could not create the egl surface: error = 0x%x\n", eglGetError()); + eglTerminate(m_dpy); + qFatal("EGL error"); + } + + EGLint w,h; + + eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w); + eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h); + fprintf(stderr, "Created surface %dx%d\n", w, h); + + m_size = QSize(w,h); + + +} + +QEglContext::~QEglContext() +{ +#ifdef QEGL_EXTRA_DEBUG + qDebug() << "QEglContext::~QEglContext()"; +#endif +} + +void QEglContext::makeCurrent() +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglContext::makeCurrent\n"); +#endif + if (!eglMakeCurrent(m_dpy, m_surface, m_surface, m_context)) + fprintf(stderr, "Could not make the egl context current\n"); + +#ifdef QEGL_EXTRA_DEBUG + static bool showDebug = true; + if (showDebug) { + showDebug = false; + const char *str = (const char*)glGetString(GL_VENDOR); + qDebug() << "Vendor" << str; + printf("Vendor %s\n", str); + str = (const char*)glGetString(GL_RENDERER); + qDebug() << "Renderer" << str; + printf("Renderer %s\n", str); + str = (const char*)glGetString(GL_VERSION); + qDebug() << "Version" << str; + printf("Version %s\n", str); + + str = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); + qDebug() << "Shader version" << str; + + str = (const char*)glGetString(GL_EXTENSIONS); + qDebug() << "Extensions" << str; + printf("Extensions %s\n", str); + + } +#endif +} + +void QEglContext::doneCurrent() +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglContext::doneCurrent\n"); +#endif + if (!eglMakeCurrent(m_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) + fprintf(stderr, "Could not release the egl context\n"); +} + +void QEglContext::swapBuffers() +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglContext::swapBuffers\n"); +#endif + eglSwapBuffers(m_dpy, m_surface); +} + +void* QEglContext::getProcAddress(const QString& procName) +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglContext::getProcAddress\n"); +#endif + return (void*)eglGetProcAddress(qPrintable(procName)); +} + + +class QEglPaintDevice; +class QEglScreen : public QPlatformScreen +{ +public: + QEglScreen(); + ~QEglScreen() {} + + 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; } //### + +public: + QRect m_geometry; + int m_depth; + QImage::Format m_format; + //QSize m_physicalSize; + QEglContext * m_platformContext; +}; + + +class QEglWindow : public QPlatformWindow +{ +public: + QEglWindow(QWidget *w, QEglScreen *screen); + QPlatformGLContext *glContext(); + + void setGeometry(const QRect &); + WId winId() const; + + QGLContext *context() { return m_context; } + QEglPaintDevice *paintDevice() { return m_pd; } +private: + QEglScreen *m_screen; + QEglPaintDevice *m_pd; + QGLContext *m_context; + WId m_winid; +}; + +class QEglPaintDevice : public QGLPaintDevice +{ +public: + QEglPaintDevice(QEglScreen *screen, QEglWindow *window); + + QSize size() const { return m_screen->geometry().size(); } + QGLContext* context() const { return m_window->context();} + + QPaintEngine *paintEngine() const { return qt_qgl_paint_engine(); } + + void beginPaint(){ + QGLPaintDevice::beginPaint(); + } +private: + QEglScreen *m_screen; + QEglWindow * m_window; +}; + + + + +QEglScreen::QEglScreen() + : m_depth(16), m_format(QImage::Format_RGB16), m_platformContext(0) +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglScreen %p\n", this); +#endif + QGLFormat format = QGLFormat::defaultFormat(); + m_platformContext = new QEglContext(format); + + + m_geometry = QRect(QPoint(), m_platformContext->size()); + +} + + + + +QEglPaintDevice::QEglPaintDevice(QEglScreen *screen, QEglWindow *window) + :QGLPaintDevice(), m_screen(screen), m_window(window) +{ +#ifdef QEGL_EXTRA_DEBUG + qDebug() << "QEglPaintDevice" << this << screen << window; +#endif +} + + + +QEglWindow::QEglWindow(QWidget *w, QEglScreen *screen) + : QPlatformWindow(w), m_screen(screen), m_pd(0), m_context(0) +{ + static int serialNo = 0; + m_winid = ++serialNo; +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglWindow %p: %p %p 0x%x\n", this, w, screen, uint(m_winid)); +#endif + m_pd = new QEglPaintDevice(screen, this); + m_context = new QGLContext( screen->m_platformContext->format(), w); + m_context->create(); +} + + +void QEglWindow::setGeometry(const QRect &) +{ + // We only support full-screen windows + QRect rect(m_screen->availableGeometry()); + QWindowSystemInterface::handleGeometryChange(this->widget(), rect); + + QPlatformWindow::setGeometry(rect); +} + +WId QEglWindow::winId() const +{ + return m_winid; +} + + + +QPlatformGLContext *QEglWindow::glContext() +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglWindow::glContext %p\n", m_screen->m_platformContext); +#endif + Q_ASSERT(m_screen); + return m_screen->m_platformContext; +} + +QEglIntegration::QEglIntegration() +{ + m_primaryScreen = new QEglScreen(); + + mScreens.append(m_primaryScreen); +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglIntegration\n"); +#endif +} + +QPixmapData *QEglIntegration::createPixmapData(QPixmapData::PixelType type) const +{ +#ifdef QEGL_EXTRA_DEBUG + fprintf(stderr, "QEglIntegration::createPixmapData %d\n", type); +#endif + return new QGLPixmapData(type); +} + +QPlatformWindow *QEglIntegration::createPlatformWindow(QWidget *widget, WId winId) const +{ + Q_UNUSED(winId); +#ifdef QEGL_EXTRA_DEBUG + qDebug() << "QEglIntegration::createPlatformWindow" << widget; +#endif + return new QEglWindow(widget, m_primaryScreen); +} + + +class QEglWindowSurface : public QWindowSurface +{ +public: + QEglWindowSurface(QWidget *window, QEglScreen *screen); + ~QEglWindowSurface() {} + + QPaintDevice *paintDevice() { return m_window->paintDevice(); } + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void resize(const QSize &size) {} +private: + QEglScreen *m_screen; + QEglWindow *m_window; +}; + +QEglWindowSurface::QEglWindowSurface(QWidget *window, QEglScreen *screen) + :QWindowSurface(window), m_screen(screen), m_window(0) +{ +#ifdef QEGL_EXTRA_DEBUG + qDebug() << "QEglWindowSurface" << window << screen; +#endif + m_window = static_cast(window->platformWindow()); +} + + +void QEglWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); +#ifdef QEGL_EXTRA_DEBUG + qDebug() << "QEglWindowSurface::flush"; +#endif + m_screen->m_platformContext->swapBuffers(); +} + +QWindowSurface *QEglIntegration::createWindowSurface(QWidget *widget, WId winId) const +{ + Q_UNUSED(winId); + +#ifdef QEGL_EXTRA_DEBUG + qDebug() << "QEglIntegration::createWindowSurface" << widget; +#endif + return new QEglWindowSurface(widget, m_primaryScreen); +} diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h new file mode 100644 index 0000000..7b9b8cf --- /dev/null +++ b/src/plugins/platforms/eglfs/qeglfsintegration.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 EGLINTEGRATION_H +#define EGLINTEGRATION_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QEglScreen; +class QEglIntegration : public QPlatformIntegration +{ +public: + QEglIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + + QList screens() const { return mScreens; } + +private: + QList mScreens; + QEglScreen *m_primaryScreen; +}; + +QT_END_NAMESPACE + + +#endif -- cgit v0.12 From 4edb2026545574e287c3d71c272c02dec9134e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 27 Jul 2010 07:42:44 +0200 Subject: Refactored the eglfs plugin seperated the functionality into different files, and made the paintdevice belong to the windowsurface. Everything really belongs to the screen, since everything is full screen but, this makes it more on par with the other plugins. --- src/gui/kernel/qplatformscreen_qpa.h | 2 +- .../platforms/eglconvenience/qeglconvenience.cpp | 5 +- .../eglconvenience/qeglplatformcontext.cpp | 47 ++- src/plugins/platforms/eglfs/eglfs.pro | 17 +- src/plugins/platforms/eglfs/main.cpp | 2 +- src/plugins/platforms/eglfs/qeglfsintegration.cpp | 412 +-------------------- src/plugins/platforms/eglfs/qeglfsintegration.h | 13 +- src/plugins/platforms/eglfs/qeglfsscreen.cpp | 174 +++++++++ src/plugins/platforms/eglfs/qeglfsscreen.h | 75 ++++ src/plugins/platforms/eglfs/qeglfswindow.cpp | 83 +++++ src/plugins/platforms/eglfs/qeglfswindow.h | 69 ++++ .../platforms/eglfs/qeglfswindowsurface.cpp | 103 ++++++ src/plugins/platforms/eglfs/qeglfswindowsurface.h | 66 ++++ 13 files changed, 655 insertions(+), 413 deletions(-) create mode 100644 src/plugins/platforms/eglfs/qeglfsscreen.cpp create mode 100644 src/plugins/platforms/eglfs/qeglfsscreen.h create mode 100644 src/plugins/platforms/eglfs/qeglfswindow.cpp create mode 100644 src/plugins/platforms/eglfs/qeglfswindow.h create mode 100644 src/plugins/platforms/eglfs/qeglfswindowsurface.cpp create mode 100644 src/plugins/platforms/eglfs/qeglfswindowsurface.h diff --git a/src/gui/kernel/qplatformscreen_qpa.h b/src/gui/kernel/qplatformscreen_qpa.h index 7d0e28d..f603db5 100644 --- a/src/gui/kernel/qplatformscreen_qpa.h +++ b/src/gui/kernel/qplatformscreen_qpa.h @@ -59,7 +59,7 @@ public: virtual ~QPlatformScreen() { } virtual QRect geometry() const = 0; - virtual QRect availableGeometry() const {return geometry();}; + virtual QRect availableGeometry() const {return geometry();} virtual int depth() const = 0; virtual QImage::Format format() const = 0; virtual QSize physicalSize() const; diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp index 1064e47..c50101d 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp @@ -1,7 +1,5 @@ #include "qeglconvenience.h" -#include - QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format) { int redSize = format.redBufferSize(); @@ -178,7 +176,6 @@ EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformW } else { configureAttributes.append(EGL_OPENGL_ES2_BIT); } - configureAttributes.append(EGL_NONE); do { @@ -228,6 +225,6 @@ EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformW } delete [] configs; } while (q_reduceConfigAttributes(&configureAttributes)); - qDebug() << "RETURNING NULL!"; + qWarning("Cant find EGLConfig, returning null config"); return 0; } diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp index 6afeb70..a72f7b2 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp @@ -43,7 +43,6 @@ #include -#include #include QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi) @@ -57,13 +56,18 @@ QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, E eglBindAPI(m_eglApi); m_eglContext = eglCreateContext(m_eglDisplay,config, 0,contextAttrs); - if (!m_eglContext) { - qErrnoWarning("QEGLPlatformContext could not create eglContext"); + if (m_eglContext == EGL_NO_CONTEXT) { + qWarning("Could not create the egl context\n"); + eglTerminate(m_eglDisplay); + qFatal("EGL error"); } } QEGLPlatformContext::~QEGLPlatformContext() { +#ifdef QEGL_EXTRA_DEBUG + qWarning("QEglContext::~QEglContext(): %p\n",this); +#endif if (m_eglSurface != EGL_NO_SURFACE) { doneCurrent(); eglDestroySurface(m_eglDisplay, m_eglSurface); @@ -78,27 +82,58 @@ QEGLPlatformContext::~QEGLPlatformContext() void QEGLPlatformContext::makeCurrent() { +#ifdef QEGL_EXTRA_DEBUG + qWarning("QEglContext::makeCurrent: %p\n",this); +#endif eglBindAPI(m_eglApi); bool ok = eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext); if (!ok) - qWarning() << "QEGLPlatformContext::makeCurrent(" << m_eglSurface << "):" << eglGetError(); + qWarning("QEGLPlatformContext::makeCurrent: eglError: %d, this: %p \n", eglGetError(), this); +#ifdef QEGL_EXTRA_DEBUG + static bool showDebug = true; + if (showDebug) { + showDebug = false; + const char *str = (const char*)glGetString(GL_VENDOR); + qWarning("Vendor %s\n", str); + str = (const char*)glGetString(GL_RENDERER); + qWarning("Renderer %s\n", str); + str = (const char*)glGetString(GL_VERSION); + qWarning("Version %s\n", str); + + str = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); + qWarning("Extensions %s\n",str); + + str = (const char*)glGetString(GL_EXTENSIONS); + qWarning("Extensions %s\n", str); + + } +#endif } void QEGLPlatformContext::doneCurrent() { +#ifdef QEGL_EXTRA_DEBUG + qWarning("QEglContext::doneCurrent:%p\n",this); +#endif eglBindAPI(m_eglApi); bool ok = eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (!ok) - qWarning() << "QEGLPlatformContext::doneCurrent():" << eglGetError(); + qWarning("QEGLPlatformContext::doneCurrent(): eglError: %d, this: %p \n", eglGetError(), this); } void QEGLPlatformContext::swapBuffers() { +#ifdef QEGL_EXTRA_DEBUG + qWarning("QEglContext::swapBuffers:%p\n",this); +#endif eglBindAPI(m_eglApi); bool ok = eglSwapBuffers(m_eglDisplay, m_eglSurface); if (!ok) - qWarning() << "QEGLPlatformContext::swapBuffers():" << eglGetError(); + qWarning("QEGLPlatformContext::swapBuffers(): eglError: %d, this: %p \n", eglGetError(), this); } void* QEGLPlatformContext::getProcAddress(const QString& procName) { +#ifdef QEGL_EXTRA_DEBUG + qWarning("QEglContext::getProcAddress%p\n",this); +#endif eglBindAPI(m_eglApi); return (void *)eglGetProcAddress(qPrintable(procName)); } diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro index 2cc5997..5d1318a 100644 --- a/src/plugins/platforms/eglfs/eglfs.pro +++ b/src/plugins/platforms/eglfs/eglfs.pro @@ -6,11 +6,24 @@ QT += opengl QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms +#DEFINES += QEGL_EXTRA_DEBUG + +#DEFINES += Q_OPENKODE + SOURCES = main.cpp \ qeglfsintegration.cpp \ - ../eglconvenience/qeglconvenience.cpp + ../eglconvenience/qeglconvenience.cpp \ + ../eglconvenience/qeglplatformcontext.cpp \ + qeglfswindow.cpp \ + qeglfswindowsurface.cpp \ + qeglfsscreen.cpp + HEADERS = qeglfsintegration.h \ - ../eglconvenience/qeglconvenience.h + ../eglconvenience/qeglconvenience.h \ + ../eglconvenience/qeglplatformcontext.h \ + qeglfswindow.h \ + qeglfswindowsurface.h \ + qeglfsscreen.h target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/eglfs/main.cpp b/src/plugins/platforms/eglfs/main.cpp index e1731e8..d0a82b7 100644 --- a/src/plugins/platforms/eglfs/main.cpp +++ b/src/plugins/platforms/eglfs/main.cpp @@ -62,7 +62,7 @@ QPlatformIntegration* QEglIntegrationPlugin::create(const QString& system, const { Q_UNUSED(paramList); if (system.toLower() == "eglfs") - return new QEglIntegration; + return new QEglFSIntegration; return 0; } diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index 4d17980..2b673ae 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -41,429 +41,53 @@ #include "qeglfsintegration.h" +#include "qeglfswindow.h" +#include "qeglfswindowsurface.h" + #include -#include +#include #include -#include -#include #include -#include -#include - -#include "../eglconvenience/qeglconvenience.h" - -//#define QEGL_EXTRA_DEBUG -#ifdef QEGL_EXTRA_DEBUG -struct AttrInfo { EGLint attr; const char *name; }; -static struct AttrInfo attrs[] = { - {EGL_BUFFER_SIZE, "EGL_BUFFER_SIZE"}, - {EGL_ALPHA_SIZE, "EGL_ALPHA_SIZE"}, - {EGL_BLUE_SIZE, "EGL_BLUE_SIZE"}, - {EGL_GREEN_SIZE, "EGL_GREEN_SIZE"}, - {EGL_RED_SIZE, "EGL_RED_SIZE"}, - {EGL_DEPTH_SIZE, "EGL_DEPTH_SIZE"}, - {EGL_STENCIL_SIZE, "EGL_STENCIL_SIZE"}, - {EGL_CONFIG_CAVEAT, "EGL_CONFIG_CAVEAT"}, - {EGL_CONFIG_ID, "EGL_CONFIG_ID"}, - {EGL_LEVEL, "EGL_LEVEL"}, - {EGL_MAX_PBUFFER_HEIGHT, "EGL_MAX_PBUFFER_HEIGHT"}, - {EGL_MAX_PBUFFER_PIXELS, "EGL_MAX_PBUFFER_PIXELS"}, - {EGL_MAX_PBUFFER_WIDTH, "EGL_MAX_PBUFFER_WIDTH"}, - {EGL_NATIVE_RENDERABLE, "EGL_NATIVE_RENDERABLE"}, - {EGL_NATIVE_VISUAL_ID, "EGL_NATIVE_VISUAL_ID"}, - {EGL_NATIVE_VISUAL_TYPE, "EGL_NATIVE_VISUAL_TYPE"}, - {EGL_SAMPLES, "EGL_SAMPLES"}, - {EGL_SAMPLE_BUFFERS, "EGL_SAMPLE_BUFFERS"}, - {EGL_SURFACE_TYPE, "EGL_SURFACE_TYPE"}, - {EGL_TRANSPARENT_TYPE, "EGL_TRANSPARENT_TYPE"}, - {EGL_TRANSPARENT_BLUE_VALUE, "EGL_TRANSPARENT_BLUE_VALUE"}, - {EGL_TRANSPARENT_GREEN_VALUE, "EGL_TRANSPARENT_GREEN_VALUE"}, - {EGL_TRANSPARENT_RED_VALUE, "EGL_TRANSPARENT_RED_VALUE"}, - {EGL_BIND_TO_TEXTURE_RGB, "EGL_BIND_TO_TEXTURE_RGB"}, - {EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA"}, - {EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL"}, - {EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL"}, - {-1, 0}}; -#endif //QEGL_EXTRA_DEBUG - - -class QEglScreen; - -class QEglContext : public QPlatformGLContext -{ -public: - QEglContext(QGLFormat& format, QPlatformGLContext* shareContext = 0); - ~QEglContext(); - - virtual void makeCurrent(); - virtual void doneCurrent(); - virtual void swapBuffers(); - virtual void* getProcAddress(const QString& procName); - - EGLContext eglContext() {return m_context;} - QSize size() const { return m_size; } - - QGLFormat format() const { return m_format; } -private: - - EGLContext m_context; - EGLDisplay m_dpy; - EGLSurface m_surface; - QSize m_size; - static bool singleton_watch; - QGLFormat m_format; -}; - -bool QEglContext::singleton_watch = false; - -QEglContext::QEglContext(QGLFormat& format, QPlatformGLContext* shareContext) -{ - if (singleton_watch) - qFatal("There can be only one"); - singleton_watch = true; - - Q_UNUSED(shareContext); - Q_UNUSED(format); - - EGLint major, minor; -#ifdef QEGL_EXTRA_DEBUG - EGLint index; -#endif - if (!eglBindAPI(EGL_OPENGL_ES_API)) { - fprintf(stderr, "Could not bind GL_ES API\n"); - qFatal("EGL error"); - } - - m_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (m_dpy == EGL_NO_DISPLAY) { - fprintf(stderr, "Could not open egl display\n"); - qFatal("EGL error"); - } - fprintf(stderr, "Opened display %p\n", m_dpy); - - if (!eglInitialize(m_dpy, &major, &minor)) { - fprintf(stderr, "Could not initialize egl display\n"); - qFatal("EGL error"); - } - - fprintf(stderr, "Initialized display %d %d\n", major, minor); - - QPlatformWindowFormat platformFormat; - platformFormat.setDepth(16); - platformFormat.setWindowApi(QPlatformWindowFormat::OpenGL); - platformFormat.setRedBufferSize(5); - platformFormat.setGreenBufferSize(6); - platformFormat.setBlueBufferSize(5); - EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat); - -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "Configuration %d matches requirements\n", (int)config); - - for (index = 0; attrs[index].attr != -1; ++index) { - EGLint value; - if (eglGetConfigAttrib(m_dpy, config, attrs[index].attr, &value)) { - printf("\t%s: %d\n", attrs[index].name, (int)value); - } - } - printf("\n"); -#endif - EGLint temp; - EGLint attribList[32]; - - temp = 0; - - attribList[temp++] = EGL_CONTEXT_CLIENT_VERSION; - attribList[temp++] = 2; // GLES version 2 - attribList[temp++] = EGL_NONE; - - - m_context = eglCreateContext(m_dpy, config, NULL, attribList); - if (m_context == EGL_NO_CONTEXT) { - fprintf(stderr, "Could not create the egl context\n"); - eglTerminate(m_dpy); - qFatal("EGL error"); - } - - m_surface = eglCreateWindowSurface(m_dpy, config, 0, NULL); - if (m_surface == EGL_NO_SURFACE) { - fprintf(stderr, "Could not create the egl surface: error = 0x%x\n", eglGetError()); - eglTerminate(m_dpy); - qFatal("EGL error"); - } - - EGLint w,h; - - eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w); - eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h); - fprintf(stderr, "Created surface %dx%d\n", w, h); - - m_size = QSize(w,h); +QT_BEGIN_NAMESPACE -} - -QEglContext::~QEglContext() -{ -#ifdef QEGL_EXTRA_DEBUG - qDebug() << "QEglContext::~QEglContext()"; -#endif -} - -void QEglContext::makeCurrent() -{ -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglContext::makeCurrent\n"); -#endif - if (!eglMakeCurrent(m_dpy, m_surface, m_surface, m_context)) - fprintf(stderr, "Could not make the egl context current\n"); - -#ifdef QEGL_EXTRA_DEBUG - static bool showDebug = true; - if (showDebug) { - showDebug = false; - const char *str = (const char*)glGetString(GL_VENDOR); - qDebug() << "Vendor" << str; - printf("Vendor %s\n", str); - str = (const char*)glGetString(GL_RENDERER); - qDebug() << "Renderer" << str; - printf("Renderer %s\n", str); - str = (const char*)glGetString(GL_VERSION); - qDebug() << "Version" << str; - printf("Version %s\n", str); - - str = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); - qDebug() << "Shader version" << str; - - str = (const char*)glGetString(GL_EXTENSIONS); - qDebug() << "Extensions" << str; - printf("Extensions %s\n", str); - - } -#endif -} - -void QEglContext::doneCurrent() +QEglFSIntegration::QEglFSIntegration() { -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglContext::doneCurrent\n"); -#endif - if (!eglMakeCurrent(m_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) - fprintf(stderr, "Could not release the egl context\n"); -} - -void QEglContext::swapBuffers() -{ -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglContext::swapBuffers\n"); -#endif - eglSwapBuffers(m_dpy, m_surface); -} - -void* QEglContext::getProcAddress(const QString& procName) -{ -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglContext::getProcAddress\n"); -#endif - return (void*)eglGetProcAddress(qPrintable(procName)); -} - - -class QEglPaintDevice; -class QEglScreen : public QPlatformScreen -{ -public: - QEglScreen(); - ~QEglScreen() {} - - 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; } //### - -public: - QRect m_geometry; - int m_depth; - QImage::Format m_format; - //QSize m_physicalSize; - QEglContext * m_platformContext; -}; - - -class QEglWindow : public QPlatformWindow -{ -public: - QEglWindow(QWidget *w, QEglScreen *screen); - QPlatformGLContext *glContext(); - - void setGeometry(const QRect &); - WId winId() const; - - QGLContext *context() { return m_context; } - QEglPaintDevice *paintDevice() { return m_pd; } -private: - QEglScreen *m_screen; - QEglPaintDevice *m_pd; - QGLContext *m_context; - WId m_winid; -}; - -class QEglPaintDevice : public QGLPaintDevice -{ -public: - QEglPaintDevice(QEglScreen *screen, QEglWindow *window); - - QSize size() const { return m_screen->geometry().size(); } - QGLContext* context() const { return m_window->context();} - - QPaintEngine *paintEngine() const { return qt_qgl_paint_engine(); } - - void beginPaint(){ - QGLPaintDevice::beginPaint(); - } -private: - QEglScreen *m_screen; - QEglWindow * m_window; -}; - - - - -QEglScreen::QEglScreen() - : m_depth(16), m_format(QImage::Format_RGB16), m_platformContext(0) -{ -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglScreen %p\n", this); -#endif - QGLFormat format = QGLFormat::defaultFormat(); - m_platformContext = new QEglContext(format); - - - m_geometry = QRect(QPoint(), m_platformContext->size()); - -} - - - - -QEglPaintDevice::QEglPaintDevice(QEglScreen *screen, QEglWindow *window) - :QGLPaintDevice(), m_screen(screen), m_window(window) -{ -#ifdef QEGL_EXTRA_DEBUG - qDebug() << "QEglPaintDevice" << this << screen << window; -#endif -} - - - -QEglWindow::QEglWindow(QWidget *w, QEglScreen *screen) - : QPlatformWindow(w), m_screen(screen), m_pd(0), m_context(0) -{ - static int serialNo = 0; - m_winid = ++serialNo; -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglWindow %p: %p %p 0x%x\n", this, w, screen, uint(m_winid)); -#endif - m_pd = new QEglPaintDevice(screen, this); - m_context = new QGLContext( screen->m_platformContext->format(), w); - m_context->create(); -} - - -void QEglWindow::setGeometry(const QRect &) -{ - // We only support full-screen windows - QRect rect(m_screen->availableGeometry()); - QWindowSystemInterface::handleGeometryChange(this->widget(), rect); - - QPlatformWindow::setGeometry(rect); -} - -WId QEglWindow::winId() const -{ - return m_winid; -} - - - -QPlatformGLContext *QEglWindow::glContext() -{ -#ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglWindow::glContext %p\n", m_screen->m_platformContext); -#endif - Q_ASSERT(m_screen); - return m_screen->m_platformContext; -} - -QEglIntegration::QEglIntegration() -{ - m_primaryScreen = new QEglScreen(); + m_primaryScreen = new QEglFSScreen(EGL_DEFAULT_DISPLAY); mScreens.append(m_primaryScreen); #ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglIntegration\n"); + qWarning("QEglIntegration\n"); #endif } -QPixmapData *QEglIntegration::createPixmapData(QPixmapData::PixelType type) const +QPixmapData *QEglFSIntegration::createPixmapData(QPixmapData::PixelType type) const { #ifdef QEGL_EXTRA_DEBUG - fprintf(stderr, "QEglIntegration::createPixmapData %d\n", type); + qWarning("QEglIntegration::createPixmapData %d\n", type); #endif return new QGLPixmapData(type); } -QPlatformWindow *QEglIntegration::createPlatformWindow(QWidget *widget, WId winId) const +QPlatformWindow *QEglFSIntegration::createPlatformWindow(QWidget *widget, WId winId) const { Q_UNUSED(winId); #ifdef QEGL_EXTRA_DEBUG - qDebug() << "QEglIntegration::createPlatformWindow" << widget; + qWarning("QEglIntegration::createPlatformWindow %p\n",widget); #endif - return new QEglWindow(widget, m_primaryScreen); + return new QEglFSWindow(widget, m_primaryScreen); } -class QEglWindowSurface : public QWindowSurface -{ -public: - QEglWindowSurface(QWidget *window, QEglScreen *screen); - ~QEglWindowSurface() {} - - QPaintDevice *paintDevice() { return m_window->paintDevice(); } - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void resize(const QSize &size) {} -private: - QEglScreen *m_screen; - QEglWindow *m_window; -}; - -QEglWindowSurface::QEglWindowSurface(QWidget *window, QEglScreen *screen) - :QWindowSurface(window), m_screen(screen), m_window(0) -{ -#ifdef QEGL_EXTRA_DEBUG - qDebug() << "QEglWindowSurface" << window << screen; -#endif - m_window = static_cast(window->platformWindow()); -} - - -void QEglWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(region); - Q_UNUSED(offset); -#ifdef QEGL_EXTRA_DEBUG - qDebug() << "QEglWindowSurface::flush"; -#endif - m_screen->m_platformContext->swapBuffers(); -} - -QWindowSurface *QEglIntegration::createWindowSurface(QWidget *widget, WId winId) const +QWindowSurface *QEglFSIntegration::createWindowSurface(QWidget *widget, WId winId) const { Q_UNUSED(winId); #ifdef QEGL_EXTRA_DEBUG - qDebug() << "QEglIntegration::createWindowSurface" << widget; + qWarning("QEglIntegration::createWindowSurface %p\n",widget); #endif - return new QEglWindowSurface(widget, m_primaryScreen); + return new QEglFSWindowSurface(m_primaryScreen,widget); } + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h index 7b9b8cf..f15b6b2 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.h +++ b/src/plugins/platforms/eglfs/qeglfsintegration.h @@ -42,16 +42,19 @@ #ifndef EGLINTEGRATION_H #define EGLINTEGRATION_H +#include "qeglfsscreen.h" + #include #include +QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE -class QEglScreen; -class QEglIntegration : public QPlatformIntegration +class QEglFSIntegration : public QPlatformIntegration { public: - QEglIntegration(); + QEglFSIntegration(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; @@ -61,10 +64,10 @@ public: private: QList mScreens; - QEglScreen *m_primaryScreen; + QEglFSScreen *m_primaryScreen; }; QT_END_NAMESPACE - +QT_END_HEADER #endif diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp new file mode 100644 index 0000000..a390106 --- /dev/null +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qeglfsscreen.h" + +#include "../eglconvenience/qeglconvenience.h" +#include "../eglconvenience/qeglplatformcontext.h" + +#ifdef Q_OPENKODE +#include +#include +#endif //Q_OPENKODE + +QT_BEGIN_NAMESPACE + +#ifdef QEGL_EXTRA_DEBUG +struct AttrInfo { EGLint attr; const char *name; }; +static struct AttrInfo attrs[] = { + {EGL_BUFFER_SIZE, "EGL_BUFFER_SIZE"}, + {EGL_ALPHA_SIZE, "EGL_ALPHA_SIZE"}, + {EGL_BLUE_SIZE, "EGL_BLUE_SIZE"}, + {EGL_GREEN_SIZE, "EGL_GREEN_SIZE"}, + {EGL_RED_SIZE, "EGL_RED_SIZE"}, + {EGL_DEPTH_SIZE, "EGL_DEPTH_SIZE"}, + {EGL_STENCIL_SIZE, "EGL_STENCIL_SIZE"}, + {EGL_CONFIG_CAVEAT, "EGL_CONFIG_CAVEAT"}, + {EGL_CONFIG_ID, "EGL_CONFIG_ID"}, + {EGL_LEVEL, "EGL_LEVEL"}, + {EGL_MAX_PBUFFER_HEIGHT, "EGL_MAX_PBUFFER_HEIGHT"}, + {EGL_MAX_PBUFFER_PIXELS, "EGL_MAX_PBUFFER_PIXELS"}, + {EGL_MAX_PBUFFER_WIDTH, "EGL_MAX_PBUFFER_WIDTH"}, + {EGL_NATIVE_RENDERABLE, "EGL_NATIVE_RENDERABLE"}, + {EGL_NATIVE_VISUAL_ID, "EGL_NATIVE_VISUAL_ID"}, + {EGL_NATIVE_VISUAL_TYPE, "EGL_NATIVE_VISUAL_TYPE"}, + {EGL_SAMPLES, "EGL_SAMPLES"}, + {EGL_SAMPLE_BUFFERS, "EGL_SAMPLE_BUFFERS"}, + {EGL_SURFACE_TYPE, "EGL_SURFACE_TYPE"}, + {EGL_TRANSPARENT_TYPE, "EGL_TRANSPARENT_TYPE"}, + {EGL_TRANSPARENT_BLUE_VALUE, "EGL_TRANSPARENT_BLUE_VALUE"}, + {EGL_TRANSPARENT_GREEN_VALUE, "EGL_TRANSPARENT_GREEN_VALUE"}, + {EGL_TRANSPARENT_RED_VALUE, "EGL_TRANSPARENT_RED_VALUE"}, + {EGL_BIND_TO_TEXTURE_RGB, "EGL_BIND_TO_TEXTURE_RGB"}, + {EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA"}, + {EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL"}, + {EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL"}, + {-1, 0}}; +#endif //QEGL_EXTRA_DEBUG + +QEglFSScreen::QEglFSScreen(EGLNativeDisplayType display) + : m_depth(16), m_format(QImage::Format_RGB16), m_platformContext(0) +{ +#ifdef QEGL_EXTRA_DEBUG + qWarning("QEglScreen %p\n", this); +#endif + + EGLint major, minor; +#ifdef QEGL_EXTRA_DEBUG + EGLint index; +#endif + if (!eglBindAPI(EGL_OPENGL_ES_API)) { + qWarning("Could not bind GL_ES API\n"); + qFatal("EGL error"); + } + + m_dpy = eglGetDisplay(display); + if (m_dpy == EGL_NO_DISPLAY) { + qWarning("Could not open egl display\n"); + qFatal("EGL error"); + } + qWarning("Opened display %p\n", m_dpy); + + if (!eglInitialize(m_dpy, &major, &minor)) { + qWarning("Could not initialize egl display\n"); + qFatal("EGL error"); + } + + qWarning("Initialized display %d %d\n", major, minor); + + QPlatformWindowFormat platformFormat; + platformFormat.setDepth(16); + platformFormat.setWindowApi(QPlatformWindowFormat::OpenGL); + platformFormat.setRedBufferSize(8); + platformFormat.setGreenBufferSize(8); + platformFormat.setBlueBufferSize(8); + EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat); + + EGLNativeWindowType eglWindow = 0; +#ifdef Q_OPENKODE + if (kdInitializeNV() == KD_ENOTINITIALIZED) { + qFatal("Did not manage to initialize openkode"); + } + KDWindow *window = kdCreateWindow(m_dpy,config,0); + + kdRealizeWindow(window,&eglWindow); +#endif + + m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL); + if (m_surface == EGL_NO_SURFACE) { + qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError()); + eglTerminate(m_dpy); + qFatal("EGL error"); + } + // qWarning("Created surface %dx%d\n", w, h); + +#ifdef QEGL_EXTRA_DEBUG + qWarning("Configuration %d matches requirements\n", (int)config); + + for (index = 0; attrs[index].attr != -1; ++index) { + EGLint value; + if (eglGetConfigAttrib(m_dpy, config, attrs[index].attr, &value)) { + qWarning("\t%s: %d\n", attrs[index].name, (int)value); + } + } + qWarning("\n"); +#endif + + EGLint temp; + EGLint attribList[32]; + + temp = 0; + + attribList[temp++] = EGL_CONTEXT_CLIENT_VERSION; + attribList[temp++] = 2; // GLES version 2 + attribList[temp++] = EGL_NONE; + + m_platformContext = new QEGLPlatformContext(m_dpy,config,attribList,m_surface,EGL_OPENGL_ES_API); + +// qWarning("Created platformcontext"); + EGLint w,h; + + eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w); + eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h); + + m_geometry = QRect(0,0,w,h); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h new file mode 100644 index 0000000..f68ab14 --- /dev/null +++ b/src/plugins/platforms/eglfs/qeglfsscreen.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QEGLSCREEN_H +#define QEGLSCREEN_H + +#include + + +#include + +QT_BEGIN_NAMESPACE + +class QPlatformGLContext; + +class QEglFSScreen : public QPlatformScreen //huh: FullScreenScreen ;) just to follow namespace +{ +public: + QEglFSScreen(EGLNativeDisplayType display); + ~QEglFSScreen() {} + + QRect geometry() const { return m_geometry; } + int depth() const { return m_depth; } + QImage::Format format() const { return m_format; } + + QPlatformGLContext *platformContext() const { return m_platformContext; } + +private: + QRect m_geometry; + int m_depth; + QImage::Format m_format; + QPlatformGLContext *m_platformContext; + EGLDisplay m_dpy; + EGLSurface m_surface; +}; + +QT_END_NAMESPACE +#endif // QEGLSCREEN_H diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp new file mode 100644 index 0000000..db15862 --- /dev/null +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qeglfswindow.h" + +#include + +QT_BEGIN_NAMESPACE + +QEglFSWindow::QEglFSWindow(QWidget *w, QEglFSScreen *screen) + : QPlatformWindow(w), m_screen(screen) +{ + static int serialNo = 0; + m_winid = ++serialNo; +#ifdef QEGL_EXTRA_DEBUG + qWarning("QEglWindow %p: %p %p 0x%x\n", this, w, screen, uint(m_winid)); +#endif +} + + +void QEglFSWindow::setGeometry(const QRect &) +{ + // We only support full-screen windows + QRect rect(m_screen->availableGeometry()); + QWindowSystemInterface::handleGeometryChange(this->widget(), rect); + + QPlatformWindow::setGeometry(rect); +} + +WId QEglFSWindow::winId() const +{ + return m_winid; +} + + + +QPlatformGLContext *QEglFSWindow::glContext() +{ +#ifdef QEGL_EXTRA_DEBUG + qWarning("QEglWindow::glContext %p\n", m_screen->platformContext()); +#endif + Q_ASSERT(m_screen); + return m_screen->platformContext(); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h new file mode 100644 index 0000000..f605cf4 --- /dev/null +++ b/src/plugins/platforms/eglfs/qeglfswindow.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QEGLWINDOW_H +#define QEGLWINDOW_H + +#include "qeglfsintegration.h" +#include "qeglfsscreen.h" + + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class QEglFSWindow : public QPlatformWindow +{ +public: + QEglFSWindow(QWidget *w, QEglFSScreen *screen); + QPlatformGLContext *glContext(); + + void setGeometry(const QRect &); + WId winId() const; + +private: + QEglFSScreen *m_screen; + WId m_winid; +}; +QT_END_NAMESPACE +#endif // QEGLWINDOW_H diff --git a/src/plugins/platforms/eglfs/qeglfswindowsurface.cpp b/src/plugins/platforms/eglfs/qeglfswindowsurface.cpp new file mode 100644 index 0000000..a613dda --- /dev/null +++ b/src/plugins/platforms/eglfs/qeglfswindowsurface.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qeglfswindowsurface.h" + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QEglFSPaintDevice : public QGLPaintDevice +{ +public: + QEglFSPaintDevice(QEglFSScreen *screen, QWidget *widget) + :QGLPaintDevice(), m_screen(screen) + { + #ifdef QEGL_EXTRA_DEBUG + qWarning("QEglPaintDevice %p, %p, %p",this, screen, widget); + #endif + QGLFormat format; + m_context = new QGLContext(format, widget); + m_context->create(); + } + + QSize size() const { return m_screen->geometry().size(); } + QGLContext* context() const { return m_context;} + + QPaintEngine *paintEngine() const { return qt_qgl_paint_engine(); } + + void beginPaint(){ + QGLPaintDevice::beginPaint(); + } +private: + QEglFSScreen *m_screen; + QGLContext *m_context; +}; + + +QEglFSWindowSurface::QEglFSWindowSurface( QEglFSScreen *screen, QWidget *window ) + :QWindowSurface(window) +{ +#ifdef QEGL_EXTRA_DEBUG + qWarning("QEglWindowSurface %p, %p", window, screen); +#endif + m_paintDevice = new QEglFSPaintDevice(screen,window); +} + +void QEglFSWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); +#ifdef QEGL_EXTRA_DEBUG + qWarning("QEglWindowSurface::flush %p",widget); +#endif + widget->platformWindow()->glContext()->swapBuffers(); +} + +void QEglFSWindowSurface::resize(const QSize &size) +{ + Q_UNUSED(size); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfswindowsurface.h b/src/plugins/platforms/eglfs/qeglfswindowsurface.h new file mode 100644 index 0000000..571b9bd --- /dev/null +++ b/src/plugins/platforms/eglfs/qeglfswindowsurface.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QEGLWINDOWSURFACE_H +#define QEGLWINDOWSURFACE_H + +#include "qeglfsintegration.h" +#include "qeglfswindow.h" + +#include + +QT_BEGIN_NAMESPACE + +class QEglFSWindowSurface : public QWindowSurface +{ +public: + QEglFSWindowSurface(QEglFSScreen *screen, QWidget *window); + ~QEglFSWindowSurface() {} + + QPaintDevice *paintDevice() { return m_paintDevice; } + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void resize(const QSize &size); +private: + QPaintDevice *m_paintDevice; +}; + +QT_END_NAMESPACE + +#endif // QEGLWINDOWSURFACE_H -- cgit v0.12 From c984a856ccf72731da052ff8bdae88fe3921fc83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 27 Jul 2010 08:30:58 +0200 Subject: Add QT_BEGIN_NAMESPACE and QT_BEGIN_HEADER to openkode plugin --- src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp | 4 +++- src/plugins/platforms/openkode/qopenkodeeventloopintegration.h | 7 +++++++ src/plugins/platforms/openkode/qopenkodeintegration.h | 2 ++ src/plugins/platforms/openkode/qopenkodewindow.cpp | 3 ++- src/plugins/platforms/openkode/qopenkodewindow.h | 6 ++++++ src/plugins/platforms/openkode/qopenkodewindowsurface.h | 2 ++ 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp index 467b5b5..e21e1d7 100644 --- a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp @@ -2,7 +2,7 @@ #include -#include +QT_BEGIN_NAMESPACE QOpenKODEEventLoopIntegration::QOpenKODEEventLoopIntegration() { @@ -27,3 +27,5 @@ void QOpenKODEEventLoopIntegration::wakeup() KDEvent *event = kdCreateEvent(); kdPostThreadEvent(event,m_kdThread); } + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h index ef04640..868eda8 100644 --- a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h @@ -4,6 +4,10 @@ #include class KDThread; + +QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + class QOpenKODEEventLoopIntegration : public QPlatformEventLoopIntegration { public: @@ -14,4 +18,7 @@ private: KDThread *m_kdThread; }; +QT_END_NAMESPACE +QT_END_HEADER + #endif // QOPENKODEEVENTLOOPINTEGRATION_H diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h index 0eaf127..8d3d175 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeintegration.h @@ -51,6 +51,7 @@ #include #include +QT_BEGIN_HEADER QT_BEGIN_NAMESPACE struct KDDesktopNV; @@ -98,5 +99,6 @@ private: }; QT_END_NAMESPACE +QT_END_HEADER #endif diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index faba2fb..2ad9238 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -55,7 +55,7 @@ #include #include - +QT_BEGIN_NAMESPACE QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) : QPlatformWindow(tlw) @@ -173,3 +173,4 @@ QPlatformGLContext *QOpenKODEWindow::glContext() { return m_platformGlContext; } +QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qopenkodewindow.h b/src/plugins/platforms/openkode/qopenkodewindow.h index 51252a9..d11c0d8 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.h +++ b/src/plugins/platforms/openkode/qopenkodewindow.h @@ -47,6 +47,9 @@ #include +QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + class QEGLPlatformContext; class QOpenKODEWindow : public QPlatformWindow @@ -71,4 +74,7 @@ private: QEGLPlatformContext *m_platformGlContext; }; +QT_END_NAMESPACE +QT_END_HEADER + #endif //QOPENKODEWINDOW_H diff --git a/src/plugins/platforms/openkode/qopenkodewindowsurface.h b/src/plugins/platforms/openkode/qopenkodewindowsurface.h index 4acd1d8..f12b625 100644 --- a/src/plugins/platforms/openkode/qopenkodewindowsurface.h +++ b/src/plugins/platforms/openkode/qopenkodewindowsurface.h @@ -46,6 +46,7 @@ #include +QT_BEGIN_HEADER QT_BEGIN_NAMESPACE class QOpenKODEWindow; @@ -71,5 +72,6 @@ private: }; QT_END_NAMESPACE +QT_END_HEADER #endif -- cgit v0.12 From e7c239407698f2a5d4f4b4000ecdd5969025fe1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 27 Jul 2010 08:32:57 +0200 Subject: Made QPlatformWidnow::glContext a const function --- src/gui/kernel/qplatformwindow_qpa.cpp | 2 +- src/gui/kernel/qplatformwindow_qpa.h | 2 +- src/plugins/platforms/eglfs/qeglfswindow.cpp | 2 +- src/plugins/platforms/eglfs/qeglfswindow.h | 3 ++- src/plugins/platforms/openkode/qopenkodewindow.cpp | 2 +- src/plugins/platforms/openkode/qopenkodewindow.h | 2 +- src/plugins/platforms/testlite/qglxintegration.cpp | 2 +- src/plugins/platforms/testlite/qtestlitewindow.cpp | 11 +++-------- src/plugins/platforms/testlite/qtestlitewindow.h | 3 +-- 9 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp index 4cd8ead..4ac4736 100644 --- a/src/gui/kernel/qplatformwindow_qpa.cpp +++ b/src/gui/kernel/qplatformwindow_qpa.cpp @@ -120,7 +120,7 @@ void QPlatformWindow::setOpacity(qreal level) qWarning("This plugin does not support setting window opacity"); } -QPlatformGLContext *QPlatformWindow::glContext() +QPlatformGLContext *QPlatformWindow::glContext() const { return 0; } diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h index e8b5ad8..2275c02 100644 --- a/src/gui/kernel/qplatformwindow_qpa.h +++ b/src/gui/kernel/qplatformwindow_qpa.h @@ -79,7 +79,7 @@ public: virtual void setOpacity(qreal level); - virtual QPlatformGLContext *glContext(); + virtual QPlatformGLContext *glContext() const; protected: QScopedPointer d_ptr; private: diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index db15862..86cc98b 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -71,7 +71,7 @@ WId QEglFSWindow::winId() const -QPlatformGLContext *QEglFSWindow::glContext() +QPlatformGLContext *QEglFSWindow::glContext() const { #ifdef QEGL_EXTRA_DEBUG qWarning("QEglWindow::glContext %p\n", m_screen->platformContext()); diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h index f605cf4..0c3bc84 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.h +++ b/src/plugins/platforms/eglfs/qeglfswindow.h @@ -56,11 +56,12 @@ class QEglFSWindow : public QPlatformWindow { public: QEglFSWindow(QWidget *w, QEglFSScreen *screen); - QPlatformGLContext *glContext(); void setGeometry(const QRect &); WId winId() const; + QPlatformGLContext *glContext() const; + private: QEglFSScreen *m_screen; WId m_winid; diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index 2ad9238..81f38d2 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -169,7 +169,7 @@ void QOpenKODEWindow::setVisible(bool visible) } } -QPlatformGLContext *QOpenKODEWindow::glContext() +QPlatformGLContext *QOpenKODEWindow::glContext() const { return m_platformGlContext; } diff --git a/src/plugins/platforms/openkode/qopenkodewindow.h b/src/plugins/platforms/openkode/qopenkodewindow.h index d11c0d8..3e7ee56 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.h +++ b/src/plugins/platforms/openkode/qopenkodewindow.h @@ -62,7 +62,7 @@ public: void setVisible(bool visible); WId winId() const { return WId(m_eglWindow); } - QPlatformGLContext *glContext(); + QPlatformGLContext *glContext() const; private: struct KDWindow *m_kdWindow; diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index 4d807b0..e554e8d 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -181,7 +181,7 @@ QGLXGLContext::QGLXGLContext(MyDisplay *display, Drawable drawable, GLXContext c QGLXGLContext::~QGLXGLContext() { if (m_context) { - qDebug("Destroying GLX context 0x%x", m_context); + qDebug("Destroying GLX context 0x%p", m_context); glXDestroyContext(m_xd->display, m_context); } } diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index f774458..67ec97c 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -1011,20 +1011,15 @@ void QTestLiteWindow::setCursor(QCursor * cursor) XFlush(xd->display); } -QPlatformGLContext *QTestLiteWindow::glContext() +QPlatformGLContext *QTestLiteWindow::glContext() const { if (!mGLContext) { - mGLContext = createGLContext(); + QTestLiteWindow *that = const_cast(this); + that->mGLContext = new QGLXGLContext(x_window, xd, widget()->platformWindowFormat()); } return mGLContext; } -QPlatformGLContext *QTestLiteWindow::createGLContext() -{ - QPlatformGLContext *context = new QGLXGLContext(x_window, xd, widget()->platformWindowFormat()); - return context; -} - Cursor QTestLiteWindow::createCursorBitmap(QCursor * cursor) { XColor bg, fg; diff --git a/src/plugins/platforms/testlite/qtestlitewindow.h b/src/plugins/platforms/testlite/qtestlitewindow.h index d405578..dc628f1 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.h +++ b/src/plugins/platforms/testlite/qtestlitewindow.h @@ -127,7 +127,7 @@ public: void setCursor(QCursor * cursor); - QPlatformGLContext *glContext(); + QPlatformGLContext *glContext() const; private: int xpos, ypos; @@ -138,7 +138,6 @@ private: GC createGC(); Cursor createCursorShape(int cshape); Cursor createCursorBitmap(QCursor * cursor); - QPlatformGLContext *createGLContext(); int currentCursor; -- cgit v0.12 From 24322b3d6b1e7b33f936081a2dcaa3d62c9b501f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 28 Jul 2010 12:17:53 +0200 Subject: Fix so that eventloop intgration can have 0 timeouts --- src/gui/kernel/qeventdispatcher_qpa.cpp | 4 +++- src/gui/kernel/qwindowsysteminterface_qpa.h | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qeventdispatcher_qpa.cpp b/src/gui/kernel/qeventdispatcher_qpa.cpp index 4464036..cb70141 100644 --- a/src/gui/kernel/qeventdispatcher_qpa.cpp +++ b/src/gui/kernel/qeventdispatcher_qpa.cpp @@ -255,7 +255,9 @@ int QEventDispatcherQPA::select(int nfds, fd_set *readfds, fd_set *writefds, fd_ Q_D(QEventDispatcherQPA); int retVal = 0; if (d->hasIntegration()) { - qint64 timeoutmsec = timeout->tv_sec * 1000 + (timeout->tv_usec/1000); + qint64 timeoutmsec = 0; + if (timeout) + timeoutmsec = timeout->tv_sec * 1000 + (timeout->tv_usec/1000); d->selectReturnMutex->lock(); if (d->selectWorkerNeedsSync) { if (d->selectWorkerHasResult) { diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h index e57fa8e..5ff4275 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa.h @@ -79,7 +79,6 @@ public: static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points); static void handleTouchEvent(QWidget *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points); - // delivered directly by the plugin via spontaneous events static void handleGeometryChange(QWidget *w, const QRect &newRect); static void handleCloseEvent(QWidget *w); static void handleEnterEvent(QWidget *w); -- cgit v0.12 From da0d594f7d1b01145c5ec47f36d039435e04e7a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 2 Aug 2010 12:05:20 +0200 Subject: Make eglfs use defaultsharedcontext --- src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp | 5 +++++ src/plugins/platforms/eglconvenience/qeglplatformcontext.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp index a72f7b2..b3a5bba 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp @@ -137,3 +137,8 @@ void* QEGLPlatformContext::getProcAddress(const QString& procName) eglBindAPI(m_eglApi); return (void *)eglGetProcAddress(qPrintable(procName)); } + +void QEGLPlatformContext::makeDefaultSaredContext() +{ + setDefaultSharedContext(this); +} diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h index 19d155a..2a49129 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h @@ -56,6 +56,7 @@ public: void swapBuffers(); void* getProcAddress(const QString& procName); + void makeDefaultSaredContext(); private: EGLContext m_eglContext; EGLDisplay m_eglDisplay; -- cgit v0.12 From 6e0edcce4c215f01416a5ee8467b7abe4665e592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 2 Aug 2010 12:07:12 +0200 Subject: Make openkode plugin handle events And make it also work without a gui manager --- src/gui/kernel/qapplication_qpa.cpp | 3 + src/gui/kernel/qplatformwindow_qpa.cpp | 9 +- src/gui/kernel/qwidget_qpa.cpp | 3 + src/plugins/platforms/openkode/openkode.pro | 5 +- .../platforms/openkode/openkodekeytranslator.h | 244 +++++++++++++++++++++ .../openkode/qopenkodeeventloopintegration.cpp | 47 ++++ .../openkode/qopenkodeeventloopintegration.h | 4 + .../platforms/openkode/qopenkodeintegration.cpp | 23 +- .../platforms/openkode/qopenkodeintegration.h | 13 +- src/plugins/platforms/openkode/qopenkodewindow.cpp | 191 +++++++++++++--- src/plugins/platforms/openkode/qopenkodewindow.h | 9 +- .../platforms/openkode/qopenkodewindowsurface.cpp | 176 --------------- .../platforms/openkode/qopenkodewindowsurface.h | 77 ------- 13 files changed, 508 insertions(+), 296 deletions(-) create mode 100644 src/plugins/platforms/openkode/openkodekeytranslator.h delete mode 100644 src/plugins/platforms/openkode/qopenkodewindowsurface.cpp delete mode 100644 src/plugins/platforms/openkode/qopenkodewindowsurface.h diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index e5b5396..b89e81d 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -802,6 +802,9 @@ void QApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEven if (app_do_modal && !qt_try_modal(focusW, e->keyType)) return; + if (!focusW->isWindow()) + focusW = focusW->window(); + modifiers = e->modifiers; QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount); QApplication::sendSpontaneousEvent(focusW, &ev); diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp index 4ac4736..9d722d8 100644 --- a/src/gui/kernel/qplatformwindow_qpa.cpp +++ b/src/gui/kernel/qplatformwindow_qpa.cpp @@ -47,6 +47,7 @@ class QPlatformWindowPrivate { QWidget *tlw; QRect rect; + Qt::WindowFlags flags; friend class QPlatformWindow; }; @@ -92,8 +93,9 @@ Requests setting the window flags of this surface to \a type. Returns the actual */ Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags) { - Q_UNUSED(flags); - return Qt::Window; + Q_D(QPlatformWindow); + d->flags = flags; + return flags; } /*! @@ -101,7 +103,8 @@ Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags) */ Qt::WindowFlags QPlatformWindow::windowFlags() const { - return Qt::Window; + Q_D(const QPlatformWindow); + return d->flags; } WId QPlatformWindow::winId() const { return WId(0); } diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index 3584f87..ef53004 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -63,6 +63,7 @@ void setParentForChildrenOfWidget(QPlatformWindow *window, const QWidget *widget if (childWidget) { // should not be necessary if (childWidget->platformWindow()) { childWidget->platformWindow()->setParent(window); + childWidget->platformWindow()->setWindowFlags(Qt::SubWindow); } else { setParentForChildrenOfWidget(window,childWidget); } @@ -106,6 +107,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO if (QWidget *nativeParent = q->nativeParentWidget()) { if (nativeParent->platformWindow()) { platformWindow->setParent(nativeParent->platformWindow()); + platformWindow->setWindowFlags(Qt::SubWindow); } } @@ -174,6 +176,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) QWidget * parentWithWindow = newparent->platformWindow()? newparent : newparent->nativeParentWidget(); if (parentWithWindow && parentWithWindow->platformWindow()) { q->platformWindow()->setParent(parentWithWindow->platformWindow()); + q->platformWindow()->setWindowFlags(Qt::SubWindow); } } diff --git a/src/plugins/platforms/openkode/openkode.pro b/src/plugins/platforms/openkode/openkode.pro index 2d90b15..5f2c1cc 100644 --- a/src/plugins/platforms/openkode/openkode.pro +++ b/src/plugins/platforms/openkode/openkode.pro @@ -7,18 +7,17 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms SOURCES = main.cpp \ qopenkodeintegration.cpp \ - qopenkodewindowsurface.cpp \ qopenkodewindow.cpp \ ../eglconvenience/qeglplatformcontext.cpp \ ../eglconvenience/qeglconvenience.cpp \ qopenkodeeventloopintegration.cpp HEADERS = qopenkodeintegration.h \ - qopenkodewindowsurface.h \ qopenkodewindow.h \ ../eglconvenience/qeglplatformcontext.h \ ../eglconvenience/qeglconvenience.h \ - qopenkodeeventloopintegration.h + qopenkodeeventloopintegration.h \ + openkodekeytranslator.h RESOURCES = resources.qrc diff --git a/src/plugins/platforms/openkode/openkodekeytranslator.h b/src/plugins/platforms/openkode/openkodekeytranslator.h new file mode 100644 index 0000000..e0ba5c1 --- /dev/null +++ b/src/plugins/platforms/openkode/openkodekeytranslator.h @@ -0,0 +1,244 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef OPENKODEKEYTRANSLATOR_H +#define OPENKODEKEYTRANSLATOR_H + +#ifdef KD_ATX_keyboard + +#include + +QT_BEGIN_NAMESPACE + +Qt::Key keyTranslator( int key ) +{ + switch (key) { +// KD_KEY_ACCEPT_ATX: +// KD_KEY_AGAIN_ATX: +// KD_KEY_ALLCANDIDATES_ATX +// KD_KEY_ALPHANUMERIC_ATX + case KD_KEY_ALT_ATX: + return Qt::Key_Alt; + case KD_KEY_ALTGRAPH_ATX: + return Qt::Key_AltGr; +// KD_KEY_APPS_ATX +// KD_KEY_ATTN_ATX +// KD_KEY_BROWSERBACK_ATX +// KD_KEY_BROWSERFAVORITES_ATX +// KD_KEY_BROWSERFORWARD_ATX +// KD_KEY_BROWSERHOME_ATX +// KD_KEY_BROWSERREFRESH_ATX +// KD_KEY_BROWSERSEARCH_ATX +// KD_KEY_BROWSERSTOP_ATX + case KD_KEY_CAPSLOCK_ATX: + return Qt::Key_CapsLock; + case KD_KEY_CLEAR_ATX: + return Qt::Key_Clear; + case KD_KEY_CODEINPUT_ATX: + return Qt::Key_Codeinput; +// KD_KEY_COMPOSE_ATX + case KD_KEY_CONTROL_ATX: + return Qt::Key_Control; +// KD_KEY_CRSEL_ATX +// KD_KEY_CONVERT_ATX + case KD_KEY_COPY_ATX: + return Qt::Key_Copy; + case KD_KEY_CUT_ATX: + return Qt::Key_Cut; + case KD_KEY_DOWN_ATX: + return Qt::Key_Down; + case KD_KEY_END_ATX: + return Qt::Key_End; + case KD_KEY_ENTER_ATX: + return Qt::Key_Enter; +// KD_KEY_ERASEEOF_ATX +// KD_KEY_EXECUTE_ATX +// KD_KEY_EXSEL_ATX + case KD_KEY_F1_ATX: + return Qt::Key_F1; + case KD_KEY_F2_ATX: + return Qt::Key_F2; + case KD_KEY_F3_ATX: + return Qt::Key_F3; + case KD_KEY_F4_ATX: + return Qt::Key_F4; + case KD_KEY_F5_ATX: + return Qt::Key_F5; + case KD_KEY_F6_ATX: + return Qt::Key_F6; + case KD_KEY_F7_ATX: + return Qt::Key_F7; + case KD_KEY_F8_ATX: + return Qt::Key_F8; + case KD_KEY_F9_ATX: + return Qt::Key_F9; + case KD_KEY_F10_ATX: + return Qt::Key_F10; + case KD_KEY_F11_ATX: + return Qt::Key_F11; + case KD_KEY_F12_ATX: + return Qt::Key_F12; + case KD_KEY_F13_ATX: + return Qt::Key_F13; + case KD_KEY_F14_ATX: + return Qt::Key_F14; + case KD_KEY_F15_ATX: + return Qt::Key_F15; + case KD_KEY_F16_ATX: + return Qt::Key_F16; + case KD_KEY_F17_ATX: + return Qt::Key_F17; + case KD_KEY_F18_ATX: + return Qt::Key_F18; + case KD_KEY_F19_ATX: + return Qt::Key_F19; + case KD_KEY_F20_ATX: + return Qt::Key_F20; + case KD_KEY_F21_ATX: + return Qt::Key_F21; + case KD_KEY_F22_ATX: + return Qt::Key_F22; + case KD_KEY_F23_ATX: + return Qt::Key_F23; + case KD_KEY_F24_ATX: + return Qt::Key_F24; +// KD_KEY_FINALMODE_ATX +// KD_KEY_FIND_ATX +// KD_KEY_FULLWIDTH_ATX +// KD_KEY_HALFWIDTH_ATX + case KD_KEY_HANGULMODE_ATX: + return Qt::Key_Hangul; +// KD_KEY_HANJAMODE_ATX + case KD_KEY_HELP_ATX: + return Qt::Key_Help; + case KD_KEY_HIRAGANA_ATX: + return Qt::Key_Hiragana; + case KD_KEY_HOME_ATX: + return Qt::Key_Home; + case KD_KEY_INSERT_ATX: + return Qt::Key_Insert; +// KD_KEY_JAPANESEHIRAGANA_ATX: +// KD_KEY_JAPANESEKATAKANA_ATX +// KD_KEY_JAPANESEROMAJI_ATX +// KD_KEY_JUNJAMODE_ATX + case KD_KEY_KANAMODE_ATX: + return Qt::Key_Kana_Lock; //? + case KD_KEY_KANJIMODE_ATX: + return Qt::Key_Kanji; +// KD_KEY_KATAKANA_ATX +// KD_KEY_LAUNCHAPPLICATION1_ATX +// KD_KEY_LAUNCHAPPLICATION2_ATX + case KD_KEY_LAUNCHMAIL_ATX: + return Qt::Key_MailForward; + case KD_KEY_LEFT_ATX: + return Qt::Key_Left; + case KD_KEY_META_ATX: + return Qt::Key_Meta; + case KD_KEY_MEDIANEXTTRACK_ATX: + return Qt::Key_MediaNext; + case KD_KEY_MEDIAPLAYPAUSE_ATX: + return Qt::Key_MediaPause; + case KD_KEY_MEDIAPREVIOUSTRACK_ATX: + return Qt::Key_MediaPrevious; + case KD_KEY_MEDIASTOP_ATX: + return Qt::Key_MediaStop; + case KD_KEY_MODECHANGE_ATX: + return Qt::Key_Mode_switch; +// KD_KEY_NONCONVERT_ATX + case KD_KEY_NUMLOCK_ATX: + return Qt::Key_NumLock; + case KD_KEY_PAGEDOWN_ATX: + return Qt::Key_PageDown; + case KD_KEY_PAGEUP_ATX: + return Qt::Key_PageUp; + case KD_KEY_PASTE_ATX: + return Qt::Key_Paste; + case KD_KEY_PAUSE_ATX: + return Qt::Key_Pause; + case KD_KEY_PLAY_ATX: + return Qt::Key_Play; +// KD_KEY_PREVIOUSCANDIDATE_ATX + case KD_KEY_PRINTSCREEN_ATX: + return Qt::Key_Print; +// case KD_KEY_PROCESS_ATX +// case KD_KEY_PROPS_ATX + case KD_KEY_RIGHT_ATX: + return Qt::Key_Right; +// KD_KEY_ROMANCHARACTERS_ATX + case KD_KEY_SCROLL_ATX: + return Qt::Key_ScrollLock; + case KD_KEY_SELECT_ATX: + return Qt::Key_Select; +// KD_KEY_SELECTMEDIA_ATX + case KD_KEY_SHIFT_ATX: + return Qt::Key_Shift; + case KD_KEY_STOP_ATX: + return Qt::Key_Stop; + case KD_KEY_UP_ATX: + return Qt::Key_Up; +// KD_KEY_UNDO_ATX + case KD_KEY_VOLUMEDOWN_ATX: + return Qt::Key_VolumeDown; + case KD_KEY_VOLUMEMUTE_ATX: + return Qt::Key_VolumeMute; + case KD_KEY_VOLUMEUP_ATX: + return Qt::Key_VolumeUp; + case KD_KEY_WIN_ATX: + return Qt::Key_Meta; + case KD_KEY_ZOOM_ATX: + return Qt::Key_Zoom; + case 0x8: + return Qt::Key_Backspace; + case 0x1b: + return Qt::Key_Escape; + case 0x9: + return Qt::Key_Tab; + + default: + break; + } + + return Qt::Key_Escape; +} + +QT_END_NAMESPACE +#endif //KD_ATX_keyboard +#endif // OPENKODEKEYTRANSLATOR_H diff --git a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp index e21e1d7..bc92d0e 100644 --- a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp @@ -1,12 +1,57 @@ #include "qopenkodeeventloopintegration.h" +#include + #include +#include QT_BEGIN_NAMESPACE +static const int QT_EVENT_WAKEUP_EVENTLOOP = KD_EVENT_USER + 1; + +void kdprocessevent( const KDEvent *event) +{ + switch (event->type) { + case KD_EVENT_INPUT: + qDebug() << "KD_EVENT_INPUT"; + break; + case KD_EVENT_INPUT_POINTER: + qDebug() << "KD_EVENT_INPUT_POINTER"; + break; + case KD_EVENT_WINDOW_CLOSE: + qDebug() << "KD_EVENT_WINDOW_CLOSE"; + break; + case KD_EVENT_WINDOWPROPERTY_CHANGE: + qDebug() << "KD_EVENT_WINDOWPROPERTY_CHANGE"; + qDebug() << event->data.windowproperty.pname; + break; + case KD_EVENT_WINDOW_FOCUS: + qDebug() << "KD_EVENT_WINDOW_FOCUS"; + break; + case KD_EVENT_WINDOW_REDRAW: + qDebug() << "KD_EVENT_WINDOW_REDRAW"; + break; + case KD_EVENT_USER: + qDebug() << "KD_EVENT_USER"; + break; + case KD_EVENT_INPUT_KEY_ATX: + qDebug() << "KD_EVENT_INPUT_KEY_ATX"; + break; + case QT_EVENT_WAKEUP_EVENTLOOP: +// qDebug() << "QT_EVENT_WAKEUP_EVENTLOOP"; + break; + default: + break; + } + + kdDefaultEvent(event); + +} + QOpenKODEEventLoopIntegration::QOpenKODEEventLoopIntegration() { m_kdThread = kdThreadSelf(); + kdInstallCallback(&kdprocessevent,QT_EVENT_WAKEUP_EVENTLOOP,this); } void QOpenKODEEventLoopIntegration::processEvents(qint64 msec) @@ -25,6 +70,8 @@ void QOpenKODEEventLoopIntegration::processEvents(qint64 msec) void QOpenKODEEventLoopIntegration::wakeup() { KDEvent *event = kdCreateEvent(); + event->type = QT_EVENT_WAKEUP_EVENTLOOP; + event->userptr = this; kdPostThreadEvent(event,m_kdThread); } diff --git a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h index 868eda8..03f800c 100644 --- a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h @@ -4,6 +4,7 @@ #include class KDThread; +class KDEvent; QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -14,7 +15,10 @@ public: QOpenKODEEventLoopIntegration(); void processEvents(qint64 msec); void wakeup(); + + void processInputEvent(const KDEvent *event); private: + KDThread *m_kdThread; }; diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index 5dada28..8fc3862 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -40,7 +40,6 @@ ****************************************************************************/ #include "qopenkodeintegration.h" -#include "qopenkodewindowsurface.h" #include "qopenkodewindow.h" #include "qopenkodeeventloopintegration.h" @@ -67,6 +66,7 @@ QT_BEGIN_NAMESPACE QOpenKODEScreen::QOpenKODEScreen() + : mIsFullScreen(false) { KDDesktopNV *kdDesktop = KD_NULL; KDDisplayNV *kdDisplay = KD_NULL; @@ -130,12 +130,13 @@ QOpenKODEScreen::QOpenKODEScreen() qErrnoWarning("EGL failed to initialize display"); } - const int defaultDpi = 72; - mGeometry = QRect(0, 0, mode.width, mode.height); - mPhysicalSize = QSize(mode.width * 25.4 / defaultDpi, mode.height * 25.4 / defaultDpi); +// cursor = new QOpenKODECursor(this); + mGeometry = QRect(0, 0, mode.width, mode.height); mDepth = 24; mFormat = QImage::Format_RGB32; + + } static GLuint loadShaders(const QString &vertexShader, const QString &fragmentShader) @@ -186,6 +187,7 @@ static GLuint loadShaders(const QString &vertexShader, const QString &fragmentSh } QOpenKODEIntegration::QOpenKODEIntegration() + : mEventLoopIntegration(0) { if (kdInitializeNV() == KD_ENOTINITIALIZED) { qFatal("Did not manage to initialize openkode"); @@ -195,6 +197,10 @@ QOpenKODEIntegration::QOpenKODEIntegration() mScreens.append(mPrimaryScreen); } +QOpenKODEIntegration::~QOpenKODEIntegration() +{ + delete mEventLoopIntegration; +} QPixmapData *QOpenKODEIntegration::createPixmapData(QPixmapData::PixelType type) const { @@ -212,9 +218,6 @@ QWindowSurface *QOpenKODEIntegration::createWindowSurface(QWidget *widget, WId w switch (widget->platformWindowFormat().windowApi()) { case QPlatformWindowFormat::Raster: - returnSurface = new QOpenKODEWindowSurface(widget, wid); - break; - case QPlatformWindowFormat::OpenGL: returnSurface = new QGLWindowSurface(widget); break; @@ -238,7 +241,11 @@ bool QOpenKODEIntegration::hasOpenGL() const QPlatformEventLoopIntegration *QOpenKODEIntegration::createEventLoopIntegration() const { - return new QOpenKODEEventLoopIntegration; + if (!mEventLoopIntegration) { + QOpenKODEIntegration *that = const_cast(this); + that->mEventLoopIntegration = new QOpenKODEEventLoopIntegration; + } + return mEventLoopIntegration; } GLuint QOpenKODEIntegration::blitterProgram() diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h index 8d3d175..454aa90 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeintegration.h @@ -42,6 +42,8 @@ #ifndef QGRAPHICSSYSTEM_OPENKODE_H #define QGRAPHICSSYSTEM_OPENKODE_H +#include "qopenkodeeventloopintegration.h" + #include #include @@ -55,6 +57,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE struct KDDesktopNV; +class QOpenKODECursor; class QOpenKODEScreen : public QPlatformScreen { @@ -66,21 +69,24 @@ public: QRect geometry() const { return mGeometry; } int depth() const { return mDepth; } QImage::Format format() const { return mFormat; } - QSize physicalSize() const { return mPhysicalSize; } EGLDisplay eglDisplay() { return mEglDisplay; } -public: + + bool isFullScreen() const {return mIsFullScreen;} + void setFullScreen(bool fullscreen) { mIsFullScreen = fullscreen; } +private: QRect mGeometry; int mDepth; QImage::Format mFormat; - QSize mPhysicalSize; EGLDisplay mEglDisplay; + bool mIsFullScreen; }; class QOpenKODEIntegration : public QPlatformIntegration { public: QOpenKODEIntegration(); + ~QOpenKODEIntegration(); QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; @@ -96,6 +102,7 @@ public: private: QList mScreens; + QOpenKODEEventLoopIntegration *mEventLoopIntegration; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index 81f38d2..c890641 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -45,6 +45,10 @@ #include #include +#include +#ifdef KD_ATX_keyboard +#include "openkodekeytranslator.h" +#endif #include @@ -57,6 +61,20 @@ QT_BEGIN_NAMESPACE +void kdProcessMouseEvents( const KDEvent *event ) +{ + QOpenKODEWindow *window = static_cast(event->userptr); + window->processMouseEvents(event); +} + +#ifdef KD_ATX_keyboard +void kdProcessKeyEvents( const KDEvent *event ) +{ + QOpenKODEWindow *window = static_cast(event->userptr); + window->processKeyEvents(event); +} +#endif //KD_ATX_keyboard + QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) : QPlatformWindow(tlw) { @@ -92,54 +110,90 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) m_kdWindow = kdCreateWindow(screen->eglDisplay(), m_eglConfig, - KD_NULL); + this); + kdInstallCallback(kdProcessMouseEvents,KD_EVENT_INPUT_POINTER,this); +#ifdef KD_ATX_keyboard + kdInstallCallback(kdProcessKeyEvents, KD_EVENT_INPUT_KEY_ATX,this); +#endif //KD_ATX_keyboard + if (!m_kdWindow) { qErrnoWarning(kdGetError(), "Error creating native window"); return; } - const KDint windowSize[2] = { tlw->width(), tlw->height()-1 }; - if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { - qErrnoWarning(kdGetError(), "Could not set native window size"); - return; + bool fullscreen = false; + KDboolean exclusive(false); + if (kdSetWindowPropertybv(m_kdWindow,KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, &exclusive)) { + fullscreen = true; } - KDboolean visibillity(false); - if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) { - qErrnoWarning(kdGetError(), "Could not set visibillity to false"); - } + if (fullscreen) { + tlw->setGeometry(screen->geometry()); + screen->setFullScreen(fullscreen); + }else { + const KDint windowSize[2] = { tlw->width(), tlw->height() }; + if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { + qErrnoWarning(kdGetError(), "Could not set native window size"); + } + KDboolean visibillity(false); + if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) { + qErrnoWarning(kdGetError(), "Could not set visibillity to false"); + } - const KDint windowPos[2] = { tlw->x(), tlw->y() }; - if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { - qErrnoWarning(kdGetError(), "Could not set native window position"); - return; + const KDint windowPos[2] = { tlw->x(), tlw->y() }; + if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { + qErrnoWarning(kdGetError(), "Could not set native window position"); + return; + } } - if (kdRealizeWindow(m_kdWindow, &m_eglWindow)) { - qErrnoWarning(kdGetError(), "Could not realize native window"); - return; - } - EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); - m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(), m_eglConfig, - m_eglContextAttrs.data(), surface, m_eglApi); + + if (!fullscreen || (fullscreen && !QPlatformGLContext::defaultSharedContext())) { + if (kdRealizeWindow(m_kdWindow, &m_eglWindow)) { + qErrnoWarning(kdGetError(), "Could not realize native window"); + return; + } + + EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); + m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(), m_eglConfig, + m_eglContextAttrs.data(), surface, m_eglApi); + m_platformGlContext->makeDefaultSaredContext(); + } else { + m_platformGlContext = static_cast(QPlatformGLContext::defaultSharedContext()); + kdDestroyWindow(m_kdWindow); + m_kdWindow = 0; + } } + QOpenKODEWindow::~QOpenKODEWindow() { qDebug() << "destroying window" << m_kdWindow; - delete m_platformGlContext; - kdDestroyWindow(m_kdWindow); + if (m_platformGlContext != QPlatformGLContext::defaultSharedContext()) { + delete m_platformGlContext; + } + if (m_kdWindow) + kdDestroyWindow(m_kdWindow); } void QOpenKODEWindow::setGeometry(const QRect &rect) { + if (!m_kdWindow) { + QList screens = QApplicationPrivate::platformIntegration()->screens(); + QOpenKODEScreen *screen = qobject_cast(screens.at(0)); + widget()->setGeometry(screen->geometry()); + return; + } + bool needToDeleteContext = false; const QRect geo = geometry(); if (geo.size() != rect.size()) { - const KDint windowSize[2] = { rect.width(), rect.height() -1 }; + const KDint windowSize[2] = { rect.width(), rect.height() }; if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { qErrnoWarning(kdGetError(), "Could not set native window size"); //return; + } else { + needToDeleteContext = true; } } @@ -148,11 +202,16 @@ void QOpenKODEWindow::setGeometry(const QRect &rect) if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { qErrnoWarning(kdGetError(), "Could not set native window position"); //return; + } else { + needToDeleteContext = true; } } //need to recreate context - delete m_platformGlContext; + if (needToDeleteContext) { + qDebug() << "deleting context"; + delete m_platformGlContext; + } QList screens = QApplicationPrivate::platformIntegration()->screens(); QOpenKODEScreen *screen = qobject_cast(screens.at(0)); @@ -163,14 +222,96 @@ void QOpenKODEWindow::setGeometry(const QRect &rect) void QOpenKODEWindow::setVisible(bool visible) { + if (!m_kdWindow) + return; KDboolean visibillity(visible); if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) { - qErrnoWarning(kdGetError(), "Could not set visibillity to false"); + qErrnoWarning(kdGetError(), "Could not set visibillity property"); } } +WId QOpenKODEWindow::winId() const +{ + static int i = 0; + return i++; +} + QPlatformGLContext *QOpenKODEWindow::glContext() const { return m_platformGlContext; } + +void QOpenKODEWindow::raise() +{ + if (!m_kdWindow) + return; + KDboolean focus(true); + if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_FOCUS, &focus)) { + qErrnoWarning(kdGetError(), "Could not set focus"); + } +} + +void QOpenKODEWindow::lower() +{ + if (!m_kdWindow) + return; + KDboolean focus(false); + if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_FOCUS, &focus)) { + qErrnoWarning(kdGetError(), "Could not set focus"); + } +} + +void QOpenKODEWindow::processMouseEvents(const KDEvent *event) +{ + int x = event->data.inputpointer.x; + int y = event->data.inputpointer.y; + Qt::MouseButtons buttons; + switch(event->data.inputpointer.select) { + case 1: + buttons = Qt::LeftButton; + break; + default: + buttons = Qt::NoButton; + } + qDebug() << x << y; + QPoint pos(x,y); + QWindowSystemInterface::handleMouseEvent(0,event->timestamp,pos,pos,buttons); +} + +void QOpenKODEWindow::processKeyEvents(const KDEvent *event) +{ +#ifdef KD_ATX_keyboard + //KD_KEY_PRESS_ATX 1 + QEvent::Type keyPressed = QEvent::KeyRelease; + if (event->data.keyboardInputKey.flags) + keyPressed = QEvent::KeyPress; +//KD_KEY_LOCATION_LEFT_ATX // dont care for now +//KD_KEY_LOCATION_RIGHT_ATX +//KD_KEY_LOCATION_NUMPAD_ATX + Qt::KeyboardModifiers mod = Qt::NoModifier; + int openkodeMods = event->data.keyboardInputKey.flags; + if (openkodeMods & KD_KEY_MODIFIER_SHIFT_ATX) + mod |= Qt::ShiftModifier; + if (openkodeMods & KD_KEY_MODIFIER_CTRL_ATX) + mod |= Qt::ControlModifier; + if (openkodeMods & KD_KEY_MODIFIER_ALT_ATX) + mod |= Qt::AltModifier; + if (openkodeMods & KD_KEY_MODIFIER_META_ATX) + mod |= Qt::MetaModifier; + + Qt::Key qtKey; + QChar keyText; + int key = event->data.keyboardInputKey.keycode; + if (key >= 0x20 && key <= 0x0ff){ // 8 bit printable Latin1 + qtKey = Qt::Key(key); + keyText = QChar(event->data.keyboardInputKeyChar.character); + if (!(mod & Qt::ShiftModifier)) + keyText = keyText.toLower(); + } else { + qtKey = keyTranslator(key); + } + QWindowSystemInterface::handleKeyEvent(0,event->timestamp,keyPressed,qtKey,mod,keyText); +#endif +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qopenkodewindow.h b/src/plugins/platforms/openkode/qopenkodewindow.h index 3e7ee56..1980c15 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.h +++ b/src/plugins/platforms/openkode/qopenkodewindow.h @@ -51,6 +51,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE class QEGLPlatformContext; +class QPlatformEventLoopIntegration; class QOpenKODEWindow : public QPlatformWindow { @@ -60,10 +61,16 @@ public: void setGeometry(const QRect &rect); void setVisible(bool visible); - WId winId() const { return WId(m_eglWindow); } + WId winId() const; QPlatformGLContext *glContext() const; + void raise(); + void lower(); + + void processKeyEvents( const KDEvent *event ); + void processMouseEvents( const KDEvent *event ); + private: struct KDWindow *m_kdWindow; EGLNativeWindowType m_eglWindow; diff --git a/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp b/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp deleted file mode 100644 index 84e27f5..0000000 --- a/src/plugins/platforms/openkode/qopenkodewindowsurface.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qopenkodewindowsurface.h" -#include "qopenkodeintegration.h" - -#include "qopenkodewindow.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -QOpenKODEWindowSurface::QOpenKODEWindowSurface - (QWidget *window, WId) - : QWindowSurface(window), m_platformGLContext(window->platformWindow()->glContext()) -{ -} - -QOpenKODEWindowSurface::~QOpenKODEWindowSurface() -{ -} - -QPaintDevice *QOpenKODEWindowSurface::paintDevice() -{ - return &mImage; -} - -// ### TODO - this updates the entire toplevel, should only update the region -void QOpenKODEWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - m_platformGLContext->makeCurrent(); - - if (!offset.isNull()) { - qWarning("Offset flushing not supported yet"); - return; - } - - m_platformGLContext->makeCurrent(); - - QRect boundingRect = region.boundingRect(); - - int x, y, w, h; - QImage blitImage; - if (true || boundingRect == mImage.rect()) { // TODO - check optimization - blitImage = mImage; - x = y = 0; - w = mImage.width(); - h = mImage.height(); - } else { - blitImage = mImage.copy(boundingRect); - w = boundingRect.width(); - h = boundingRect.height(); - x = boundingRect.x(); - y = boundingRect.y(); - } - - GLuint shaderProgram = QOpenKODEIntegration::blitterProgram(); - - glUseProgram(shaderProgram); - - GLuint index = glGetUniformLocation(shaderProgram, "window"); - glUniform2f(index, GLfloat(mImage.width()), GLfloat(mImage.height())); - - // attributes - GLuint posId = glGetAttribLocation(shaderProgram, "pos_attr"); - GLuint texcoordId = glGetAttribLocation(shaderProgram, "texcoord_attr"); - - // sampler - index = glGetUniformLocation(shaderProgram, "tex_samp"); - - glUniform1i(index, 0); - - glDisable(GL_DEPTH_TEST); - glActiveTexture(GL_TEXTURE0); - - GLuint texId; - GLfloat coords[8] = {x, y, x, y + h, x + w, y + h, x + w, y }; - GLfloat texcoords[8] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0 }; - - // Generate texture for checkered background - glGenTextures(1, &texId); - glBindTexture(GL_TEXTURE_2D, texId); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, mImage.bits()); - - // Enable vertex attribute associated with vertex position - glEnableVertexAttribArray(posId); - glEnableVertexAttribArray(texcoordId); - - // Set the quad vertices - glVertexAttribPointer(posId, 2, GL_FLOAT, 0, 0, coords); - glVertexAttribPointer(texcoordId, 2, GL_FLOAT, 0, 0, texcoords); - - // Draw the quad - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - // Cleanup - glDisableVertexAttribArray(posId); - glDisableVertexAttribArray(texcoordId); - - // Release all textures - glBindTexture(GL_TEXTURE_2D, 0); - if (texId) - glDeleteTextures(1, &texId); - - eglWaitGL(); - - m_platformGLContext->swapBuffers(); - m_platformGLContext->doneCurrent(); - - eglWaitNative(EGL_CORE_NATIVE_ENGINE); -} - -void QOpenKODEWindowSurface::resize(const QSize &size) -{ - QWindowSurface::resize(size); - mImage = QImage(); - -} -void QOpenKODEWindowSurface::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); - if (mImage.isNull()) { - m_platformGLContext = window()->platformWindow()->glContext(); - mImage = QImage(size(),QImage::Format_RGB888); - } -} - -void QOpenKODEWindowSurface::endPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qopenkodewindowsurface.h b/src/plugins/platforms/openkode/qopenkodewindowsurface.h deleted file mode 100644 index f12b625..0000000 --- a/src/plugins/platforms/openkode/qopenkodewindowsurface.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_OPENKODE_H -#define QWINDOWSURFACE_OPENKODE_H - -#include - -#include - -QT_BEGIN_HEADER -QT_BEGIN_NAMESPACE - -class QOpenKODEWindow; -class QPlatformGLContext; - -class QOpenKODEWindowSurface : public QWindowSurface -{ -public: - QOpenKODEWindowSurface - (QWidget *window, WId winId); - ~QOpenKODEWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void resize (const QSize &size); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - -private: - QImage mImage; - QPlatformGLContext *m_platformGLContext; -}; - -QT_END_NAMESPACE -QT_END_HEADER - -#endif -- cgit v0.12 From c0eb289559705e15fe13013c72a218e647ad6d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 3 Aug 2010 08:46:44 +0200 Subject: Make it possible to view what format a QPlatformGlContext has QPlatformGlContext has now a pure virtual format getter. The way its intended to work is that the tlw has a QPlatformWindowFormat which is the requested format. Once you get the QPlatformGlContext of the window, you can request the QPlatformWindowFormat of the context to see what you really got. --- src/gui/kernel/qplatformglcontext_qpa.cpp | 3 ++ src/gui/kernel/qplatformglcontext_qpa.h | 5 +- src/opengl/qgl_qpa.cpp | 1 + .../platforms/eglconvenience/qeglconvenience.cpp | 45 +++++++++++++++++ .../platforms/eglconvenience/qeglconvenience.h | 4 ++ .../eglconvenience/qeglplatformcontext.cpp | 12 ++++- .../platforms/eglconvenience/qeglplatformcontext.h | 4 ++ src/plugins/platforms/testlite/qglxintegration.cpp | 57 ++++++++++++++++++++-- src/plugins/platforms/testlite/qglxintegration.h | 4 +- 9 files changed, 129 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp index a2ffbf3..36db2b0 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.cpp +++ b/src/gui/kernel/qplatformglcontext_qpa.cpp @@ -41,6 +41,9 @@ #include "qplatformglcontext_qpa.h" +QPlatformGLContext::~QPlatformGLContext() +{ } + static QPlatformGLContext *staticSharedContext = 0; void QPlatformGLContext::setDefaultSharedContext(QPlatformGLContext *sharedContext) diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h index 9f3bfb3..d235848 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.h +++ b/src/gui/kernel/qplatformglcontext_qpa.h @@ -51,16 +51,19 @@ QT_BEGIN_NAMESPACE class Q_OPENGL_EXPORT QPlatformGLContext { public: - virtual ~QPlatformGLContext() { } + virtual ~QPlatformGLContext(); virtual void makeCurrent() = 0; virtual void doneCurrent() = 0; virtual void swapBuffers() = 0; virtual void* getProcAddress(const QString& procName) = 0; + virtual QPlatformWindowFormat platformWindowFormat() const = 0; + static QPlatformGLContext *defaultSharedContext(); protected: + static void setDefaultSharedContext(QPlatformGLContext *sharedContext); }; diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 8fa210b..f859ff1 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -134,6 +134,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) widget->winId();//make window } d->platformContext = widget->platformWindow()->glContext(); + d->glFormat = qt_platformwindowformat_to_glformat(d->platformContext->platformWindowFormat()); d->valid =(bool) d->platformContext; } diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp index c50101d..b3a4c53 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp @@ -1,5 +1,7 @@ #include "qeglconvenience.h" +QT_BEGIN_NAMESPACE + QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format) { int redSize = format.redBufferSize(); @@ -228,3 +230,46 @@ EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformW qWarning("Cant find EGLConfig, returning null config"); return 0; } + +QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config) +{ + QPlatformWindowFormat format; + EGLint redSize = 0; + EGLint greenSize = 0; + EGLint blueSize = 0; + EGLint alphaSize = 0; + EGLint depthSize = 0; + EGLint stencilSize = 0; + EGLint sampleCount = 0; + EGLint level = 0; + + eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize); + eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize); + eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize); + eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize); + eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize); + eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize); + eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount); + eglGetConfigAttrib(display, config, EGL_LEVEL, &level); + + format.setRedBufferSize(redSize); + format.setGreenBufferSize(greenSize); + format.setBlueBufferSize(blueSize); + format.setAlphaBufferSize(alphaSize); + format.setDepthBufferSize(depthSize); + format.setStencilBufferSize(stencilSize); + format.setSamples(sampleCount); + format.setDirectRendering(true); // All EGL contexts are direct-rendered + format.setRgba(true); // EGL doesn't support colour index rendering + format.setStereo(false); // EGL doesn't support stereo buffers + format.setAccumBufferSize(0); // EGL doesn't support accululation buffers + + // Clear the EGL error state because some of the above may + // have errored out because the attribute is not applicable + // to the surface type. Such errors don't matter. + eglGetError(); + + return format; +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h index bd5a6d3..12731e1 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.h +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h @@ -46,9 +46,13 @@ #include #include +QT_BEGIN_NAMESPACE + QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format); bool q_reduceConfigAttributes(QVector *configAttributes); EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format); +QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config); +QT_END_NAMESPACE #endif //QEGLCONVENIENCE_H diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp index b3a5bba..87cd958 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp @@ -45,8 +45,11 @@ #include +#include "qeglconvenience.h" + QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi) - : m_eglDisplay(display) + : QPlatformGLContext() + , m_eglDisplay(display) , m_eglSurface(surface) , m_eglApi(eglApi) { @@ -61,6 +64,8 @@ QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, E eglTerminate(m_eglDisplay); qFatal("EGL error"); } + + m_windowFormat = qt_qPlatformWindowFormatFromConfig(display,config); } QEGLPlatformContext::~QEGLPlatformContext() @@ -142,3 +147,8 @@ void QEGLPlatformContext::makeDefaultSaredContext() { setDefaultSharedContext(this); } + +QPlatformWindowFormat QEGLPlatformContext::platformWindowFormat() const +{ + return m_windowFormat; +} diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h index 2a49129..b0cbbe0 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h @@ -57,11 +57,15 @@ public: void* getProcAddress(const QString& procName); void makeDefaultSaredContext(); + + QPlatformWindowFormat platformWindowFormat() const; private: EGLContext m_eglContext; EGLDisplay m_eglDisplay; EGLSurface m_eglSurface; EGLenum m_eglApi; + + QPlatformWindowFormat m_windowFormat; }; #endif //QOPENKODEGLINTEGRATION_H diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index e554e8d..57f9de4 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -125,6 +125,54 @@ GLXFBConfig QGLXGLContext::findConfig(const GLXFBConfig *configs, int configCoun return chosenConfig; } +QPlatformWindowFormat QGLXGLContext::platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config) +{ + QPlatformWindowFormat format; + int redSize = 0; + int greenSize = 0; + int blueSize = 0; + int alphaSize = 0; + int depthSize = 0; + int stencilSize = 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; + + 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, &sampleCount); + glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level); + glXGetFBConfigAttrib(display, config, GLX_RGBA, &rgba); + 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.setSamples(sampleCount); + format.setDirectRendering(true); // We don't support anything else for now. + format.setRgba(rgba); + format.setStereo(stereo); + format.setAccumBufferSize(accumSizeA + accumSizeB + accumSizeG + accumSizeR); + + return format; +} + QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindowFormat &format) : QPlatformGLContext() , m_xd(xd) @@ -159,6 +207,7 @@ QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindow { GLXFBConfig config = findConfig(configs,confcount,format,xd); m_context = glXCreateNewContext(xd->display,config,GLX_RGBA_TYPE,shareGlxContext,TRUE); + m_windowFormat = QGLXGLContext::platformWindowFromGLXFBConfig(xd->display,config); XFree(configs); } else { qFatal("Warning no context created"); @@ -167,9 +216,6 @@ QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindow #ifdef MYX11_DEBUG qDebug() << "QGLXGLContext::create context" << m_context; #endif - -// TODO: Populate the QGLFormat with the values of the GLXFBConfig - } QGLXGLContext::QGLXGLContext(MyDisplay *display, Drawable drawable, GLXContext context) @@ -266,4 +312,9 @@ void* QGLXGLContext::getProcAddress(const QString& procName) return glXGetProcAddressARB(reinterpret_cast(procName.toLatin1().data())); } +QPlatformWindowFormat QGLXGLContext::platformWindowFormat() const +{ + return m_windowFormat; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h index decbe36..5a98e25 100644 --- a/src/plugins/platforms/testlite/qglxintegration.h +++ b/src/plugins/platforms/testlite/qglxintegration.h @@ -68,14 +68,16 @@ public: GLXContext glxContext() {return m_context;} - + QPlatformWindowFormat platformWindowFormat() const; private: static QVector buildSpec(const QPlatformWindowFormat &format); static GLXFBConfig findConfig(const GLXFBConfig *configs,int configCount, const QPlatformWindowFormat &format, const MyDisplay *xd); + static QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config); MyDisplay *m_xd; Drawable m_drawable; GLXContext m_context; + QPlatformWindowFormat m_windowFormat; QGLXGLContext (MyDisplay *display, Drawable drawable, GLXContext context); static QMutex m_defaultSharedContextMutex; -- cgit v0.12 From 42cdfaf86d34afeb6448723839fef70fe477deed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 3 Aug 2010 12:44:00 +0200 Subject: Make QOpenKODEWindow not delete context when in fullscreen mode --- src/plugins/platforms/openkode/qopenkodewindow.cpp | 59 +++++++++++----------- src/plugins/platforms/openkode/qopenkodewindow.h | 2 + 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index c890641..454a50f 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -76,7 +76,7 @@ void kdProcessKeyEvents( const KDEvent *event ) #endif //KD_ATX_keyboard QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) - : QPlatformWindow(tlw) + : QPlatformWindow(tlw), isFullScreen(false) { if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenVG) { m_eglApi = EGL_OPENVG_API; @@ -121,15 +121,14 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) return; } - bool fullscreen = false; KDboolean exclusive(false); if (kdSetWindowPropertybv(m_kdWindow,KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, &exclusive)) { - fullscreen = true; + isFullScreen = true; } - if (fullscreen) { + if (isFullScreen) { tlw->setGeometry(screen->geometry()); - screen->setFullScreen(fullscreen); + screen->setFullScreen(isFullScreen); }else { const KDint windowSize[2] = { tlw->width(), tlw->height() }; if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { @@ -150,7 +149,7 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) - if (!fullscreen || (fullscreen && !QPlatformGLContext::defaultSharedContext())) { + if (!isFullScreen || (isFullScreen && !QPlatformGLContext::defaultSharedContext())) { if (kdRealizeWindow(m_kdWindow, &m_eglWindow)) { qErrnoWarning(kdGetError(), "Could not realize native window"); return; @@ -179,31 +178,33 @@ QOpenKODEWindow::~QOpenKODEWindow() } void QOpenKODEWindow::setGeometry(const QRect &rect) { - if (!m_kdWindow) { + if (isFullScreen) { QList screens = QApplicationPrivate::platformIntegration()->screens(); QOpenKODEScreen *screen = qobject_cast(screens.at(0)); widget()->setGeometry(screen->geometry()); return; } bool needToDeleteContext = false; - const QRect geo = geometry(); - if (geo.size() != rect.size()) { - const KDint windowSize[2] = { rect.width(), rect.height() }; - if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { - qErrnoWarning(kdGetError(), "Could not set native window size"); - //return; - } else { - needToDeleteContext = true; + if (!isFullScreen) { + const QRect geo = geometry(); + if (geo.size() != rect.size()) { + const KDint windowSize[2] = { rect.width(), rect.height() }; + if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { + qErrnoWarning(kdGetError(), "Could not set native window size"); + //return; + } else { + needToDeleteContext = true; + } } - } - if (geo.topLeft() != rect.topLeft()) { - const KDint windowPos[2] = { rect.x(), rect.y() }; - if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { - qErrnoWarning(kdGetError(), "Could not set native window position"); - //return; - } else { - needToDeleteContext = true; + if (geo.topLeft() != rect.topLeft()) { + const KDint windowPos[2] = { rect.x(), rect.y() }; + if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { + qErrnoWarning(kdGetError(), "Could not set native window position"); + //return; + } else { + needToDeleteContext = true; + } } } @@ -211,13 +212,13 @@ void QOpenKODEWindow::setGeometry(const QRect &rect) if (needToDeleteContext) { qDebug() << "deleting context"; delete m_platformGlContext; - } - QList screens = QApplicationPrivate::platformIntegration()->screens(); - QOpenKODEScreen *screen = qobject_cast(screens.at(0)); - EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); - m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(),m_eglConfig, - m_eglContextAttrs.data(),surface,m_eglApi); + QList screens = QApplicationPrivate::platformIntegration()->screens(); + QOpenKODEScreen *screen = qobject_cast(screens.at(0)); + EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); + m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(),m_eglConfig, + m_eglContextAttrs.data(),surface,m_eglApi); + } } void QOpenKODEWindow::setVisible(bool visible) diff --git a/src/plugins/platforms/openkode/qopenkodewindow.h b/src/plugins/platforms/openkode/qopenkodewindow.h index 1980c15..27d33d6 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.h +++ b/src/plugins/platforms/openkode/qopenkodewindow.h @@ -79,6 +79,8 @@ private: QVector m_eglContextAttrs; EGLenum m_eglApi; QEGLPlatformContext *m_platformGlContext; + + bool isFullScreen; }; QT_END_NAMESPACE -- cgit v0.12 From 34a3b5d2a0c86a534b9d7b036fb1aaf1eb1c65b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 3 Aug 2010 14:03:28 +0200 Subject: QGLWindowSurface does not support partialupdates if not EGL is defined --- src/opengl/qwindowsurface_gl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index ef115bd..b3c9df1 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -370,6 +370,8 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) setPartialUpdateSupport(false); // Force full-screen updates else setPartialUpdateSupport(true); +#else + setPartialUpdateSupport(false); #endif widgetPrivate->extraData()->glContext = ctx; -- cgit v0.12 From 7992c2d3a4413082fd40e4099f735d95d522b0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 4 Aug 2010 13:48:43 +0200 Subject: Make QWidget::setPlatformWindowFormat recreate platformWindow if the platformWindow is visible. Also had to make sure that the QGLContext of a QGLWidget was recreated. --- src/gui/kernel/qwidget_qpa.cpp | 41 ++++++++++++++-------- src/opengl/qgl_qpa.cpp | 29 +++++++++------ src/plugins/platforms/testlite/qtestlitewindow.cpp | 2 +- 3 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index ef53004..e11f1fc 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -54,22 +54,26 @@ QT_BEGIN_NAMESPACE static QPlatformScreen *qt_screenForWidget(const QWidget *w); -void setParentForChildrenOfWidget(QPlatformWindow *window, const QWidget *widget) +void q_createNativeChildrenAndSetParent(QPlatformWindow *parentWindow, const QWidget *parentWidget) { - QObjectList children = widget->children(); + QObjectList children = parentWidget->children(); for (int i = 0; i < children.size(); i++) { if (children.at(i)->isWidgetType()) { const QWidget *childWidget = qobject_cast(children.at(i)); if (childWidget) { // should not be necessary + if (childWidget->testAttribute(Qt::WA_NativeWindow)) { + if (!childWidget->platformWindow()) + childWidget->winId(); + } if (childWidget->platformWindow()) { - childWidget->platformWindow()->setParent(window); - childWidget->platformWindow()->setWindowFlags(Qt::SubWindow); + childWidget->platformWindow()->setParent(parentWindow); } else { - setParentForChildrenOfWidget(window,childWidget); + q_createNativeChildrenAndSetParent(parentWindow,childWidget); } } } } + } void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) @@ -79,7 +83,6 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO Q_UNUSED(window); Q_UNUSED(initializeWindow); Q_UNUSED(destroyOldWindow); - // XXX Qt::WindowFlags flags = data.window_flags; @@ -102,12 +105,13 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO setWinId(q->platformWindow()->winId()); - //first check children. then find who for parent. - setParentForChildrenOfWidget(platformWindow,q); + //first check children. and create them if necessary + q_createNativeChildrenAndSetParent(q->platformWindow(),q); + + //if we we have a parent, then set correct parent; if (QWidget *nativeParent = q->nativeParentWidget()) { if (nativeParent->platformWindow()) { platformWindow->setParent(nativeParent->platformWindow()); - platformWindow->setWindowFlags(Qt::SubWindow); } } @@ -143,6 +147,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) if (topData) { delete topData->platformWindow; topData->platformWindow = 0; + d->data.winid = 0; } } else { if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) { @@ -176,7 +181,6 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) QWidget * parentWithWindow = newparent->platformWindow()? newparent : newparent->nativeParentWidget(); if (parentWithWindow && parentWithWindow->platformWindow()) { q->platformWindow()->setParent(parentWithWindow->platformWindow()); - q->platformWindow()->setWindowFlags(Qt::SubWindow); } } @@ -615,7 +619,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (isResize) { QResizeEvent e(r.size(), olds); QApplication::sendEvent(q, &e); - if (q->isWindow()) + if (q->platformWindow()) q->update(); } } else { // not visible @@ -743,9 +747,18 @@ QPlatformWindow *QWidget::platformWindow() const void QWidget::setPlatformWindowFormat(const QPlatformWindowFormat &format) { - Q_D(QWidget); - QTLWExtra *topData = d->topData(); - topData->platformWindowFormat = format; + if (isWindow() || testAttribute(Qt::WA_NativeWindow)) { + Q_D(QWidget); + QTLWExtra *topData = d->topData(); + topData->platformWindowFormat = format; + if (testAttribute(Qt::WA_WState_Created)) { + bool wasVisible = testAttribute(Qt::WA_WState_Visible); + destroy(); + d->create_sys(0,true,true); + if (wasVisible) + topData->platformWindow->setVisible(true); + } + } } QPlatformWindowFormat QWidget::platformWindowFormat() const diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index f859ff1..5e05de1 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -129,11 +129,15 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) if (!widget->platformWindow()){ QGLFormat glformat = format(); QPlatformWindowFormat winFormat = qt_glformat_to_platformwindowformat(glformat); + if (shareContext) { + winFormat.setSharedContext(shareContext->d_func()->platformContext); + } winFormat.setWindowApi(QPlatformWindowFormat::OpenGL); widget->setPlatformWindowFormat(winFormat); widget->winId();//make window } d->platformContext = widget->platformWindow()->glContext(); + Q_ASSERT(d->platformContext); d->glFormat = qt_platformwindowformat_to_glformat(d->platformContext->platformWindowFormat()); d->valid =(bool) d->platformContext; } @@ -147,14 +151,6 @@ void QGLContext::reset() if (!d->valid) return; d->cleanup(); - doneCurrent(); - - if (d->platformContext) { - if (d->paintDevice && d->paintDevice->devType() == QInternal::Widget) { - QWidget *widget = static_cast(d->paintDevice); - widget->destroy(); - } - } d->crWin = false; d->sharing = false; @@ -204,8 +200,6 @@ void QGLWidget::setContext(QGLContext *context, return; } - if (d->glcx) - d->glcx->doneCurrent(); QGLContext* oldcx = d->glcx; d->glcx = context; @@ -286,11 +280,26 @@ void QGLWidget::setMouseTracking(bool enable) bool QGLWidget::event(QEvent *e) { + Q_D(QGLWidget); + if (e->type() == QEvent::WinIdChange) { + if (d->glcx->isValid()) { + if (QGLContext::currentContext() == d->glcx) + QGLContextPrivate::setCurrentContext(0); //Its not valid anymore + setContext(new QGLContext(d->glcx->requestedFormat(), this)); + + } + } return QWidget::event(e); } void QGLWidget::resizeEvent(QResizeEvent *e) { + Q_D(QGLWidget); + if (!isValid()) + return; + if (!d->glcx->initialized()) + glInit(); + resizeGL(width(), height()); return QWidget::resizeEvent(e); } diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index 67ec97c..fd02bc4 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -206,11 +206,11 @@ QTestLiteWindow::~QTestLiteWindow() #ifdef MYX11_DEBUG qDebug() << "~QTestLiteWindow" << hex << x_window; #endif + delete mGLContext; XFreeGC(xd->display, gc); XDestroyWindow(xd->display, x_window); xd->windowList.removeAll(this); - delete mGLContext; } -- cgit v0.12 From 8fb1271a4c211adcf3e74f545d8133671747e230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 4 Aug 2010 16:21:09 +0200 Subject: Forgot to makeCurrent before QGLWidget::resizeGL in Lighthouse --- src/opengl/qgl_qpa.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 5e05de1..3d5b74f 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -297,6 +297,7 @@ void QGLWidget::resizeEvent(QResizeEvent *e) Q_D(QGLWidget); if (!isValid()) return; + makeCurrent(); if (!d->glcx->initialized()) glInit(); resizeGL(width(), height()); -- cgit v0.12 From 1be2e830da7aa09f92d8cdca906f8a588cd10381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 5 Aug 2010 11:55:01 +0200 Subject: Remove "disabling opengl tests by default" in configure for lighthouse --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 52a36eb..aa2341a 100755 --- a/configure +++ b/configure @@ -3324,7 +3324,7 @@ if [ "$CFG_USE_GNUMAKE" = "auto" ] && "$MAKE" -v | grep "GNU Make" >/dev/null 2> fi # If -opengl wasn't specified, don't try to auto-detect -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ] && [ "$CFG_OPENGL" = "auto" ]; then +if [ "$PLATFORM_QWS" = "yes" ] && [ "$CFG_OPENGL" = "auto" ]; then CFG_OPENGL=no fi -- cgit v0.12 From 261fa64d61111741a9746459eac4901248eb19d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 5 Aug 2010 13:58:51 +0200 Subject: Force 16 bit in eglfs --- src/plugins/platforms/eglfs/qeglfsscreen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index a390106..0d72862 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -116,9 +116,9 @@ QEglFSScreen::QEglFSScreen(EGLNativeDisplayType display) QPlatformWindowFormat platformFormat; platformFormat.setDepth(16); platformFormat.setWindowApi(QPlatformWindowFormat::OpenGL); - platformFormat.setRedBufferSize(8); - platformFormat.setGreenBufferSize(8); - platformFormat.setBlueBufferSize(8); + platformFormat.setRedBufferSize(5); + platformFormat.setGreenBufferSize(6); + platformFormat.setBlueBufferSize(5); EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat); EGLNativeWindowType eglWindow = 0; -- cgit v0.12 From a1f0a650578b71fddae9db05435715338b15ba35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 6 Aug 2010 07:53:28 +0200 Subject: Make the GLX integration give more correct format Also create a correct window for the format. --- src/gui/kernel/qplatformwindowformat_qpa.cpp | 24 ++++ src/gui/kernel/qplatformwindowformat_qpa.h | 7 + src/opengl/qgl_qpa.cpp | 3 +- src/plugins/platforms/testlite/qglxintegration.cpp | 159 ++++++++++++--------- src/plugins/platforms/testlite/qglxintegration.h | 7 +- src/plugins/platforms/testlite/qtestlitewindow.cpp | 25 ++-- 6 files changed, 138 insertions(+), 87 deletions(-) diff --git a/src/gui/kernel/qplatformwindowformat_qpa.cpp b/src/gui/kernel/qplatformwindowformat_qpa.cpp index 1112ba9..d497e85 100644 --- a/src/gui/kernel/qplatformwindowformat_qpa.cpp +++ b/src/gui/kernel/qplatformwindowformat_qpa.cpp @@ -41,6 +41,8 @@ #include "qplatformwindowformat_qpa.h" +#include + Q_GLOBAL_STATIC(QPlatformWindowFormat, q_platformwindow_default_format); class QPlatformWindowFormatPrivate @@ -986,3 +988,25 @@ bool operator!=(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b) { return !(a == b); } + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QPlatformWindowFormat &f) +{ + const QPlatformWindowFormatPrivate * const d = f.d; + + dbg.nospace() << "QGLFormat(" + << "options " << d->opts + << ", depthBufferSize " << d->depthSize + << ", accumBufferSize " << d->accumSize + << ", stencilBufferSize " << d->stencilSize + << ", redBufferSize " << d->redSize + << ", greenBufferSize " << d->greenSize + << ", blueBufferSize " << d->blueSize + << ", alphaBufferSize " << d->alphaSize + << ", samples " << d->numSamples + << ", swapInterval " << d->swapInterval + << ')'; + + return dbg.space(); +} +#endif diff --git a/src/gui/kernel/qplatformwindowformat_qpa.h b/src/gui/kernel/qplatformwindowformat_qpa.h index 37e628d..075e796 100644 --- a/src/gui/kernel/qplatformwindowformat_qpa.h +++ b/src/gui/kernel/qplatformwindowformat_qpa.h @@ -163,11 +163,18 @@ private: friend Q_GUI_EXPORT bool operator==(const QPlatformWindowFormat&, const QPlatformWindowFormat&); friend Q_GUI_EXPORT bool operator!=(const QPlatformWindowFormat&, const QPlatformWindowFormat&); +#ifndef QT_NO_DEBUG_STREAM + friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QPlatformWindowFormat &); +#endif }; Q_GUI_EXPORT bool operator==(const QPlatformWindowFormat&, const QPlatformWindowFormat&); Q_GUI_EXPORT bool operator!=(const QPlatformWindowFormat&, const QPlatformWindowFormat&); +#ifndef QT_NO_DEBUG_STREAM +Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QPlatformWindowFormat &); +#endif + Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformWindowFormat::FormatOptions) inline bool QPlatformWindowFormat::doubleBuffer() const diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 3d5b74f..5f0bca3 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -105,7 +105,8 @@ static QPlatformWindowFormat qt_glformat_to_platformwindowformat(const QGLFormat retFormat.setRedBufferSize(format.redBufferSize()); retFormat.setRgba(format.rgba()); retFormat.setSampleBuffers(format.sampleBuffers()); - retFormat.setSamples(format.sampleBuffers()); + if (format.samples() >= 0) + retFormat.setSamples(format.samples()); retFormat.setStencil(format.stencil()); if (format.stencilBufferSize() >= 0) retFormat.setStencilBufferSize(format.stencilBufferSize()); diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index 57f9de4..47a4f5a 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -63,69 +63,94 @@ QVector QGLXGLContext::buildSpec(const QPlatformWindowFormat &format) { QVector spec(48); int i = 0; - int depthSize = 0; - int stencilSize = 0; - int sampleSize = 0; - - if (format.depth()) - depthSize = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize(); - if (format.stencil()) - stencilSize = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize(); - if (format.sampleBuffers()) - sampleSize = (format.samples() == -1) ? 1 : format.samples(); + spec[i++] = GLX_LEVEL; + spec[i++] = 0; spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_WINDOW_BIT; - spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_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; - spec[i++] = GLX_DEPTH_SIZE; spec[i++] = depthSize; - spec[i++] = GLX_STENCIL_SIZE; spec[i++] = stencilSize; - spec[i++] = GLX_SAMPLE_BUFFERS_ARB; spec[i++] = sampleSize; + if (format.depth()) { + spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize(); + } - 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(); - spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 0 : format.alphaBufferSize(); + 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++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 0 : format.accumBufferSize(); spec[i++] = XNone; return spec; } -GLXFBConfig QGLXGLContext::findConfig(const GLXFBConfig *configs, int configCount, const QPlatformWindowFormat &format, const MyDisplay *xd) +GLXFBConfig QGLXGLContext::findConfig(const MyDisplay *xd, const QPlatformWindowFormat &format) { - if (!configs) - return 0; - + QVector spec = buildSpec(format); + int confcount = 0; + GLXFBConfig *configs; GLXFBConfig chosenConfig = 0; - for (int i = 0; i < configCount; ++i) { - chosenConfig = configs[i]; + configs = glXChooseFBConfig(xd->display,xd->screen,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 (format.alpha()) { + int alphaSize; + glXGetFBConfigAttrib(xd->display,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 + } + } - // Make sure we try to get an ARGB visual if the format asked for an alpha: - if (format.alpha()) { - XVisualInfo* vi; - vi = glXGetVisualFromFBConfig(xd->display, configs[i]); - if (!vi) - continue; + XFree(configs); + } - XRenderPictFormat *pictFormat = XRenderFindVisualFormat(xd->display, vi->visual); - XFree(vi); + if (!chosenConfig) + qFatal("Warning no context created"); - if (pictFormat && (pictFormat->type == PictTypeDirect) && pictFormat->direct.alphaMask) { - // The pict format for the visual matching the FBConfig indicates ARGB - break; - } - } else - break; // Just choose the first in the list if there's no alpha requested - } return chosenConfig; } -QPlatformWindowFormat QGLXGLContext::platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config) +XVisualInfo *QGLXGLContext::findVisualInfo(const MyDisplay *xd, const QPlatformWindowFormat &format) +{ + GLXFBConfig config = QGLXGLContext::findConfig(xd,format); + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(xd->display,config); + return visualInfo; +} + +QPlatformWindowFormat QGLXGLContext::platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx) { QPlatformWindowFormat format; int redSize = 0; @@ -134,6 +159,7 @@ QPlatformWindowFormat QGLXGLContext::platformWindowFromGLXFBConfig(Display *disp int alphaSize = 0; int depthSize = 0; int stencilSize = 0; + int sampleBuffers = 0; int sampleCount = 0; int level = 0; int rgba = 0; @@ -143,15 +169,17 @@ QPlatformWindowFormat QGLXGLContext::platformWindowFromGLXFBConfig(Display *disp 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, &sampleCount); + glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers); glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level); - glXGetFBConfigAttrib(display, config, GLX_RGBA, &rgba); glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo); glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA); glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR); @@ -164,11 +192,16 @@ QPlatformWindowFormat QGLXGLContext::platformWindowFromGLXFBConfig(Display *disp format.setAlphaBufferSize(alphaSize); format.setDepthBufferSize(depthSize); format.setStencilBufferSize(stencilSize); - format.setSamples(sampleCount); - format.setDirectRendering(true); // We don't support anything else for now. + 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(accumSizeA + accumSizeB + accumSizeG + accumSizeR); + format.setAccumBufferSize(accumSizeB); return format; } @@ -199,19 +232,9 @@ QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindow if (sharePlatformContext) shareGlxContext = static_cast(sharePlatformContext)->glxContext(); - QVector spec = buildSpec(format); - int confcount = 0; - GLXFBConfig *configs; - configs = glXChooseFBConfig(xd->display,xd->screen,spec.constData(),&confcount); - if (confcount) - { - GLXFBConfig config = findConfig(configs,confcount,format,xd); - m_context = glXCreateNewContext(xd->display,config,GLX_RGBA_TYPE,shareGlxContext,TRUE); - m_windowFormat = QGLXGLContext::platformWindowFromGLXFBConfig(xd->display,config); - XFree(configs); - } else { - qFatal("Warning no context created"); - } + GLXFBConfig config = findConfig(xd,format); + m_context = glXCreateNewContext(xd->display,config,GLX_RGBA_TYPE,shareGlxContext,TRUE); + m_windowFormat = QGLXGLContext::platformWindowFromGLXFBConfig(xd->display,config,m_context); #ifdef MYX11_DEBUG qDebug() << "QGLXGLContext::create context" << m_context; @@ -243,16 +266,10 @@ void QGLXGLContext::createDefaultSharedContex(MyDisplay *xd) x, y, w, h, 0 /*border_width*/, xd->blackPixel(), xd->whitePixel()); GLXContext context; - QPlatformWindowFormat format; - QVector spec = buildSpec(format); - int confcount = 0; - GLXFBConfig *configs; - configs = glXChooseFBConfig(xd->display,xd->screen,spec.constData(),&confcount); - if (confcount) - { - GLXFBConfig config = findConfig(configs,confcount,format,xd); + QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat(); + GLXFBConfig config = findConfig(xd,format); + if (config) { context = glXCreateNewContext(xd->display,config,GLX_RGBA_TYPE,0,TRUE); - XFree(configs); QPlatformGLContext *sharedContext = new QGLXGLContext(xd,sharedWindow,context); QPlatformGLContext::setDefaultSharedContext(sharedContext); } else { diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h index 5a98e25..2f7c70e 100644 --- a/src/plugins/platforms/testlite/qglxintegration.h +++ b/src/plugins/platforms/testlite/qglxintegration.h @@ -69,10 +69,13 @@ public: GLXContext glxContext() {return m_context;} QPlatformWindowFormat platformWindowFormat() const; + + static XVisualInfo *findVisualInfo(const MyDisplay *xd, const QPlatformWindowFormat &format); private: + static GLXFBConfig findConfig(const MyDisplay *xd,const QPlatformWindowFormat &format); static QVector buildSpec(const QPlatformWindowFormat &format); - static GLXFBConfig findConfig(const GLXFBConfig *configs,int configCount, const QPlatformWindowFormat &format, const MyDisplay *xd); - static QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config); + static QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); + MyDisplay *m_xd; Drawable m_drawable; diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index fd02bc4..39b2cc0 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -56,7 +56,6 @@ #include #include -#include #include "qglxintegration.h" #include @@ -158,21 +157,21 @@ QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration int w = window->width(); int h = window->height(); -// int n, i; -// if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL) { -// x_visualInfo = QGLXGLContext::findVisual(window->platformWindowFormat(),xd); - -// XSetWindowAttributes a; -// a.background_pixel = xd->whitePixel(); -// a.border_pixel = xd->blackPixel(); -// x_window = XCreateWindow(xd->display, xd->rootWindow(),x, y, w, h, -// 0, visualInfo()->depth, InputOutput, visualInfo()->visual, -// CWBackPixel|CWBorderPixel, &a); -// } else { + if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL) { + + XVisualInfo *visualInfo = QGLXGLContext::findVisualInfo(xd,window->platformWindowFormat()); + Colormap cmap = XCreateColormap(xd->display,xd->rootWindow(),visualInfo->visual,AllocNone); + + XSetWindowAttributes a; + a.colormap = cmap; + x_window = XCreateWindow(xd->display, xd->rootWindow(),x, y, w, h, + 0, visualInfo->depth, InputOutput, visualInfo->visual, + CWColormap, &a); + } else { x_window = XCreateSimpleWindow(xd->display, xd->rootWindow(), x, y, w, h, 0 /*border_width*/, xd->blackPixel(), xd->whitePixel()); -// } + } #ifdef MYX11_DEBUG qDebug() << "QTestLiteWindow::QTestLiteWindow creating" << hex << x_window << window; -- cgit v0.12 From a8530e5db7ae25ea0ab5df4681308374abf8b6ba Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Fri, 6 Aug 2010 12:35:47 +0200 Subject: Allow customizing the default fbo from the QPlatformGLContext. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jørgen Lind --- src/gui/kernel/qplatformglcontext_qpa.cpp | 12 ++++++++++++ src/gui/kernel/qplatformglcontext_qpa.h | 1 + src/opengl/qgl_qpa.cpp | 1 + src/opengl/qglpaintdevice.cpp | 6 ++++++ 4 files changed, 20 insertions(+) diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp index 36db2b0..4fcd9b8 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.cpp +++ b/src/gui/kernel/qplatformglcontext_qpa.cpp @@ -44,6 +44,18 @@ QPlatformGLContext::~QPlatformGLContext() { } +/*! + The frame buffer object that a QGLWidget is painted to and that gets bound + when a QGLFramebufferObject is released. + + The default implementation returns 0, which denotes the default + window-system provided frame buffer. +*/ +GLuint QPlatformGLContext::defaultFBO() const +{ + return 0; +} + static QPlatformGLContext *staticSharedContext = 0; void QPlatformGLContext::setDefaultSharedContext(QPlatformGLContext *sharedContext) diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h index d235848..9bfe676 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.h +++ b/src/gui/kernel/qplatformglcontext_qpa.h @@ -57,6 +57,7 @@ public: virtual void doneCurrent() = 0; virtual void swapBuffers() = 0; virtual void* getProcAddress(const QString& procName) = 0; + virtual GLuint defaultFBO() const; virtual QPlatformWindowFormat platformWindowFormat() const = 0; diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 5f0bca3..b05df64 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -139,6 +139,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) } d->platformContext = widget->platformWindow()->glContext(); Q_ASSERT(d->platformContext); + d->default_fbo = d->platformContext->defaultFBO(); d->glFormat = qt_platformwindowformat_to_glformat(d->platformContext->platformWindowFormat()); d->valid =(bool) d->platformContext; } diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index e1dcbfd..e12fdae 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -166,6 +166,12 @@ void QGLWidgetGLPaintDevice::setWidget(QGLWidget* w) void QGLWidgetGLPaintDevice::beginPaint() { + // ### This should be in setWidget(), but the context of the QGLWidget + // hasn't been set there yet. +#ifdef Q_WS_QPA + m_thisFBO = context()->d_ptr->platformContext->defaultFBO(); +#endif + QGLPaintDevice::beginPaint(); if (!glWidget->d_func()->disable_clear_on_painter_begin && glWidget->autoFillBackground()) { if (glWidget->testAttribute(Qt::WA_TranslucentBackground)) -- cgit v0.12 From 4a0ecee1fca85468c1cbcf8abb68f3d066ca4f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 6 Aug 2010 08:41:19 +0200 Subject: Make testlite work without glx --- src/plugins/platforms/testlite/qglxintegration.h | 2 -- src/plugins/platforms/testlite/qtestliteintegration.cpp | 5 +---- src/plugins/platforms/testlite/qtestlitewindow.cpp | 13 +++++++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h index 2f7c70e..562967a 100644 --- a/src/plugins/platforms/testlite/qglxintegration.h +++ b/src/plugins/platforms/testlite/qglxintegration.h @@ -87,8 +87,6 @@ private: static void createDefaultSharedContex(MyDisplay *xd); }; - - QT_END_NAMESPACE #endif diff --git a/src/plugins/platforms/testlite/qtestliteintegration.cpp b/src/plugins/platforms/testlite/qtestliteintegration.cpp index 3f500c0..a8e0fa7 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.cpp +++ b/src/plugins/platforms/testlite/qtestliteintegration.cpp @@ -52,10 +52,9 @@ #ifndef QT_NO_OPENGL #include -#include "qglxintegration.h" #include #include -#endif +#endif //QT_NO_OPENGL QT_BEGIN_NAMESPACE @@ -84,9 +83,7 @@ public: QTestLiteIntegration::QTestLiteIntegration(bool useOpenGL) -#ifndef QT_NO_OPENGL : mUseOpenGL(useOpenGL) -#endif { xd = new MyDisplay; diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index 39b2cc0..1f477db 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -42,6 +42,7 @@ #include "qtestliteintegration.h" #include #include +#include #include "qtestlitewindow.h" @@ -56,7 +57,9 @@ #include #include +#ifndef QT_NO_OPENGL #include "qglxintegration.h" +#endif #include #include @@ -157,8 +160,9 @@ QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration int w = window->width(); int h = window->height(); - if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL) { - + if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL + && QApplicationPrivate::platformIntegration()->hasOpenGL() ) { +#ifndef QT_NO_OPENGL XVisualInfo *visualInfo = QGLXGLContext::findVisualInfo(xd,window->platformWindowFormat()); Colormap cmap = XCreateColormap(xd->display,xd->rootWindow(),visualInfo->visual,AllocNone); @@ -167,6 +171,7 @@ QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration x_window = XCreateWindow(xd->display, xd->rootWindow(),x, y, w, h, 0, visualInfo->depth, InputOutput, visualInfo->visual, CWColormap, &a); +#endif //QT_NO_OPENGL } else { x_window = XCreateSimpleWindow(xd->display, xd->rootWindow(), x, y, w, h, 0 /*border_width*/, @@ -1012,9 +1017,13 @@ void QTestLiteWindow::setCursor(QCursor * cursor) QPlatformGLContext *QTestLiteWindow::glContext() const { + if (!QApplicationPrivate::platformIntegration()->hasOpenGL()) + return 0; if (!mGLContext) { QTestLiteWindow *that = const_cast(this); +#ifndef QT_NO_OPENGL that->mGLContext = new QGLXGLContext(x_window, xd, widget()->platformWindowFormat()); +#endif } return mGLContext; } -- cgit v0.12 From 783f218aac7c73837405af4893d8dd35b425a710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 6 Aug 2010 13:23:06 +0200 Subject: Fixed Lighthouse tempcontext to reset to current context and made glxintegrations shared context use the correct window configuration --- src/opengl/qgl_qpa.cpp | 13 ++++++++----- src/plugins/platforms/testlite/qglxintegration.cpp | 17 ++++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index b05df64..ad125fe 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -244,20 +244,23 @@ void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase) class QGLTemporaryContextPrivate { public: - QWidget *widget; + QGLWidget *widget; + QGLContext *context; }; QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) : d(new QGLTemporaryContextPrivate) { - d->widget = new QWidget; - d->widget->setGeometry(0,0,3,3); - d->widget->winId(); - d->widget->platformWindow()->glContext()->makeCurrent(); + d->context = const_cast(QGLContext::currentContext()); + d->context->doneCurrent(); + d->widget = new QGLWidget; + d->widget->makeCurrent(); } QGLTemporaryContext::~QGLTemporaryContext() { + d->widget->doneCurrent(); + d->context->makeCurrent(); delete d->widget; } diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index 47a4f5a..050643c 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -262,20 +262,27 @@ void QGLXGLContext::createDefaultSharedContex(MyDisplay *xd) int w = 3; int h = 3; - Window sharedWindow = XCreateSimpleWindow(xd->display, xd->rootWindow(), - x, y, w, h, 0 /*border_width*/, - xd->blackPixel(), xd->whitePixel()); - GLXContext context; QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat(); + GLXContext context; GLXFBConfig config = findConfig(xd,format); if (config) { + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(xd->display,config); + Colormap cmap = XCreateColormap(xd->display,xd->rootWindow(),visualInfo->visual,AllocNone); + XSetWindowAttributes a; + a.colormap = cmap; + Window sharedWindow = XCreateWindow(xd->display, xd->rootWindow(),x, y, w, h, + 0, visualInfo->depth, InputOutput, visualInfo->visual, + CWColormap, &a); + context = glXCreateNewContext(xd->display,config,GLX_RGBA_TYPE,0,TRUE); QPlatformGLContext *sharedContext = new QGLXGLContext(xd,sharedWindow,context); QPlatformGLContext::setDefaultSharedContext(sharedContext); } else { - qFatal("Warning no shared context created"); + qWarning("Warning no shared context created"); } + + } void QGLXGLContext::makeCurrent() -- cgit v0.12 From 1d8ce23abdb0bd980292e4a9c8d87c019585150a Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Fri, 6 Aug 2010 13:42:43 +0200 Subject: Add missing null check to lighthouse's QGLTemporaryContext. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jørgen Lind --- src/opengl/qgl_qpa.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index ad125fe..d87e668 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -252,7 +252,8 @@ QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) : d(new QGLTemporaryContextPrivate) { d->context = const_cast(QGLContext::currentContext()); - d->context->doneCurrent(); + if (d->context) + d->context->doneCurrent(); d->widget = new QGLWidget; d->widget->makeCurrent(); } @@ -260,7 +261,8 @@ QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) QGLTemporaryContext::~QGLTemporaryContext() { d->widget->doneCurrent(); - d->context->makeCurrent(); + if (d->context) + d->context->makeCurrent(); delete d->widget; } -- cgit v0.12 From 47bed030ffedded5914d8309bf2e1cccc1fd78d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 6 Aug 2010 15:10:20 +0200 Subject: Added reduced config to glxconfig should help if there are not many glxconfigs available. Also made QGLTemporaryContext use a QWidget again instead of a QGLWidget; This allows us to ask for a smaller window size before making the context. --- src/opengl/qgl_qpa.cpp | 14 +++-- src/plugins/platforms/testlite/qglxintegration.cpp | 68 ++++++++++++++++------ src/plugins/platforms/testlite/qglxintegration.h | 1 + 3 files changed, 60 insertions(+), 23 deletions(-) diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index d87e668..c328819 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -244,7 +244,7 @@ void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase) class QGLTemporaryContextPrivate { public: - QGLWidget *widget; + QWidget *widget; QGLContext *context; }; @@ -254,13 +254,19 @@ QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) d->context = const_cast(QGLContext::currentContext()); if (d->context) d->context->doneCurrent(); - d->widget = new QGLWidget; - d->widget->makeCurrent(); + d->widget = new QWidget; + d->widget->setGeometry(0,0,3,3); + QPlatformWindowFormat format = d->widget->platformWindowFormat(); + format.setWindowApi(QPlatformWindowFormat::OpenGL); + d->widget->winId(); + + + d->widget->platformWindow()->glContext()->makeCurrent(); } QGLTemporaryContext::~QGLTemporaryContext() { - d->widget->doneCurrent(); + d->widget->platformWindow()->glContext()->doneCurrent(); if (d->context) d->context->makeCurrent(); delete d->widget; diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index 050643c..ba161c1 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -113,28 +113,33 @@ QVector QGLXGLContext::buildSpec(const QPlatformWindowFormat &format) GLXFBConfig QGLXGLContext::findConfig(const MyDisplay *xd, const QPlatformWindowFormat &format) { - QVector spec = buildSpec(format); - int confcount = 0; - GLXFBConfig *configs; + bool reduced = true; GLXFBConfig chosenConfig = 0; - configs = glXChooseFBConfig(xd->display,xd->screen,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 (format.alpha()) { - int alphaSize; - glXGetFBConfigAttrib(xd->display,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 + QPlatformWindowFormat reducedFormat = format; + while (!chosenConfig && reduced) { + QVector spec = buildSpec(reducedFormat); + int confcount = 0; + GLXFBConfig *configs; + configs = glXChooseFBConfig(xd->display,xd->screen,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 (format.alpha()) { + int alphaSize; + glXGetFBConfigAttrib(xd->display,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); + XFree(configs); + } + reducedFormat = reducePlatformWindowFormat(format,&reduced); } if (!chosenConfig) @@ -206,6 +211,31 @@ QPlatformWindowFormat QGLXGLContext::platformWindowFromGLXFBConfig(Display *disp return format; } +QPlatformWindowFormat QGLXGLContext::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; +} + QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindowFormat &format) : QPlatformGLContext() , m_xd(xd) diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h index 562967a..479be4b 100644 --- a/src/plugins/platforms/testlite/qglxintegration.h +++ b/src/plugins/platforms/testlite/qglxintegration.h @@ -75,6 +75,7 @@ private: static GLXFBConfig findConfig(const MyDisplay *xd,const QPlatformWindowFormat &format); static QVector buildSpec(const QPlatformWindowFormat &format); static QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); + static QPlatformWindowFormat reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced); MyDisplay *m_xd; -- cgit v0.12 From eaf64f3a07533a30aa29eed85f6a3cbc744722a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 6 Aug 2010 16:31:15 +0200 Subject: Cleaned up in includes in Lighthouse headerfiles --- src/gui/kernel/qplatformglcontext_qpa.cpp | 2 +- src/gui/kernel/qplatformglcontext_qpa.h | 5 +++-- src/gui/kernel/qplatformintegration_qpa.h | 1 + src/gui/kernel/qplatformscreen_qpa.h | 9 ++++++++- src/plugins/platforms/eglconvenience/qeglconvenience.h | 2 +- src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp | 3 ++- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp index 4fcd9b8..516bf24 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.cpp +++ b/src/gui/kernel/qplatformglcontext_qpa.cpp @@ -51,7 +51,7 @@ QPlatformGLContext::~QPlatformGLContext() The default implementation returns 0, which denotes the default window-system provided frame buffer. */ -GLuint QPlatformGLContext::defaultFBO() const +unsigned long QPlatformGLContext::defaultFBO() const { return 0; } diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h index 9bfe676..3e7656b 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.h +++ b/src/gui/kernel/qplatformglcontext_qpa.h @@ -42,7 +42,8 @@ #ifndef QPLATFORM_GL_CONTEXT_H #define QPLATFORM_GL_CONTEXT_H -#include +#include +#include QT_BEGIN_HEADER @@ -57,7 +58,7 @@ public: virtual void doneCurrent() = 0; virtual void swapBuffers() = 0; virtual void* getProcAddress(const QString& procName) = 0; - virtual GLuint defaultFBO() const; + virtual unsigned long defaultFBO() const; virtual QPlatformWindowFormat platformWindowFormat() const = 0; diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h index 9f7367e..8cecbb4 100644 --- a/src/gui/kernel/qplatformintegration_qpa.h +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -43,6 +43,7 @@ #define QPLATFORMINTEGRATION_H #include +#include #include #include diff --git a/src/gui/kernel/qplatformscreen_qpa.h b/src/gui/kernel/qplatformscreen_qpa.h index f603db5..1704f0f 100644 --- a/src/gui/kernel/qplatformscreen_qpa.h +++ b/src/gui/kernel/qplatformscreen_qpa.h @@ -42,10 +42,17 @@ #ifndef QPLATFORMSCREEN_H #define QPLATFORMSCREEN_H +#include +#include +#include +#include #include -#include #include +#include +#include +#include + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h index 12731e1..484894b 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.h +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h @@ -41,11 +41,11 @@ #ifndef QEGLCONVENIENCE_H #define QEGLCONVENIENCE_H -#include #include #include +#include QT_BEGIN_NAMESPACE QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format); diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp index 87cd958..04720b5 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp @@ -41,12 +41,13 @@ #include "qeglplatformcontext.h" -#include #include #include "qeglconvenience.h" +#include + QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi) : QPlatformGLContext() , m_eglDisplay(display) -- cgit v0.12 From 3b048f8727a125eef2ac132d95dd3d9c2acbcab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 11 Aug 2010 11:01:53 +0200 Subject: Revert "Allow customizing the default fbo from the QPlatformGLContext." This reverts commit a8530e5db7ae25ea0ab5df4681308374abf8b6ba. Conflicts: src/gui/kernel/qplatformglcontext_qpa.cpp src/gui/kernel/qplatformglcontext_qpa.h --- src/gui/kernel/qplatformglcontext_qpa.cpp | 12 ------------ src/gui/kernel/qplatformglcontext_qpa.h | 1 - src/opengl/qgl_qpa.cpp | 1 - src/opengl/qglpaintdevice.cpp | 6 ------ 4 files changed, 20 deletions(-) diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp index 516bf24..36db2b0 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.cpp +++ b/src/gui/kernel/qplatformglcontext_qpa.cpp @@ -44,18 +44,6 @@ QPlatformGLContext::~QPlatformGLContext() { } -/*! - The frame buffer object that a QGLWidget is painted to and that gets bound - when a QGLFramebufferObject is released. - - The default implementation returns 0, which denotes the default - window-system provided frame buffer. -*/ -unsigned long QPlatformGLContext::defaultFBO() const -{ - return 0; -} - static QPlatformGLContext *staticSharedContext = 0; void QPlatformGLContext::setDefaultSharedContext(QPlatformGLContext *sharedContext) diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h index 3e7656b..ff848ed 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.h +++ b/src/gui/kernel/qplatformglcontext_qpa.h @@ -58,7 +58,6 @@ public: virtual void doneCurrent() = 0; virtual void swapBuffers() = 0; virtual void* getProcAddress(const QString& procName) = 0; - virtual unsigned long defaultFBO() const; virtual QPlatformWindowFormat platformWindowFormat() const = 0; diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index c328819..49c0860 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -139,7 +139,6 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) } d->platformContext = widget->platformWindow()->glContext(); Q_ASSERT(d->platformContext); - d->default_fbo = d->platformContext->defaultFBO(); d->glFormat = qt_platformwindowformat_to_glformat(d->platformContext->platformWindowFormat()); d->valid =(bool) d->platformContext; } diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index e12fdae..e1dcbfd 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -166,12 +166,6 @@ void QGLWidgetGLPaintDevice::setWidget(QGLWidget* w) void QGLWidgetGLPaintDevice::beginPaint() { - // ### This should be in setWidget(), but the context of the QGLWidget - // hasn't been set there yet. -#ifdef Q_WS_QPA - m_thisFBO = context()->d_ptr->platformContext->defaultFBO(); -#endif - QGLPaintDevice::beginPaint(); if (!glWidget->d_func()->disable_clear_on_painter_begin && glWidget->autoFillBackground()) { if (glWidget->testAttribute(Qt::WA_TranslucentBackground)) -- cgit v0.12 From 144f1f710ad46e89a7c07e94f80ac3744ace5c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 11 Aug 2010 11:07:19 +0200 Subject: Fix typo in glxintegration did actually not reduce the format more than one level, and if that didn't wasnt enough it would end up in an infinite loop. --- src/plugins/platforms/testlite/qglxintegration.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index ba161c1..fbffcab 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -125,9 +125,8 @@ GLXFBConfig QGLXGLContext::findConfig(const MyDisplay *xd, const QPlatformWindow { 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 (format.alpha()) { + if (reducedFormat.alpha()) { int alphaSize; glXGetFBConfigAttrib(xd->display,configs[i],GLX_ALPHA_SIZE,&alphaSize); if (alphaSize > 0) @@ -139,11 +138,11 @@ GLXFBConfig QGLXGLContext::findConfig(const MyDisplay *xd, const QPlatformWindow XFree(configs); } - reducedFormat = reducePlatformWindowFormat(format,&reduced); + reducedFormat = reducePlatformWindowFormat(reducedFormat,&reduced); } if (!chosenConfig) - qFatal("Warning no context created"); + qWarning("Warning no context created"); return chosenConfig; } -- cgit v0.12 From 660732ed870d584ef704941a4b6a00dc6c84f38e Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 18 Aug 2010 11:02:16 +0200 Subject: Only list activeqt once This caused build errors for the Windows platform. Looks like a merge error introduced in commit 075e96eba50 --- src/src.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/src/src.pro b/src/src.pro index 6118622..94ecb1b 100644 --- a/src/src.pro +++ b/src/src.pro @@ -6,7 +6,6 @@ win32:SRC_SUBDIRS += src_winmain symbian:SRC_SUBDIRS += src_s60main SRC_SUBDIRS += src_corelib src_xml src_network src_sql src_testlib nacl: SRC_SUBDIRS -= src_network src_testlib -win32:SRC_SUBDIRS += src_activeqt !symbian:contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus !contains(QT_CONFIG, no-gui): SRC_SUBDIRS += src_gui !wince*:!symbian:!vxworks:contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_qt3support -- cgit v0.12 From 411525a29e1d98c5e2a7052307bcd9e386710f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 18 Aug 2010 11:48:39 +0200 Subject: Lighthouse:Only native children uses setParent --- src/gui/kernel/qwidget_qpa.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index e11f1fc..b3599bd 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -109,9 +109,11 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO q_createNativeChildrenAndSetParent(q->platformWindow(),q); //if we we have a parent, then set correct parent; - if (QWidget *nativeParent = q->nativeParentWidget()) { - if (nativeParent->platformWindow()) { - platformWindow->setParent(nativeParent->platformWindow()); + if (!q->isWindow()) { + if (QWidget *nativeParent = q->nativeParentWidget()) { + if (nativeParent->platformWindow()) { + platformWindow->setParent(nativeParent->platformWindow()); + } } } -- cgit v0.12 From 9fb2afe3a31da4f08bdd5090a5b4aefd2035a46d Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 18 Aug 2010 12:27:08 +0200 Subject: Compile on Symbian after commit 075e96eba5001 --- src/corelib/thread/qthread_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 16a0a46..f8cf67d 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -465,7 +465,7 @@ void QThread::usleep(unsigned long usecs) // Does some magic and calculate the Unix scheduler priorities // sched_policy is IN/OUT: it must be set to a valid policy before calling this function // sched_priority is OUT only -#if defined(Q_OS_DARWIN) || !defined(Q_OS_OPENBSD) && !defined(Q_OS_SYMBIAN) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING-0 >= 0) +#if defined(Q_OS_DARWIN) || !defined(Q_OS_OPENBSD) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING-0 >= 0) static bool calculateUnixPriority(int priority, int *sched_policy, int *sched_priority) { #ifdef SCHED_IDLE -- cgit v0.12 From c02ad51733d0a2885ddb39cb7e3b09355ab97213 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 18 Aug 2010 12:51:00 +0200 Subject: Work around compile error with g++ for Windows --- src/gui/kernel/qapplication_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 628a041..b4a3f50 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -951,7 +951,7 @@ Q_GLOBAL_STATIC(WinClassNameHash, winclassNames) // const QString qt_reg_winclass(QWidget *w) // register window class { - int flags = w ? w->windowFlags() : 0; + int flags = w ? int(w->windowFlags()) : 0; int type = flags & Qt::WindowType_Mask; uint style; -- cgit v0.12 From 74d519f87e804b624ac76337fe2905d512d363fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 18 Aug 2010 14:22:09 +0200 Subject: Lighthouse: don't force sending key events to the TLW --- src/gui/kernel/qapplication_qpa.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index b89e81d..e5b5396 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -802,9 +802,6 @@ void QApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEven if (app_do_modal && !qt_try_modal(focusW, e->keyType)) return; - if (!focusW->isWindow()) - focusW = focusW->window(); - modifiers = e->modifiers; QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount); QApplication::sendSpontaneousEvent(focusW, &ev); -- cgit v0.12 From 5508ea53b0af0c580dbf7466bf2731dcbad399de Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 20 Aug 2010 10:26:50 +0200 Subject: Clean up lighthouse header files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes configure warnings Reviewed-by: Jørgen --- src/corelib/global/qglobal.h | 2 +- src/corelib/global/qnaclunimplemented.h | 8 ++++++++ src/gui/kernel/qplatformeventloopintegration_qpa.h | 12 +++++++++++- src/gui/kernel/qplatformglcontext_qpa.h | 4 +++- src/gui/kernel/qplatformintegration_qpa.h | 3 ++- src/gui/kernel/qplatformwindow_qpa.h | 2 ++ src/gui/kernel/qplatformwindowformat_qpa.h | 4 +++- src/gui/painting/qplatformcursor_qpa.h | 20 +++++++++++++------- 8 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 2d37a59..4b25503 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2666,7 +2666,7 @@ QT_LICENSED_MODULE(DBus) #endif #ifdef Q_OS_NACL -#include +#include #endif QT_END_NAMESPACE diff --git a/src/corelib/global/qnaclunimplemented.h b/src/corelib/global/qnaclunimplemented.h index 84085b5..ba43915 100644 --- a/src/corelib/global/qnaclunimplemented.h +++ b/src/corelib/global/qnaclunimplemented.h @@ -50,6 +50,10 @@ #define PTHREAD_CANCEL_ENABLE 2 #define PTHREAD_INHERIT_SCHED 3 +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + extern "C" { void pthread_cleanup_push(void (*handler)(void *), void *arg); @@ -80,6 +84,10 @@ int open64(const char *path, int oflag, ...); int select(int nfds, fd_set * readfds, fd_set * writefds, fd_set * errorfds, struct timeval * timeout); +QT_END_NAMESPACE + +QT_END_HEADER + #endif //Q_OS_NACL #endif //QNACLUNIMPLEMENTED_H diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.h b/src/gui/kernel/qplatformeventloopintegration_qpa.h index 5e4c227..7343566 100644 --- a/src/gui/kernel/qplatformeventloopintegration_qpa.h +++ b/src/gui/kernel/qplatformeventloopintegration_qpa.h @@ -1,7 +1,13 @@ #ifndef QPLATFORMEVENTLOOPINTEGRATION_QPA_H #define QPLATFORMEVENTLOOPINTEGRATION_QPA_H -#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) class QPlatformEventLoopIntegration { @@ -10,4 +16,8 @@ public: virtual void wakeup() = 0; }; +QT_END_NAMESPACE + +QT_END_HEADER + #endif // QPLATFORMEVENTLOOPINTEGRATION_QPA_H diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h index ff848ed..ed41723 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.h +++ b/src/gui/kernel/qplatformglcontext_qpa.h @@ -43,12 +43,14 @@ #define QPLATFORM_GL_CONTEXT_H #include -#include +#include QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +QT_MODULE(Gui) + class Q_OPENGL_EXPORT QPlatformGLContext { public: diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h index 8cecbb4..9460910 100644 --- a/src/gui/kernel/qplatformintegration_qpa.h +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -51,7 +51,8 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -//QT_MODULE(Gui) +QT_MODULE(Gui) + class QPlatformWindow; class QWindowSurface; class QBlittable; diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h index 2275c02..6dfba05 100644 --- a/src/gui/kernel/qplatformwindow_qpa.h +++ b/src/gui/kernel/qplatformwindow_qpa.h @@ -52,6 +52,8 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +QT_MODULE(Gui) + class QPlatformWindowPrivate; class QWidget; class QPlatformGLContext; diff --git a/src/gui/kernel/qplatformwindowformat_qpa.h b/src/gui/kernel/qplatformwindowformat_qpa.h index 075e796..63df76a 100644 --- a/src/gui/kernel/qplatformwindowformat_qpa.h +++ b/src/gui/kernel/qplatformwindowformat_qpa.h @@ -41,12 +41,14 @@ #ifndef QPLATFORMWINDOWFORMAT_QPA_H #define QPLATFORMWINDOWFORMAT_QPA_H -#include +#include QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +QT_MODULE(Gui) + class QPlatformWindowFormatPrivate; class Q_GUI_EXPORT QPlatformWindowFormat diff --git a/src/gui/painting/qplatformcursor_qpa.h b/src/gui/painting/qplatformcursor_qpa.h index 5f1654d..abdbfee 100644 --- a/src/gui/painting/qplatformcursor_qpa.h +++ b/src/gui/painting/qplatformcursor_qpa.h @@ -41,16 +41,20 @@ #ifndef QGRAPHICSSYSTEMCURSOR_H #define QGRAPHICSSYSTEMCURSOR_H -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +QT_MODULE(Gui) + // Cursor graphics management class Q_GUI_EXPORT QPlatformCursorImage { public: @@ -94,4 +98,6 @@ private: QT_END_NAMESPACE +QT_END_HEADER + #endif // QGRAPHICSSYSTEMCURSOR_H -- cgit v0.12 From 53ce5a08f5a0a4e09ec81486275039afbf76fe3c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 20 Aug 2010 12:14:34 +0200 Subject: Move qplatformcursor from gui/painting to gui/kernel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jørgen --- src/gui/kernel/kernel.pri | 6 +- src/gui/kernel/qplatformcursor_qpa.cpp | 664 +++++++++++++++++++++++++++++++ src/gui/kernel/qplatformcursor_qpa.h | 103 +++++ src/gui/painting/painting.pri | 5 +- src/gui/painting/qplatformcursor_qpa.cpp | 664 ------------------------------- src/gui/painting/qplatformcursor_qpa.h | 103 ----- 6 files changed, 772 insertions(+), 773 deletions(-) create mode 100644 src/gui/kernel/qplatformcursor_qpa.cpp create mode 100644 src/gui/kernel/qplatformcursor_qpa.h delete mode 100644 src/gui/painting/qplatformcursor_qpa.cpp delete mode 100644 src/gui/painting/qplatformcursor_qpa.h diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 9941b1b..703a1cb 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -221,7 +221,8 @@ qpa { kernel/qplatformwindowformat_qpa.h \ kernel/qplatformglcontext_qpa.h \ kernel/qdesktopwidget_qpa_p.h \ - kernel/qplatformeventloopintegration_qpa.h + kernel/qplatformeventloopintegration_qpa.h \ + painting/qplatformcursor_qpa.h SOURCES += \ kernel/qapplication_qpa.cpp \ @@ -242,7 +243,8 @@ qpa { kernel/qplatformwindow_qpa.cpp \ kernel/qplatformwindowformat_qpa.cpp \ kernel/qplatformeventloopintegration_qpa.cpp \ - kernel/qplatformglcontext_qpa.cpp + kernel/qplatformglcontext_qpa.cpp \ + painting/qplatformcursor_qpa.cpp contains(QT_CONFIG, glib) { SOURCES += \ diff --git a/src/gui/kernel/qplatformcursor_qpa.cpp b/src/gui/kernel/qplatformcursor_qpa.cpp new file mode 100644 index 0000000..6665396 --- /dev/null +++ b/src/gui/kernel/qplatformcursor_qpa.cpp @@ -0,0 +1,664 @@ +/**************************************************************************** +** +** 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 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 "qplatformcursor_qpa.h" + +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +QList > QPlatformCursorPrivate::instances; + +/*! + \class QGraphicsSystemCursor + + \brief The QGraphicsSystemCursor class provides information about + pointer device events (movement, buttons), and requests to change + the currently displayed cursor. + + Note that QGraphicsSystemCursor does not include any graphics for + display. An application that sets a QCursor may provide its own + graphics. + + \sa QGraphicsSystemCursorImage +*/ + +/*! + \fn virtual void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & event) + + This method is called by Qt whenever a QMouseEvent is generated by the + underlying pointer input. \a event is a reference to the QMouseEvent in + question. A default do-nothing implementation is provided. + + \sa QApplicationPrivate::handleMouseEvent() +*/ + +/*! + \fn virtual void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) + + \brief This method is called by Qt whenever the cursor graphic should be changed. + + Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor. + + \a widgetCursor is a pointer to the QCursor that should be displayed. + + \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note + that this may be 0 if the current position is not occupied by a displayed widget. + + \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos() +*/ + +/*! + \fn QGraphicsSystemCursor::QGraphicsSystemCursor() + + \brief Constructs a QGraphicsSystemCursor +*/ +QPlatformCursor::QPlatformCursor(QPlatformScreen *scr ) + : screen(scr) +{ + QPlatformCursorPrivate::instances.append(this); +} + +// End of display and pointer event handling code +// Beginning of built-in cursor graphics +// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp + +/*! + \class QGraphicsSystemCursorImage + + \brief The QGraphicsSystemCursorImage class provides a set of graphics + intended to be used as cursors. + + \sa QGraphicsSystemCursor +*/ + +static QPlatformCursorImage *systemCursorTable[Qt::LastCursor+1]; +static bool systemCursorTableInit = false; + +// 16 x 16 +static const uchar cur_arrow_bits[] = { + 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08, + 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22, + 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 }; +static const uchar mcur_arrow_bits[] = { + 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f, + 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e, + 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 }; + +static const unsigned char cur_up_arrow_bits[] = { + 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, + 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01}; +static const unsigned char mcur_up_arrow_bits[] = { + 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07, + 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01}; + +static const unsigned char cur_cross_bits[] = { + 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, + 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00}; +static const unsigned char mcur_cross_bits[] = { + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; + +static const uchar cur_ibeam_bits[] = { + 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, + 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, + 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_ibeam_bits[] = { + 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 }; + +static const uchar cur_ver_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, + 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, + 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; +static const uchar mcur_ver_bits[] = { + 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, + 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, + 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; + +static const uchar cur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, + 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, + 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, + 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; +static const uchar cur_bdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, + 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, + 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_bdiag_bits[] = { + 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, + 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, + 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; +static const uchar cur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, + 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, + 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; +static const uchar mcur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, + 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, + 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; +static const uchar cur_blank_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +// 20 x 20 +static const uchar forbidden_bits[] = { + 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, + 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, + 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, + 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; + +static const uchar forbiddenm_bits[] = { + 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, + 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, + 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, + 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; + +// 32 x 32 +static const uchar wait_data_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00, + 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, + 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00, + 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, + 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00, + 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar wait_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, + 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00, + 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, + 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, + 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar hsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, + 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar hsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, + 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, + 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, + 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar vsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar vsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar phand_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, + 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00, + 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00, + 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, + 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar phandm_bits[] = { + 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, + 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, + 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, + 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, + 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar size_all_data_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00, + 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const uchar size_all_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00, + 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01, + 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00, + 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uchar whatsthis_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, + 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, + 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, + 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, + 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, + 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; +static const uchar whatsthism_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, + 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, + 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, + 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, + 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, + 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + +static const uchar busy_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, + 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, + 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, + 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, + 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static const uchar busym_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, + 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, + 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, + 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, + 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +// 16 x 16 +static const uchar openhand_bits[] = { + 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, + 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, + 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; +static const uchar openhandm_bits[] = { + 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, + 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, + 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; +static const uchar closedhand_bits[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, + 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, + 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; +static const uchar closedhandm_bits[] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, + 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, + 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; + +void QPlatformCursorImage::createSystemCursor(int id) +{ + if (!systemCursorTableInit) { + for (int i = 0; i <= Qt::LastCursor; i++) + systemCursorTable[i] = 0; + systemCursorTableInit = true; + } + switch (id) { + // 16x16 cursors + case Qt::ArrowCursor: + systemCursorTable[Qt::ArrowCursor] = + new QPlatformCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0); + break; + + case Qt::UpArrowCursor: + systemCursorTable[Qt::UpArrowCursor] = + new QPlatformCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0); + break; + + case Qt::CrossCursor: + systemCursorTable[Qt::CrossCursor] = + new QPlatformCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7); + break; + + case Qt::IBeamCursor: + systemCursorTable[Qt::IBeamCursor] = + new QPlatformCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7); + break; + + case Qt::SizeVerCursor: + systemCursorTable[Qt::SizeVerCursor] = + new QPlatformCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7); + break; + + case Qt::SizeHorCursor: + systemCursorTable[Qt::SizeHorCursor] = + new QPlatformCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7); + break; + + case Qt::SizeBDiagCursor: + systemCursorTable[Qt::SizeBDiagCursor] = + new QPlatformCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7); + break; + + case Qt::SizeFDiagCursor: + systemCursorTable[Qt::SizeFDiagCursor] = + new QPlatformCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7); + break; + + case Qt::BlankCursor: + systemCursorTable[Qt::BlankCursor] = + new QPlatformCursorImage(0, 0, 0, 0, 0, 0); + break; + + // 20x20 cursors + case Qt::ForbiddenCursor: + systemCursorTable[Qt::ForbiddenCursor] = + new QPlatformCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10); + break; + + // 32x32 cursors + case Qt::WaitCursor: + systemCursorTable[Qt::WaitCursor] = + new QPlatformCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15); + break; + + case Qt::SplitVCursor: + systemCursorTable[Qt::SplitVCursor] = + new QPlatformCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15); + break; + + case Qt::SplitHCursor: + systemCursorTable[Qt::SplitHCursor] = + new QPlatformCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15); + break; + + case Qt::SizeAllCursor: + systemCursorTable[Qt::SizeAllCursor] = + new QPlatformCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15); + break; + + case Qt::PointingHandCursor: + systemCursorTable[Qt::PointingHandCursor] = + new QPlatformCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0); + break; + + case Qt::WhatsThisCursor: + systemCursorTable[Qt::WhatsThisCursor] = + new QPlatformCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0); + break; + case Qt::BusyCursor: + systemCursorTable[Qt::BusyCursor] = + new QPlatformCursorImage(busy_bits, busym_bits, 32, 32, 0, 0); + break; + + case Qt::OpenHandCursor: + systemCursorTable[Qt::OpenHandCursor] = + new QPlatformCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8); + break; + case Qt::ClosedHandCursor: + systemCursorTable[Qt::ClosedHandCursor] = + new QPlatformCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8); + break; + default: + qWarning("Unknown system cursor %d", id); + } +} + +/*! + \fn void QGraphicsSystemCursorImage::set(Qt::CursorShape id) + + \brief Calling this method sets the cursor image to the specified shape + + \a id is one of the defined Qt::CursorShape values. + + If id is invalid, Qt::BitmapCursor, or unknown by the implementation, + Qt::ArrowCursor is used instead. +*/ + +void QPlatformCursorImage::set(Qt::CursorShape id) +{ + QPlatformCursorImage *cursor = 0; + if (id >= 0 && id <= Qt::LastCursor) { + if (!systemCursorTable[id]) + createSystemCursor(id); + cursor = systemCursorTable[id]; + } + + if (cursor == 0) { + if (!systemCursorTable[Qt::ArrowCursor]) + createSystemCursor(Qt::ArrowCursor); + cursor = systemCursorTable[Qt::ArrowCursor]; + } + cursorImage = cursor->cursorImage; + hot = cursor->hot; +} + +/*! + \fn void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) + + \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy) + + \a image A pointer to a QImage + + \a hx The x coordinate of the cursor's hotspot + + \a hy the y coordinate of the cursor's hotspot +*/ + +void QPlatformCursorImage::set(const QImage * image, int hx, int hy) +{ + hot.setX(hx); + hot.setY(hy); + cursorImage = *image; +} + +/*! + \fn void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) + + \brief set the cursor image to the graphic represented by the combination of data, mask, + width, and height + + \a data The pixel data of the graphic + + \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn + + \a width The width of the graphic in pixels + + \a height The height of the graphic in pixels + + \a hx The X hotspot of the cursor graphic + + \a hy The Y hotspot of the cursor graphic +*/ +void QPlatformCursorImage::set(const uchar *data, const uchar *mask, + int width, int height, int hx, int hy) +{ + hot.setX(hx); + hot.setY(hy); + + cursorImage = QImage(width,height, QImage::Format_Indexed8); + + if (!width || !height || !data || !mask || cursorImage.isNull()) + return; + + cursorImage.setNumColors(3); + cursorImage.setColor(0, 0xff000000); + cursorImage.setColor(1, 0xffffffff); + cursorImage.setColor(2, 0x00000000); + + int bytesPerLine = (width + 7) / 8; + int p = 0; + int d, m; + + int x = -1, w = 0; + + uchar *cursor_data = cursorImage.bits(); + int bpl = cursorImage.bytesPerLine(); + for (int i = 0; i < height; i++) + { + for (int j = 0; j < bytesPerLine; j++, data++, mask++) + { + for (int b = 0; b < 8 && j*8+b < width; b++) + { + d = *data & (1 << b); + m = *mask & (1 << b); + if (d && m) p = 0; + else if (!d && m) p = 1; + else p = 2; + cursor_data[j*8+b] = p; + + // calc region + if (x < 0 && m) + x = j*8+b; + else if (x >= 0 && !m) { + x = -1; + w = 0; + } + if (m) + w++; + } + } + if (x >= 0) { + x = -1; + w = 0; + } + cursor_data += bpl; + } + +} + +/*! + \fn QGraphicsSystemCursorImage::QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + + \brief set the cursor image to the graphic represented by the combination of data, mask, + width, and height + + \a data The pixel data of the graphic + + \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn + + \a width The width of the graphic in pixels + + \a height The height of the graphic in pixels + + \a hotX The X hotspot of the cursor graphic + + \a hotY The Y hotspot of the cursor graphic + + \sa set +*/ + +/*! + \fn QImage *QGraphicsSystemCursorImage::image() + + \brief Return the cursor graphic as a pointer to a QImage +*/ + +/*! + \fn QPoint QGraphicsSystemCursorImage::hotspot() + + \brief Return the cursor's hotspot +*/ + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformcursor_qpa.h b/src/gui/kernel/qplatformcursor_qpa.h new file mode 100644 index 0000000..abdbfee --- /dev/null +++ b/src/gui/kernel/qplatformcursor_qpa.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QGRAPHICSSYSTEMCURSOR_H +#define QGRAPHICSSYSTEMCURSOR_H + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +// Cursor graphics management +class Q_GUI_EXPORT QPlatformCursorImage { +public: + QPlatformCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) + { set(data, mask, width, height, hotX, hotY); } + QImage * image() { return &cursorImage; } + QPoint hotspot() { return hot; } + void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); + void set(const QImage * image, int hx, int hy); + void set(Qt::CursorShape); +private: + static void createSystemCursor(int id); + QImage cursorImage; + QPoint hot; +}; + +class QPlatformCursor; + +class QPlatformCursorPrivate { +public: + static QList > getInstances() { return instances; } + static QList > instances; +}; + +class Q_GUI_EXPORT QPlatformCursor : public QObject { +public: + QPlatformCursor(QPlatformScreen *); + + // input methods + virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } + virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0; + +protected: + QPlatformScreen* screen; // Where to request an update + +private: + Q_DECLARE_PRIVATE(QPlatformCursor); + friend void qt_qpa_set_cursor(QWidget * w, bool force); + friend class QApplicationPrivate; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QGRAPHICSSYSTEMCURSOR_H diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 1f76b6f..088ad42 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -188,10 +188,7 @@ embedded { qpa { SOURCES += \ painting/qcolormap_qpa.cpp \ - painting/qpaintdevice_qpa.cpp \ - painting/qplatformcursor_qpa.cpp - HEADERS += \ - painting/qplatformcursor_qpa.h + painting/qpaintdevice_qpa.cpp } symbian { diff --git a/src/gui/painting/qplatformcursor_qpa.cpp b/src/gui/painting/qplatformcursor_qpa.cpp deleted file mode 100644 index 6665396..0000000 --- a/src/gui/painting/qplatformcursor_qpa.cpp +++ /dev/null @@ -1,664 +0,0 @@ -/**************************************************************************** -** -** 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 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 "qplatformcursor_qpa.h" - -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -QList > QPlatformCursorPrivate::instances; - -/*! - \class QGraphicsSystemCursor - - \brief The QGraphicsSystemCursor class provides information about - pointer device events (movement, buttons), and requests to change - the currently displayed cursor. - - Note that QGraphicsSystemCursor does not include any graphics for - display. An application that sets a QCursor may provide its own - graphics. - - \sa QGraphicsSystemCursorImage -*/ - -/*! - \fn virtual void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & event) - - This method is called by Qt whenever a QMouseEvent is generated by the - underlying pointer input. \a event is a reference to the QMouseEvent in - question. A default do-nothing implementation is provided. - - \sa QApplicationPrivate::handleMouseEvent() -*/ - -/*! - \fn virtual void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget) - - \brief This method is called by Qt whenever the cursor graphic should be changed. - - Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor. - - \a widgetCursor is a pointer to the QCursor that should be displayed. - - \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note - that this may be 0 if the current position is not occupied by a displayed widget. - - \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos() -*/ - -/*! - \fn QGraphicsSystemCursor::QGraphicsSystemCursor() - - \brief Constructs a QGraphicsSystemCursor -*/ -QPlatformCursor::QPlatformCursor(QPlatformScreen *scr ) - : screen(scr) -{ - QPlatformCursorPrivate::instances.append(this); -} - -// End of display and pointer event handling code -// Beginning of built-in cursor graphics -// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp - -/*! - \class QGraphicsSystemCursorImage - - \brief The QGraphicsSystemCursorImage class provides a set of graphics - intended to be used as cursors. - - \sa QGraphicsSystemCursor -*/ - -static QPlatformCursorImage *systemCursorTable[Qt::LastCursor+1]; -static bool systemCursorTableInit = false; - -// 16 x 16 -static const uchar cur_arrow_bits[] = { - 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08, - 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22, - 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 }; -static const uchar mcur_arrow_bits[] = { - 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f, - 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e, - 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 }; - -static const unsigned char cur_up_arrow_bits[] = { - 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04, - 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01}; -static const unsigned char mcur_up_arrow_bits[] = { - 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07, - 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01}; - -static const unsigned char cur_cross_bits[] = { - 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, - 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00}; -static const unsigned char mcur_cross_bits[] = { - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; - -static const uchar cur_ibeam_bits[] = { - 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, - 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, - 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_ibeam_bits[] = { - 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 }; - -static const uchar cur_ver_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, - 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, - 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; -static const uchar mcur_ver_bits[] = { - 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, - 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, - 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; - -static const uchar cur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, - 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, - 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, - 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; -static const uchar cur_bdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, - 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, - 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_bdiag_bits[] = { - 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, - 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, - 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; -static const uchar cur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, - 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, - 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; -static const uchar mcur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, - 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, - 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; -static const uchar cur_blank_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -// 20 x 20 -static const uchar forbidden_bits[] = { - 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, - 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, - 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, - 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; - -static const uchar forbiddenm_bits[] = { - 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, - 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, - 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, - 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; - -// 32 x 32 -static const uchar wait_data_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00, - 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, - 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00, - 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, - 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00, - 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar wait_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00, - 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00, - 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, - 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, - 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar hsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, - 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar hsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, - 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, - 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, - 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar vsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar vsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar phand_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, - 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00, - 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00, - 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, - 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar phandm_bits[] = { - 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, - 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, - 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, - 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, - 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar size_all_data_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00, - 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static const uchar size_all_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00, - 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01, - 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00, - 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -static const uchar whatsthis_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, - 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, - 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, - 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, - 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, - 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -static const uchar whatsthism_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, - 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, - 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, - 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, - 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, - 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - -static const uchar busy_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, - 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, - 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, - 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, - 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static const uchar busym_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, - 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, - 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, - 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, - 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, - 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -// 16 x 16 -static const uchar openhand_bits[] = { - 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, - 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, - 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; -static const uchar openhandm_bits[] = { - 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, - 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, - 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; -static const uchar closedhand_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, - 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, - 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; -static const uchar closedhandm_bits[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, - 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, - 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; - -void QPlatformCursorImage::createSystemCursor(int id) -{ - if (!systemCursorTableInit) { - for (int i = 0; i <= Qt::LastCursor; i++) - systemCursorTable[i] = 0; - systemCursorTableInit = true; - } - switch (id) { - // 16x16 cursors - case Qt::ArrowCursor: - systemCursorTable[Qt::ArrowCursor] = - new QPlatformCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0); - break; - - case Qt::UpArrowCursor: - systemCursorTable[Qt::UpArrowCursor] = - new QPlatformCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0); - break; - - case Qt::CrossCursor: - systemCursorTable[Qt::CrossCursor] = - new QPlatformCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7); - break; - - case Qt::IBeamCursor: - systemCursorTable[Qt::IBeamCursor] = - new QPlatformCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7); - break; - - case Qt::SizeVerCursor: - systemCursorTable[Qt::SizeVerCursor] = - new QPlatformCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7); - break; - - case Qt::SizeHorCursor: - systemCursorTable[Qt::SizeHorCursor] = - new QPlatformCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7); - break; - - case Qt::SizeBDiagCursor: - systemCursorTable[Qt::SizeBDiagCursor] = - new QPlatformCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7); - break; - - case Qt::SizeFDiagCursor: - systemCursorTable[Qt::SizeFDiagCursor] = - new QPlatformCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7); - break; - - case Qt::BlankCursor: - systemCursorTable[Qt::BlankCursor] = - new QPlatformCursorImage(0, 0, 0, 0, 0, 0); - break; - - // 20x20 cursors - case Qt::ForbiddenCursor: - systemCursorTable[Qt::ForbiddenCursor] = - new QPlatformCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10); - break; - - // 32x32 cursors - case Qt::WaitCursor: - systemCursorTable[Qt::WaitCursor] = - new QPlatformCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15); - break; - - case Qt::SplitVCursor: - systemCursorTable[Qt::SplitVCursor] = - new QPlatformCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15); - break; - - case Qt::SplitHCursor: - systemCursorTable[Qt::SplitHCursor] = - new QPlatformCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15); - break; - - case Qt::SizeAllCursor: - systemCursorTable[Qt::SizeAllCursor] = - new QPlatformCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15); - break; - - case Qt::PointingHandCursor: - systemCursorTable[Qt::PointingHandCursor] = - new QPlatformCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0); - break; - - case Qt::WhatsThisCursor: - systemCursorTable[Qt::WhatsThisCursor] = - new QPlatformCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0); - break; - case Qt::BusyCursor: - systemCursorTable[Qt::BusyCursor] = - new QPlatformCursorImage(busy_bits, busym_bits, 32, 32, 0, 0); - break; - - case Qt::OpenHandCursor: - systemCursorTable[Qt::OpenHandCursor] = - new QPlatformCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8); - break; - case Qt::ClosedHandCursor: - systemCursorTable[Qt::ClosedHandCursor] = - new QPlatformCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8); - break; - default: - qWarning("Unknown system cursor %d", id); - } -} - -/*! - \fn void QGraphicsSystemCursorImage::set(Qt::CursorShape id) - - \brief Calling this method sets the cursor image to the specified shape - - \a id is one of the defined Qt::CursorShape values. - - If id is invalid, Qt::BitmapCursor, or unknown by the implementation, - Qt::ArrowCursor is used instead. -*/ - -void QPlatformCursorImage::set(Qt::CursorShape id) -{ - QPlatformCursorImage *cursor = 0; - if (id >= 0 && id <= Qt::LastCursor) { - if (!systemCursorTable[id]) - createSystemCursor(id); - cursor = systemCursorTable[id]; - } - - if (cursor == 0) { - if (!systemCursorTable[Qt::ArrowCursor]) - createSystemCursor(Qt::ArrowCursor); - cursor = systemCursorTable[Qt::ArrowCursor]; - } - cursorImage = cursor->cursorImage; - hot = cursor->hot; -} - -/*! - \fn void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy) - - \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy) - - \a image A pointer to a QImage - - \a hx The x coordinate of the cursor's hotspot - - \a hy the y coordinate of the cursor's hotspot -*/ - -void QPlatformCursorImage::set(const QImage * image, int hx, int hy) -{ - hot.setX(hx); - hot.setY(hy); - cursorImage = *image; -} - -/*! - \fn void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy) - - \brief set the cursor image to the graphic represented by the combination of data, mask, - width, and height - - \a data The pixel data of the graphic - - \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn - - \a width The width of the graphic in pixels - - \a height The height of the graphic in pixels - - \a hx The X hotspot of the cursor graphic - - \a hy The Y hotspot of the cursor graphic -*/ -void QPlatformCursorImage::set(const uchar *data, const uchar *mask, - int width, int height, int hx, int hy) -{ - hot.setX(hx); - hot.setY(hy); - - cursorImage = QImage(width,height, QImage::Format_Indexed8); - - if (!width || !height || !data || !mask || cursorImage.isNull()) - return; - - cursorImage.setNumColors(3); - cursorImage.setColor(0, 0xff000000); - cursorImage.setColor(1, 0xffffffff); - cursorImage.setColor(2, 0x00000000); - - int bytesPerLine = (width + 7) / 8; - int p = 0; - int d, m; - - int x = -1, w = 0; - - uchar *cursor_data = cursorImage.bits(); - int bpl = cursorImage.bytesPerLine(); - for (int i = 0; i < height; i++) - { - for (int j = 0; j < bytesPerLine; j++, data++, mask++) - { - for (int b = 0; b < 8 && j*8+b < width; b++) - { - d = *data & (1 << b); - m = *mask & (1 << b); - if (d && m) p = 0; - else if (!d && m) p = 1; - else p = 2; - cursor_data[j*8+b] = p; - - // calc region - if (x < 0 && m) - x = j*8+b; - else if (x >= 0 && !m) { - x = -1; - w = 0; - } - if (m) - w++; - } - } - if (x >= 0) { - x = -1; - w = 0; - } - cursor_data += bpl; - } - -} - -/*! - \fn QGraphicsSystemCursorImage::QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) - - \brief set the cursor image to the graphic represented by the combination of data, mask, - width, and height - - \a data The pixel data of the graphic - - \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn - - \a width The width of the graphic in pixels - - \a height The height of the graphic in pixels - - \a hotX The X hotspot of the cursor graphic - - \a hotY The Y hotspot of the cursor graphic - - \sa set -*/ - -/*! - \fn QImage *QGraphicsSystemCursorImage::image() - - \brief Return the cursor graphic as a pointer to a QImage -*/ - -/*! - \fn QPoint QGraphicsSystemCursorImage::hotspot() - - \brief Return the cursor's hotspot -*/ - -QT_END_NAMESPACE diff --git a/src/gui/painting/qplatformcursor_qpa.h b/src/gui/painting/qplatformcursor_qpa.h deleted file mode 100644 index abdbfee..0000000 --- a/src/gui/painting/qplatformcursor_qpa.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenVG module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QGRAPHICSSYSTEMCURSOR_H -#define QGRAPHICSSYSTEMCURSOR_H - -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -// Cursor graphics management -class Q_GUI_EXPORT QPlatformCursorImage { -public: - QPlatformCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) - { set(data, mask, width, height, hotX, hotY); } - QImage * image() { return &cursorImage; } - QPoint hotspot() { return hot; } - void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); - void set(const QImage * image, int hx, int hy); - void set(Qt::CursorShape); -private: - static void createSystemCursor(int id); - QImage cursorImage; - QPoint hot; -}; - -class QPlatformCursor; - -class QPlatformCursorPrivate { -public: - static QList > getInstances() { return instances; } - static QList > instances; -}; - -class Q_GUI_EXPORT QPlatformCursor : public QObject { -public: - QPlatformCursor(QPlatformScreen *); - - // input methods - virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } - virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0; - -protected: - QPlatformScreen* screen; // Where to request an update - -private: - Q_DECLARE_PRIVATE(QPlatformCursor); - friend void qt_qpa_set_cursor(QWidget * w, bool force); - friend class QApplicationPrivate; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGRAPHICSSYSTEMCURSOR_H -- cgit v0.12 From c0c2e556e98ffe550cbedb4e3a0def5dd272ce25 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 25 Aug 2010 11:31:15 +0200 Subject: qdrawhelper: fix assert in fetchTransformedBilinear There can be rounding errors. Reviewed-by: paul --- src/gui/painting/qdrawhelper.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index d6beb72..c5704fb 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -747,7 +747,6 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * if (fdx <= fixed_scale && fdx > 0) { // scale up on X int disty = (fy & 0x0000ffff) >> 8; int idisty = 256 - disty; - int count = length * data->m11 + 2; int x = fx >> 16; // The idea is first to do the interpolation between the row s1 and the row s2 @@ -756,7 +755,9 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * // intermediate_buffer[0] is a buffer of red-blue component of the pixel, in the form 0x00RR00BB // intermediate_buffer[1] is the alpha-green component of the pixel, in the form 0x00AA00GG quint32 intermediate_buffer[2][buffer_size + 2]; - Q_ASSERT(length * data->m11 <= buffer_size); + // count is the size used in the intermediate_buffer. + int count = qCeil(length * data->m11) + 2; //+1 for the last pixel to interpolate with, and +1 for rounding errors. + Q_ASSERT(count <= buffer_size + 2); //length is supposed to be <= buffer_size and data->m11 < 1 in this case int f = 0; int lim = count; if (blendType == BlendTransformedBilinearTiled) { -- cgit v0.12 From db76fd9b3cc0acb49c7c017c85ac3326953167f5 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 26 Aug 2010 12:01:57 +0200 Subject: Oops, fix cut and paste bug in kernel.pri --- src/gui/kernel/kernel.pri | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 703a1cb..4d9110a 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -222,7 +222,7 @@ qpa { kernel/qplatformglcontext_qpa.h \ kernel/qdesktopwidget_qpa_p.h \ kernel/qplatformeventloopintegration_qpa.h \ - painting/qplatformcursor_qpa.h + kernel/qplatformcursor_qpa.h SOURCES += \ kernel/qapplication_qpa.cpp \ @@ -244,7 +244,7 @@ qpa { kernel/qplatformwindowformat_qpa.cpp \ kernel/qplatformeventloopintegration_qpa.cpp \ kernel/qplatformglcontext_qpa.cpp \ - painting/qplatformcursor_qpa.cpp + kernel/qplatformcursor_qpa.cpp contains(QT_CONFIG, glib) { SOURCES += \ -- cgit v0.12 From de66ffa4d7d057f0c782edc45374ad58322a0c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 26 Aug 2010 09:55:31 +0200 Subject: Remove listing all platform plugins on load --- src/gui/kernel/qplatformintegrationfactory_qpa.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/kernel/qplatformintegrationfactory_qpa.cpp b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp index 4f2bfa5..9122e1a 100644 --- a/src/gui/kernel/qplatformintegrationfactory_qpa.cpp +++ b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp @@ -61,7 +61,6 @@ QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key) QString platform = paramList.takeFirst().toLower(); #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) - qDebug() << loader()->keys(); if (QPlatformIntegrationFactoryInterface *factory = qobject_cast(loader()->instance(platform))) ret = factory->create(platform, paramList); #endif -- cgit v0.12 From 5e7fdcc7a4a2bb070ad7ece920ac5db81e3e6f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 20 Aug 2010 12:33:33 +0200 Subject: Initial pluggable fontdatabase QPlatformFontDatabase added. QPlatformIntegration now has a new virtual function: QPlatformDatabase::fontDatabase() const. Most unix platform plugins wants to follow the pattern implemented in directfb, linuxfb, vnc etc. In the pro file do: include(../fontdatabases/genericunix/genericunix.pri) In the QPlatformIntegration class do: and instansiate a QGenericFontDatabase in the constructor and return it in the getter function. --- configure | 24 + lib/fonts/dejavu_sans_11_50.qpf2 | Bin 0 -> 405944 bytes src/gui/kernel/qplatformintegration_qpa.cpp | 11 + src/gui/kernel/qplatformintegration_qpa.h | 4 + src/gui/painting/qpaintengine.h | 2 +- src/gui/painting/qpaintengine_raster.cpp | 31 +- src/gui/painting/qpdf.cpp | 2 +- src/gui/text/qfont.h | 4 +- src/gui/text/qfont_qpa.cpp | 114 ++++ src/gui/text/qfontdatabase.cpp | 67 ++- src/gui/text/qfontdatabase.h | 1 + src/gui/text/qfontdatabase_qpa.cpp | 392 +++++++++++++ src/gui/text/qfontengine.cpp | 2 +- src/gui/text/qfontengine_ft.cpp | 7 +- src/gui/text/qfontengine_ft_p.h | 16 +- src/gui/text/qfontengine_p.h | 2 +- src/gui/text/qfontengine_qpa.cpp | 650 +++++++++++++++++++++ src/gui/text/qfontengine_qpa_p.h | 262 +++++++++ src/gui/text/qplatformfontdatabase_qpa.cpp | 195 +++++++ src/gui/text/qplatformfontdatabase_qpa.h | 65 +++ src/gui/text/text.pri | 22 +- src/plugins/platforms/directfb/directfb.pro | 2 + .../platforms/directfb/qdirectfbintegration.cpp | 7 +- .../platforms/directfb/qdirectfbintegration.h | 4 +- src/plugins/platforms/eglfs/eglfs.pro | 2 + src/plugins/platforms/eglfs/qeglfsintegration.cpp | 8 + src/plugins/platforms/eglfs/qeglfsintegration.h | 3 + .../fontdatabases/basicunix/basicunix.pri | 82 +++ .../basicunix/qbasicunixfontdatabase.cpp | 281 +++++++++ .../basicunix/qbasicunixfontdatabase.h | 26 + .../fontdatabases/fontconfig/fontconfig.pri | 12 + .../fontconfig/qfontconfigdatabase.cpp | 528 +++++++++++++++++ .../fontdatabases/fontconfig/qfontconfigdatabase.h | 15 + .../fontdatabases/genericunix/genericunix.pri | 10 + .../genericunix/qgenericunixfontdatabase.h | 12 + src/plugins/platforms/linuxfb/linuxfb.pro | 1 + .../platforms/linuxfb/qlinuxfbintegration.cpp | 7 + .../platforms/linuxfb/qlinuxfbintegration.h | 3 + src/plugins/platforms/platforms.pro | 12 +- src/plugins/platforms/qvfb/qvfb.pro | 2 + src/plugins/platforms/qvfb/qvfbintegration.cpp | 8 + src/plugins/platforms/qvfb/qvfbintegration.h | 3 + .../platforms/testlite/qtestliteintegration.cpp | 8 +- .../platforms/testlite/qtestliteintegration.h | 3 + src/plugins/platforms/testlite/qtestlitewindow.cpp | 10 +- src/plugins/platforms/testlite/testlite.pro | 21 +- src/plugins/platforms/vnc/qvncintegration.cpp | 8 +- src/plugins/platforms/vnc/qvncintegration.h | 4 + src/plugins/platforms/vnc/vnc.pro | 1 + 49 files changed, 2894 insertions(+), 62 deletions(-) create mode 100644 lib/fonts/dejavu_sans_11_50.qpf2 create mode 100644 src/gui/text/qfont_qpa.cpp create mode 100644 src/gui/text/qfontdatabase_qpa.cpp create mode 100644 src/gui/text/qfontengine_qpa.cpp create mode 100644 src/gui/text/qfontengine_qpa_p.h create mode 100644 src/gui/text/qplatformfontdatabase_qpa.cpp create mode 100644 src/gui/text/qplatformfontdatabase_qpa.h create mode 100644 src/plugins/platforms/fontdatabases/basicunix/basicunix.pri create mode 100644 src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp create mode 100644 src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h create mode 100644 src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri create mode 100644 src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp create mode 100644 src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h create mode 100644 src/plugins/platforms/fontdatabases/genericunix/genericunix.pri create mode 100644 src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h diff --git a/configure b/configure index bdf4588..94a0c0f 100755 --- a/configure +++ b/configure @@ -6093,6 +6093,30 @@ if [ "$PLATFORM_QPA" = "yes" ]; then exit 1 fi fi + + # auto-detect FontConfig support + if [ "$CFG_FONTCONFIG" != "no" ]; then + if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists fontconfig --exists freetype2 2>/dev/null; then + QT_CFLAGS_FONTCONFIG=`$PKG_CONFIG --cflags fontconfig --cflags freetype2 2>/dev/null` + QT_LIBS_FONTCONFIG=`$PKG_CONFIG --libs fontconfig --libs freetype2 2>/dev/null` + else + QT_CFLAGS_FONTCONFIG= + QT_LIBS_FONTCONFIG="-lfreetype -lfontconfig" + fi + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/fontconfig "FontConfig" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS $QT_CFLAGS_FONTCONFIG $QT_LIBS_FONTCONFIG; then + QT_CONFIG="$QT_CONFIG fontconfig" + QMakeVar set QMAKE_CFLAGS_FONTCONFIG "$QT_CFLAGS_FONTCONFIG" + QMakeVar set QMAKE_LIBS_FONTCONFIG "$QT_LIBS_FONTCONFIG" + CFG_LIBFREETYPE=system + fi + fi + + # MIT_SHM is required for testlite + if [ "$CFG_MITSHM" != "no" ]; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/mitshm "mitshm" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then + QT_CONFIG="$QT_CONFIG mitshm" + fi + fi fi diff --git a/lib/fonts/dejavu_sans_11_50.qpf2 b/lib/fonts/dejavu_sans_11_50.qpf2 new file mode 100644 index 0000000..c88d099 Binary files /dev/null and b/lib/fonts/dejavu_sans_11_50.qpf2 differ diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp index b4987f2..e2a493d 100644 --- a/src/gui/kernel/qplatformintegration_qpa.cpp +++ b/src/gui/kernel/qplatformintegration_qpa.cpp @@ -41,6 +41,8 @@ #include "qplatformintegration_qpa.h" +#include + QT_BEGIN_NAMESPACE QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, int height) const @@ -63,4 +65,13 @@ bool QPlatformIntegration::hasOpenGL() const return false; } +QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const +{ + static QPlatformFontDatabase *db = 0; + if (!db) { + db = new QPlatformFontDatabase; + } + return db; +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h index 9460910..b1f4e5f 100644 --- a/src/gui/kernel/qplatformintegration_qpa.h +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -58,6 +58,7 @@ class QWindowSurface; class QBlittable; class QWidget; class QPlatformEventLoopIntegration; +class QPlatformFontDatabase; class Q_GUI_EXPORT QPlatformIntegration { @@ -75,6 +76,9 @@ public: virtual bool isVirtualDesktop() { return false; } virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; +//Fontdatabase integration. + virtual QPlatformFontDatabase *fontDatabase() const; + // Experimental in mainthread eventloop integration // This should only be used if it is only possible to do window system event processing in // the gui thread. All of the functions in QWindowSystemInterface are thread safe. diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h index ddb6195..ee9b457 100644 --- a/src/gui/painting/qpaintengine.h +++ b/src/gui/painting/qpaintengine.h @@ -272,7 +272,7 @@ private: friend class QProxyFontEngine; #endif #ifdef Q_WS_QPA - friend class QProxyFontEngine; + friend class QFontEngineQPA; #endif friend class QPainter; friend class QPainterPrivate; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index df32ea8..7dee7e4 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3396,9 +3396,36 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte } #endif // Q_WS_QWS -#if (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) || defined(Q_WS_QPA)) && !defined(QT_NO_FREETYPE) +#ifdef Q_WS_QPA + if (s->matrix.type() < QTransform::TxScale) { -#if (defined(Q_WS_QWS) || defined(Q_WS_QPA)) && !defined(QT_NO_QWS_QPF2) + QVarLengthArray positions; + QVarLengthArray glyphs; + QTransform matrix = state()->transform(); + + qreal _x = qFloor(p.x() + aliasedCoordinateDelta); + qreal _y = qFloor(p.y() + aliasedCoordinateDelta); + matrix.translate(_x, _y); + + fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); + if (glyphs.size() == 0) + return; + + for(int i = 0; i < glyphs.size(); i++) { + QImage img = fontEngine->alphaMapForGlyph(glyphs[i]); + glyph_metrics_t metrics = fontEngine->boundingBox(glyphs[i]); + alphaPenBlt(img.bits(), img.bytesPerLine(), img.depth(), + qRound(positions[i].x + metrics.x), + qRound(positions[i].y + metrics.y), + img.width(), img.height()); + } + return; + } +#endif //Q_WS_QPA + +#if (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) + +#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_QPF2) if (fontEngine->type() == QFontEngine::QPF2) { QFontEngine *renderingEngine = static_cast(fontEngine)->renderingEngine(); if (renderingEngine) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 6e02435..fdb84e0 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -916,7 +916,7 @@ const char *QPdf::paperSizeToString(QPrinter::PaperSize paperSize) } -QByteArray QPdf::stripSpecialCharacters(const QByteArray &string) +Q_GUI_EXPORT QByteArray QPdf::stripSpecialCharacters(const QByteArray &string) { QByteArray s = string; s.replace(' ', ""); diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index fd1a2dd..2cc41e1 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -46,7 +46,7 @@ #include #include -#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA) +#if defined(Q_WS_X11) || defined(Q_WS_QWS) typedef struct FT_FaceRec_* FT_Face; #endif @@ -236,7 +236,7 @@ public: #ifdef Q_WS_MAC quint32 macFontID() const; #endif -#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA) +#if defined(Q_WS_X11) || defined(Q_WS_QWS) FT_Face freetypeFace() const; #endif diff --git a/src/gui/text/qfont_qpa.cpp b/src/gui/text/qfont_qpa.cpp new file mode 100644 index 0000000..5fed18b --- /dev/null +++ b/src/gui/text/qfont_qpa.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** 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 +#include + +QT_BEGIN_NAMESPACE + +void QFont::initialize() +{ + QApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase(); +} + +void QFont::cleanup() +{ + QFontCache::cleanup(); +} + + +/***************************************************************************** + QFont member functions + *****************************************************************************/ + +Qt::HANDLE QFont::handle() const +{ + return 0; +} + +QString QFont::rawName() const +{ + return QLatin1String("unknown"); +} + +void QFont::setRawName(const QString &) +{ +} + +QString QFont::defaultFamily() const +{ + QString familyName; + switch(d->request.styleHint) { + case QFont::Times: + familyName = QString::fromLatin1("times"); + case QFont::Courier: + case QFont::Monospace: + familyName = QString::fromLatin1("monospace"); + case QFont::Decorative: + familyName = QString::fromLatin1("old english"); + case QFont::Helvetica: + case QFont::System: + default: + familyName = QString::fromLatin1("helvetica"); + } + + QStringList list = QApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(familyName,QFont::StyleNormal,QUnicodeTables::Common); + if (list.size()) { + familyName = list.at(0); + } + return familyName; +} + +QString QFont::lastResortFamily() const +{ + return QString::fromLatin1("helvetica"); +} + +QString QFont::lastResortFont() const +{ + qFatal("QFont::lastResortFont: Cannot find any reasonable font"); + // Shut compiler up + return QString(); +} + + +QT_END_NAMESPACE + diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 7ece6ea..72ffb1c 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -50,13 +50,19 @@ #include "private/qunicodetables_p.h" #include "qfontengine_p.h" +#ifdef Q_WS_QPA +#include +#include +#include "qabstractfileengine.h" +#endif + #ifdef Q_WS_X11 #include #endif #include #include -#if (defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) +#if (defined(Q_WS_QWS)|| defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) # include # include FT_TRUETYPE_TABLES_H #endif @@ -143,7 +149,7 @@ struct QtFontEncoding uchar pitch : 8; }; -struct QtFontSize +struct QtFontSize { #ifdef Q_WS_X11 QtFontEncoding *encodings; @@ -152,10 +158,13 @@ struct QtFontSize unsigned short count : 16; #endif // Q_WS_X11 -#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) QByteArray fileName; int fileIndex; #endif // defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QPA) + void *handle; +#endif unsigned short pixelSize : 16; }; @@ -238,9 +247,15 @@ struct QtFontStyle #ifdef Q_WS_X11 free(pixelSizes[count].encodings); #endif -#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) pixelSizes[count].fileName.~QByteArray(); #endif +#if defined (Q_WS_QPA) + QPlatformIntegration *integration = QApplicationPrivate::platformIntegration(); + if (integration) { //on shut down there will be some that we don't release. + integration->fontDatabase()->releaseHandle(pixelSizes[count].handle); + } +#endif } #endif free(pixelSizes); @@ -302,10 +317,13 @@ QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add) pixelSizes[count].count = 0; pixelSizes[count].encodings = 0; #endif -#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) new (&pixelSizes[count].fileName) QByteArray; pixelSizes[count].fileIndex = 0; #endif +#if defined(Q_WS_QPA) + pixelSizes[count].handle = 0; +#endif return pixelSizes + (count++); } @@ -362,7 +380,7 @@ QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, bool create) } -struct QtFontFamily +struct QtFontFamily { enum WritingSystemStatus { Unknown = 0, @@ -391,6 +409,9 @@ struct QtFontFamily #if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) , bogusWritingSystems(false) #endif +#if defined(Q_WS_QPA) + , askedForFallback(false) +#endif { memset(writingSystems, 0, sizeof(writingSystems)); } @@ -432,6 +453,9 @@ struct QtFontFamily bool bogusWritingSystems; QStringList fallbackFamilies; #endif +#if defined (Q_WS_QPA) + bool askedForFallback; +#endif unsigned char writingSystems[QFontDatabase::WritingSystemsCount]; QtFontFoundry *foundry(const QString &f, bool = false); @@ -475,7 +499,7 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create) // ### copied to tools/makeqpf/qpf2.cpp -#if ((defined(Q_WS_QWS) || defined(Q_WS_QPA)) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)) +#if (defined(Q_WS_QWS) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)) // see the Unicode subset bitfields in the MSDN docs static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = { @@ -617,7 +641,7 @@ class QFontDatabasePrivate public: QFontDatabasePrivate() : count(0), families(0), reregisterAppFonts(false) -#if defined(Q_WS_QWS) || defined(Q_WS_QPA) +#if defined(Q_WS_QWS) , stream(0) #endif #if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) @@ -665,11 +689,11 @@ public: void invalidate(); -#if defined(Q_WS_QWS) || defined(Q_WS_QPA) +#if defined(Q_WS_QWS) bool loadFromCache(const QString &fontPath); void addQPF2File(const QByteArray &file); #endif // Q_WS_QWS -#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) +#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) void addFont(const QString &familyname, const char *foundryname, int weight, bool italic, int pixelSize, const QByteArray &file, int fileIndex, bool antialiased, @@ -678,12 +702,14 @@ public: QStringList addTTFile(const QByteArray &file, const QByteArray &fontData = QByteArray()); #endif // QT_NO_FREETYPE #endif -#if defined(Q_WS_QWS) || defined (Q_WS_QPA) +#if defined(Q_WS_QWS) QDataStream *stream; - QStringList fallbackFamilies; #elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) const QSymbianFontDatabaseExtras *symbianExtras; #endif +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) + QStringList fallbackFamilies; +#endif }; void QFontDatabasePrivate::invalidate() @@ -732,7 +758,7 @@ QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create) return families[pos]; } -#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) +#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE) void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundryname, int weight, bool italic, int pixelSize, const QByteArray &file, int fileIndex, bool antialiased, const QList &writingSystems) @@ -763,7 +789,7 @@ void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundr size->fileName = file; size->fileIndex = fileIndex; -#if defined(Q_WS_QWS) || defined(Q_WS_QPA) +#if defined(Q_WS_QWS) if (stream) { *stream << familyname << foundry->name << weight << quint8(italic) << pixelSize << file << fileIndex << quint8(antialiased); @@ -778,7 +804,7 @@ void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundr } #endif -#if (defined(Q_WS_QWS) || defined (Q_WS_QPA) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) +#if (defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE) QStringList QFontDatabasePrivate::addTTFile(const QByteArray &file, const QByteArray &fontData) { QStringList families; @@ -891,7 +917,7 @@ static const int scriptForWritingSystem[] = { }; -#if defined Q_WS_QWS || defined(Q_WS_QPA) || (defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)) || defined(Q_WS_WIN) +#if defined Q_WS_QWS || (defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)) || defined(Q_WS_WIN) static inline bool requiresOpenType(int writingSystem) { return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala) @@ -994,7 +1020,7 @@ static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDe #endif #endif -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || defined(Q_WS_QPA) static void getEngineData(const QFontPrivate *d, const QFontCache::Key &key) { // look for the requested font in the engine data cache @@ -1053,8 +1079,10 @@ QT_BEGIN_INCLUDE_NAMESPACE # include "qfontdatabase_mac.cpp" #elif defined(Q_WS_WIN) # include "qfontdatabase_win.cpp" -#elif defined(Q_WS_QWS) || defined(Q_WS_QPA) +#elif defined(Q_WS_QWS) # include "qfontdatabase_qws.cpp" +#elif defined(Q_WS_QPA) +# include "qfontdatabase_qpa.cpp" #elif defined(Q_OS_SYMBIAN) # include "qfontdatabase_s60.cpp" #endif @@ -1340,6 +1368,7 @@ static void match(int script, const QFontDef &request, styleKey.stretch = request.stretch; char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p'; + FM_DEBUG("QFontDatabase::match\n" " request:\n" " family: %s [%s], script: %d\n" @@ -2485,7 +2514,7 @@ void QFontDatabase::createDatabase() { initializeDb(); } // used from qfontengine_ft.cpp -QByteArray qt_fontdata_from_index(int index) +Q_GUI_EXPORT QByteArray qt_fontdata_from_index(int index) { QMutexLocker locker(fontDatabaseMutex()); return privateDb()->applicationFonts.value(index).data; diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h index 6a09b77..f31c19c 100644 --- a/src/gui/text/qfontdatabase.h +++ b/src/gui/text/qfontdatabase.h @@ -167,6 +167,7 @@ private: friend class QFontEngineMultiXLFD; friend class QFontEngineMultiQWS; friend class QFontEngineMultiS60; + friend class QFontEngineMultiQPA; QFontDatabasePrivate *d; }; diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp new file mode 100644 index 0000000..53594aa --- /dev/null +++ b/src/gui/text/qfontdatabase_qpa.cpp @@ -0,0 +1,392 @@ +/**************************************************************************** +** +** 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 "qlibraryinfo.h" +#include + +#include "qfontengine_qpa_p.h" +#include "qplatformdefs.h" + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +Q_GUI_EXPORT void qt_registerFont(const QString &familyName, const QString &foundryname, int weight, + QFont::Style style, int stretch, bool antialiased, bool scalable, int pixelSize, + const QSupportedWritingSystems &writingSystems, void *handle) +{ + QFontDatabasePrivate *d = privateDb(); + // qDebug() << "Adding font" << familyname << weight << italic << pixelSize << file << fileIndex << antialiased; + QtFontStyle::Key styleKey; + styleKey.style = style; + styleKey.weight = weight; + styleKey.stretch = stretch; + QtFontFamily *f = d->family(familyName, true); + + for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) { + if (writingSystems.supported(QFontDatabase::WritingSystem(i))) { + f->writingSystems[i] = QtFontFamily::Supported; + } else { + f->writingSystems[i] = QtFontFamily::Unsupported; + } + } + + QtFontFoundry *foundry = f->foundry(foundryname, true); + QtFontStyle *fontStyle = foundry->style(styleKey, true); + fontStyle->smoothScalable = scalable; + fontStyle->antialiased = antialiased; + QtFontSize *size = fontStyle->pixelSize(pixelSize?pixelSize:SMOOTH_SCALABLE, true); + size->handle = handle; +} + +static QStringList fallbackFamilies(const QString &family, const QFont::Style &style, const QUnicodeTables::Script &script) +{ + QStringList retList = QApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(family,style,script); + QFontDatabasePrivate *db = privateDb(); + + QStringList::iterator i; + for (i = retList.begin(); i != retList.end(); ++i) { + bool contains = false; + for (int j = 0; j < db->count; j++) { + QtFontFamily *qtFamily = db->families[j]; + if (!(i->compare(qtFamily->name,Qt::CaseInsensitive))) { + contains = true; + break; + } + } + if (!contains) { + i = retList.erase(i); + i--; + } + } + return retList; +} + +static void initializeDb() +{ + static int initialized = false; + + if (!initialized) { + //init by asking for the platformfontdb for the first time :) + QApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase(); + initialized = true; + } +} + +#ifndef QT_NO_SETTINGS +// called from qapplication_qws.cpp +void qt_applyFontDatabaseSettings(const QSettings &settings) +{ + initializeDb(); + QFontDatabasePrivate *db = privateDb(); + for (int i = 0; i < db->count; ++i) { + QtFontFamily *family = db->families[i]; + if (settings.contains(family->name)) + family->fallbackFamilies = settings.value(family->name).toStringList(); + } + + if (settings.contains(QLatin1String("Global Fallbacks"))) + db->fallbackFamilies = settings.value(QLatin1String("Global Fallbacks")).toStringList(); +} +#endif // QT_NO_SETTINGS + +static inline void load(const QString & = QString(), int = -1) +{ + initializeDb(); +} + +static +QFontEngine *loadSingleEngine(int script, + const QFontDef &request, + QtFontFoundry *foundry, + QtFontStyle *style, QtFontSize *size) +{ + Q_UNUSED(foundry); + + Q_ASSERT(size); + int pixelSize = size->pixelSize; + if (!pixelSize || (style->smoothScalable && pixelSize == SMOOTH_SCALABLE)) + pixelSize = request.pixelSize; + + QFontDef def = request; + def.pixelSize = pixelSize; + + QFontCache::Key key(def,script); + QFontEngine *engine = QFontCache::instance()->findEngine(key); + if (!engine) { + QPlatformFontDatabase *pfdb = QApplicationPrivate::platformIntegration()->fontDatabase(); + if (size->handle) { + engine = pfdb->fontEngine(def,QUnicodeTables::Script(script),size->handle); + if (engine) { + QFontCache::Key key(def,script); + QFontCache::instance()->instance()->insertEngine(key,engine); + } + } + + } + return engine; +} + +static +QFontEngine *loadEngine(int script, const QFontDef &request, + QtFontFamily *family, QtFontFoundry *foundry, + QtFontStyle *style, QtFontSize *size) +{ + + QFontEngine *engine = loadSingleEngine(script, request, foundry, style, size); + //make sure that the db has all fallback families + if (engine + && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol ) { + + if (family && !family->askedForFallback) { + family->fallbackFamilies = fallbackFamilies(family->name,QFont::Style(style->key.style),QUnicodeTables::Script(script)); + + family->askedForFallback = true; + } + + QStringList fallbacks = privateDb()->fallbackFamilies; + if (family && !family->fallbackFamilies.isEmpty()) + fallbacks = family->fallbackFamilies; + + engine = new QFontEngineMultiQPA(engine, script, fallbacks); + } + + return engine; +} + +static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) +{ + QFontDatabasePrivate *db = privateDb(); + + QApplicationPrivate::platformIntegration()->fontDatabase()->addApplicationFont(fnt->data,fnt->fileName); + db->reregisterAppFonts = true; +} + +bool QFontDatabase::removeApplicationFont(int handle) +{ + QMutexLocker locker(fontDatabaseMutex()); + + QFontDatabasePrivate *db = privateDb(); + if (handle < 0 || handle >= db->applicationFonts.count()) + return false; + + db->applicationFonts[handle] = QFontDatabasePrivate::ApplicationFont(); + + db->reregisterAppFonts = true; + db->invalidate(); + return true; +} + +bool QFontDatabase::removeAllApplicationFonts() +{ + QMutexLocker locker(fontDatabaseMutex()); + + QFontDatabasePrivate *db = privateDb(); + if (db->applicationFonts.isEmpty()) + return false; + + db->applicationFonts.clear(); + db->invalidate(); + return true; +} + +bool QFontDatabase::supportsThreadedFontRendering() +{ + return true; +} + +/*! + \internal +*/ +QFontEngine * +QFontDatabase::findFont(int script, const QFontPrivate *fp, + const QFontDef &request) +{ + QMutexLocker locker(fontDatabaseMutex()); + + const int force_encoding_id = -1; + + if (!privateDb()->count) + initializeDb(); + + QFontEngine *engine; + QFontCache::Key key(request, script); + engine = QFontCache::instance()->findEngine(key); + if (engine) { + qDebug() << "Cache hit level 1"; + return engine; + } + + QString family_name, foundry_name; + + parseFontName(request.family, foundry_name, family_name); + + if (qt_enable_test_font && request.family == QLatin1String("__Qt__Box__Engine__")) { + engine =new QTestFontEngine(request.pixelSize); + engine->fontDef = request; + } + + QtFontDesc desc; + match(script, request, family_name, foundry_name, force_encoding_id, &desc); + if (desc.family != 0 && desc.foundry != 0 && desc.style != 0) { + engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size); + } else { + FM_DEBUG(" NO MATCH FOUND\n"); + } + + if (engine) { + initFontDef(desc, request, &engine->fontDef); + + if (fp) { + QFontDef def = request; + if (def.family.isEmpty()) { + def.family = fp->request.family; + def.family = def.family.left(def.family.indexOf(QLatin1Char(','))); + } + } + } + + if (!engine) { + if (!request.family.isEmpty()) { + QStringList fallbacks = fallbackFamilies(request.family,QFont::Style(request.style),QUnicodeTables::Script(script)); + for (int i = 0; i < fallbacks.size(); i++) { + QFontDef def = request; + def.family = fallbacks.at(i); + QFontCache::Key key(def,script); + engine = QFontCache::instance()->findEngine(key); + if (!engine) { + QtFontDesc desc; + match(script, def, def.family, QLatin1String(""), 0, &desc); + if (desc.family == 0 && desc.foundry == 0 && desc.style == 0) { + continue; + } + engine = loadEngine(script, def, desc.family, desc.foundry, desc.style, desc.size); + if (engine) { + initFontDef(desc, def, &engine->fontDef); + break; + } + } + } + } + + if (!engine) + engine = new QFontEngineBox(request.pixelSize); + + FM_DEBUG("returning box engine"); + } + + if (fp && fp->dpi > 0) { + engine->fontDef.pointSize = qreal(double((engine->fontDef.pixelSize * 72) / fp->dpi)); + } else { + engine->fontDef.pointSize = request.pointSize; + } + + return engine; +} + +void QFontDatabase::load(const QFontPrivate *d, int script) +{ + QFontDef req = d->request; + + if (req.pixelSize == -1) { + req.pixelSize = floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100; + req.pixelSize = qRound(req.pixelSize); + } + if (req.pointSize < 0) + req.pointSize = req.pixelSize*72.0/d->dpi; + if (req.weight == 0) + req.weight = QFont::Normal; + if (req.stretch == 0) + req.stretch = 100; + + QFontCache::Key key(req, script); + + if (!d->engineData) + getEngineData(d, key); + + // the cached engineData could have already loaded the engine we want + if (d->engineData->engines[script]) + return; + + QFontEngine *fe = QFontCache::instance()->findEngine(key); + + // list of families to try + QStringList family_list; + + if (!req.family.isEmpty()) { + family_list = familyList(req); + + // add the default family + QString defaultFamily = QApplication::font().family(); + if (! family_list.contains(defaultFamily)) + family_list << defaultFamily; + + } + + // null family means find the first font matching the specified script + family_list << QString(); + + QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd(); + for (; !fe && it != end; ++it) { + req.family = *it; + + fe = QFontDatabase::findFont(script, d, req); + if (fe && (fe->type()==QFontEngine::Box) && !req.family.isEmpty()) + fe = 0; + } + + if (fe->symbol || (d->request.styleStrategy & QFont::NoFontMerging)) { + for (int i = 0; i < QUnicodeTables::ScriptCount; ++i) { + if (!d->engineData->engines[i]) { + d->engineData->engines[i] = fe; + fe->ref.ref(); + } + } + } else { + d->engineData->engines[script] = fe; + fe->ref.ref(); + } +} + +QT_END_NAMESPACE diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index fdb86ce..1c705ae 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -481,7 +481,7 @@ static void collectSingleContour(qreal x0, qreal y0, uint *grid, int x, int y, i path->closeSubpath(); } -void qt_addBitmapToPath(qreal x0, qreal y0, const uchar *image_data, int bpl, int w, int h, QPainterPath *path) +Q_GUI_EXPORT void qt_addBitmapToPath(qreal x0, qreal y0, const uchar *image_data, int bpl, int w, int h, QPainterPath *path) { uint *grid = new uint[(w+1)*(h+1)]; // set up edges diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 2c4fbab..1ee7144 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -717,7 +717,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format) metrics = face->size->metrics; -#if defined(Q_WS_QWS) +#if defined(Q_WS_QWS) || defined(Q_WS_QPA) /* TrueType fonts with embedded bitmaps may have a bitmap font specific ascent/descent in the EBLC table. There is no direct public API @@ -749,6 +749,11 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format) return true; } +void QFontEngineFT::setDefaultHintStyle(HintStyle style) +{ + default_hint_style = style; +} + QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph) const { Glyph *g = set->getGlyph(glyph); diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 372ad0c..f40ce04 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -271,7 +271,7 @@ private: QGlyphSet *loadTransformedGlyphSet(const QTransform &matrix); bool loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, GlyphFormat format = Format_Render); -#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) +#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) virtual void draw(QPaintEngine * /*p*/, qreal /*x*/, qreal /*y*/, const QTextItemInt & /*si*/) {} #endif @@ -282,6 +282,14 @@ private: virtual HB_Error getPointInOutline(HB_Glyph glyph, int flags, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints); + enum HintStyle { + HintNone, + HintLight, + HintMedium, + HintFull + }; + + void setDefaultHintStyle(HintStyle style); protected: void freeGlyphSets(); @@ -293,12 +301,6 @@ protected: QFreetypeFace *freetype; int default_load_flags; - enum HintStyle { - HintNone, - HintLight, - HintMedium, - HintFull - }; HintStyle default_hint_style; diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index fb4556b..897f76f 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -168,7 +168,7 @@ public: virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const {} virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const; -#if !defined(Q_WS_X11) && !defined(Q_WS_WIN) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN) +#if !defined(Q_WS_X11) && !defined(Q_WS_WIN) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN) && !defined(Q_WS_QPA) virtual void draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &si) = 0; #endif virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, diff --git a/src/gui/text/qfontengine_qpa.cpp b/src/gui/text/qfontengine_qpa.cpp new file mode 100644 index 0000000..910bbfe --- /dev/null +++ b/src/gui/text/qfontengine_qpa.cpp @@ -0,0 +1,650 @@ +#include "qfontengine_qpa_p.h" + +#include +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +//#define DEBUG_HEADER +//#define DEBUG_FONTENGINE + +static QFontEngineQPA::TagType tagTypes[QFontEngineQPA::NumTags] = { + QFontEngineQPA::StringType, // FontName + QFontEngineQPA::StringType, // FileName + QFontEngineQPA::UInt32Type, // FileIndex + QFontEngineQPA::UInt32Type, // FontRevision + QFontEngineQPA::StringType, // FreeText + QFontEngineQPA::FixedType, // Ascent + QFontEngineQPA::FixedType, // Descent + QFontEngineQPA::FixedType, // Leading + QFontEngineQPA::FixedType, // XHeight + QFontEngineQPA::FixedType, // AverageCharWidth + QFontEngineQPA::FixedType, // MaxCharWidth + QFontEngineQPA::FixedType, // LineThickness + QFontEngineQPA::FixedType, // MinLeftBearing + QFontEngineQPA::FixedType, // MinRightBearing + QFontEngineQPA::FixedType, // UnderlinePosition + QFontEngineQPA::UInt8Type, // GlyphFormat + QFontEngineQPA::UInt8Type, // PixelSize + QFontEngineQPA::UInt8Type, // Weight + QFontEngineQPA::UInt8Type, // Style + QFontEngineQPA::StringType, // EndOfHeader + QFontEngineQPA::BitFieldType// WritingSystems +}; + + +#if defined(DEBUG_HEADER) +# define DEBUG_VERIFY qDebug +#else +# define DEBUG_VERIFY if (0) qDebug +#endif + +#define READ_VERIFY(type, variable) \ + if (tagPtr + sizeof(type) > endPtr) { \ + DEBUG_VERIFY() << "read verify failed in line" << __LINE__; \ + return 0; \ + } \ + variable = qFromBigEndian(tagPtr); \ + DEBUG_VERIFY() << "read value" << variable << "of type " #type; \ + tagPtr += sizeof(type) + +template +T readValue(const uchar *&data) +{ + T value = qFromBigEndian(data); + data += sizeof(T); + return value; +} + +#define VERIFY(condition) \ + if (!(condition)) { \ + DEBUG_VERIFY() << "condition " #condition " failed in line" << __LINE__; \ + return 0; \ + } + +#define VERIFY_TAG(condition) \ + if (!(condition)) { \ + DEBUG_VERIFY() << "verifying tag condition " #condition " failed in line" << __LINE__ << "with tag" << tag; \ + return 0; \ + } + +static inline const uchar *verifyTag(const uchar *tagPtr, const uchar *endPtr) +{ + quint16 tag, length; + READ_VERIFY(quint16, tag); + READ_VERIFY(quint16, length); + if (tag == QFontEngineQPA::Tag_EndOfHeader) + return endPtr; + if (tag < QFontEngineQPA::NumTags) { + switch (tagTypes[tag]) { + case QFontEngineQPA::BitFieldType: + case QFontEngineQPA::StringType: + // can't do anything... + break; + case QFontEngineQPA::UInt32Type: + VERIFY_TAG(length == sizeof(quint32)); + break; + case QFontEngineQPA::FixedType: + VERIFY_TAG(length == sizeof(quint32)); + break; + case QFontEngineQPA::UInt8Type: + VERIFY_TAG(length == sizeof(quint8)); + break; + } +#if defined(DEBUG_HEADER) + if (length == 1) + qDebug() << "tag data" << hex << *tagPtr; + else if (length == 4) + qDebug() << "tag data" << hex << tagPtr[0] << tagPtr[1] << tagPtr[2] << tagPtr[3]; +#endif + } + return tagPtr + length; +} + +const QFontEngineQPA::Glyph *QFontEngineQPA::findGlyph(glyph_t g) const +{ + if (!g || g >= glyphMapEntries) + return 0; + const quint32 *gmapPtr = reinterpret_cast(fontData + glyphMapOffset); + quint32 glyphPos = qFromBigEndian(gmapPtr[g]); + if (glyphPos > glyphDataSize) { + if (glyphPos == 0xffffffff) + return 0; +#if defined(DEBUG_FONTENGINE) + qDebug() << "glyph" << g << "outside of glyphData, remapping font file"; +#endif + if (glyphPos > glyphDataSize) + return 0; + } + return reinterpret_cast(fontData + glyphDataOffset + glyphPos); +} + +bool QFontEngineQPA::verifyHeader(const uchar *data, int size) +{ + VERIFY(size >= int(sizeof(Header))); + const Header *header = reinterpret_cast(data); + if (header->magic[0] != 'Q' + || header->magic[1] != 'P' + || header->magic[2] != 'F' + || header->magic[3] != '2') + return false; + + VERIFY(header->majorVersion <= CurrentMajorVersion); + const quint16 dataSize = qFromBigEndian(header->dataSize); + VERIFY(size >= int(sizeof(Header)) + dataSize); + + const uchar *tagPtr = data + sizeof(Header); + const uchar *tagEndPtr = tagPtr + dataSize; + while (tagPtr < tagEndPtr - 3) { + tagPtr = verifyTag(tagPtr, tagEndPtr); + VERIFY(tagPtr); + } + + VERIFY(tagPtr <= tagEndPtr); + return true; +} + +QVariant QFontEngineQPA::extractHeaderField(const uchar *data, HeaderTag requestedTag) +{ + const Header *header = reinterpret_cast(data); + const uchar *tagPtr = data + sizeof(Header); + const uchar *endPtr = tagPtr + qFromBigEndian(header->dataSize); + while (tagPtr < endPtr - 3) { + quint16 tag = readValue(tagPtr); + quint16 length = readValue(tagPtr); + if (tag == requestedTag) { + switch (tagTypes[requestedTag]) { + case StringType: + return QVariant(QString::fromUtf8(reinterpret_cast(tagPtr), length)); + case UInt32Type: + return QVariant(readValue(tagPtr)); + case UInt8Type: + return QVariant(uint(*tagPtr)); + case FixedType: + return QVariant(QFixed::fromFixed(readValue(tagPtr)).toReal()); + case BitFieldType: + return QVariant(QByteArray(reinterpret_cast(tagPtr), length)); + } + return QVariant(); + } else if (tag == Tag_EndOfHeader) { + break; + } + tagPtr += length; + } + + return QVariant(); +} + + + +static inline unsigned int getChar(const QChar *str, int &i, const int len) +{ + unsigned int uc = str[i].unicode(); + if (uc >= 0xd800 && uc < 0xdc00 && i < len-1) { + uint low = str[i+1].unicode(); + if (low >= 0xdc00 && low < 0xe000) { + uc = (uc - 0xd800)*0x400 + (low - 0xdc00) + 0x10000; + ++i; + } + } + return uc; +} + +QFontEngineQPA::QFontEngineQPA(const QFontDef &def, const QByteArray &data) + : fontData(reinterpret_cast(data.constData())), dataSize(data.size()) +{ + fontDef = def; + cache_cost = 100; + externalCMap = 0; + cmapOffset = 0; + cmapSize = 0; + glyphMapOffset = 0; + glyphMapEntries = 0; + glyphDataOffset = 0; + glyphDataSize = 0; + kerning_pairs_loaded = false; + readOnly = true; + +#if defined(DEBUG_FONTENGINE) + qDebug() << "QFontEngineQPA::QFontEngineQPA( fd =" << fd << ", renderingFontEngine =" << renderingFontEngine << ')'; +#endif + + if (!verifyHeader(fontData, dataSize)) { +#if defined(DEBUG_FONTENGINE) + qDebug() << "verifyHeader failed!"; +#endif + return; + } + + const Header *header = reinterpret_cast(fontData); + + readOnly = (header->lock == 0xffffffff); + + const uchar *imgData = fontData + sizeof(Header) + qFromBigEndian(header->dataSize); + const uchar *endPtr = fontData + dataSize; + while (imgData <= endPtr - 8) { + quint16 blockTag = readValue(imgData); + imgData += 2; // skip padding + quint32 blockSize = readValue(imgData); + + if (blockTag == CMapBlock) { + cmapOffset = imgData - fontData; + cmapSize = blockSize; + } else if (blockTag == GMapBlock) { + glyphMapOffset = imgData - fontData; + glyphMapEntries = blockSize / 4; + } else if (blockTag == GlyphBlock) { + glyphDataOffset = imgData - fontData; + glyphDataSize = blockSize; + } + + imgData += blockSize; + } + + face_id.filename = QFile::encodeName(extractHeaderField(fontData, Tag_FileName).toString()); + face_id.index = extractHeaderField(fontData, Tag_FileIndex).toInt(); + + // get the real cmap + if (cmapOffset) { + int tableSize = cmapSize; + const uchar *cmapPtr = getCMap(fontData + cmapOffset, tableSize, &symbol, &cmapSize); + if (cmapPtr) + cmapOffset = cmapPtr - fontData; + else + cmapOffset = 0; + } else if (externalCMap) { + int tableSize = cmapSize; + externalCMap = getCMap(externalCMap, tableSize, &symbol, &cmapSize); + } + + // verify all the positions in the glyphMap + if (glyphMapOffset) { + const quint32 *gmapPtr = reinterpret_cast(fontData + glyphMapOffset); + for (uint i = 0; i < glyphMapEntries; ++i) { + quint32 glyphDataPos = qFromBigEndian(gmapPtr[i]); + if (glyphDataPos == 0xffffffff) + continue; + if (glyphDataPos >= glyphDataSize) { + // error + glyphMapOffset = 0; + glyphMapEntries = 0; + break; + } + } + } + +#if defined(DEBUG_FONTENGINE) + if (!isValid()) + qDebug() << "fontData" << fontData << "dataSize" << dataSize + << "externalCMap" << externalCMap << "cmapOffset" << cmapOffset + << "glyphMapOffset" << glyphMapOffset << "glyphDataOffset" << glyphDataOffset + << "fd" << fd << "glyphDataSize" << glyphDataSize; +#endif +} + +QFontEngineQPA::~QFontEngineQPA() +{ +} + +bool QFontEngineQPA::getSfntTableData(uint tag, uchar *buffer, uint *length) const +{ + Q_UNUSED(tag); + Q_UNUSED(buffer); + *length = 0; + return false; +} + +bool QFontEngineQPA::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const +{ + if (*nglyphs < len) { + *nglyphs = len; + return false; + } + +#if defined(DEBUG_FONTENGINE) + QSet seenGlyphs; +#endif + + const uchar *cmap = externalCMap ? externalCMap : (fontData + cmapOffset); + + bool mirrored = flags & QTextEngine::RightToLeft; + int glyph_pos = 0; + if (symbol) { + for (int i = 0; i < len; ++i) { + unsigned int uc = getChar(str, i, len); + if (mirrored) + uc = QChar::mirroredChar(uc); + glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc); + if(!glyphs->glyphs[glyph_pos] && uc < 0x100) + glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc + 0xf000); + ++glyph_pos; + } + } else { + for (int i = 0; i < len; ++i) { + unsigned int uc = getChar(str, i, len); + if (mirrored) + uc = QChar::mirroredChar(uc); + glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc); +#if 0 && defined(DEBUG_FONTENGINE) + QChar c(uc); + if (!findGlyph(glyphs[glyph_pos].glyph) && !seenGlyphs.contains(c)) + qDebug() << "glyph for character" << c << '/' << hex << uc << "is" << dec << glyphs[glyph_pos].glyph; + + seenGlyphs.insert(c); +#endif + ++glyph_pos; + } + } + + *nglyphs = glyph_pos; + glyphs->numGlyphs = glyph_pos; + recalcAdvances(glyphs, flags); + return true; +} + +void QFontEngineQPA::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const +{ + for (int i = 0; i < glyphs->numGlyphs; ++i) { + const Glyph *g = findGlyph(glyphs->glyphs[i]); + if (!g) { + glyphs->glyphs[i] = 0; + continue; + } + glyphs->advances_x[i] = g->advance; + glyphs->advances_y[i] = 0; + } +} + +QImage QFontEngineQPA::alphaMapForGlyph(glyph_t g) +{ + const Glyph *glyph = findGlyph(g); + if (!glyph) + return QImage(); + + const uchar *bits = ((const uchar *) glyph) + sizeof(Glyph); + + QImage image(bits,glyph->width, glyph->height, glyph->bytesPerLine, QImage::Format_Indexed8); + + return image; +} + +void QFontEngineQPA::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags) +{ + addBitmapFontToPath(x, y, glyphs, path, flags); +} + +glyph_metrics_t QFontEngineQPA::boundingBox(const QGlyphLayout &glyphs) +{ + glyph_metrics_t overall; + // initialize with line height, we get the same behaviour on all platforms + overall.y = -ascent(); + overall.height = ascent() + descent() + 1; + + QFixed ymax = 0; + QFixed xmax = 0; + for (int i = 0; i < glyphs.numGlyphs; i++) { + const Glyph *g = findGlyph(glyphs.glyphs[i]); + if (!g) + continue; + + QFixed x = overall.xoff + glyphs.offsets[i].x + g->x; + QFixed y = overall.yoff + glyphs.offsets[i].y + g->y; + overall.x = qMin(overall.x, x); + overall.y = qMin(overall.y, y); + xmax = qMax(xmax, x + g->width); + ymax = qMax(ymax, y + g->height); + overall.xoff += g->advance; + } + overall.height = qMax(overall.height, ymax - overall.y); + overall.width = xmax - overall.x; + + return overall; +} + +glyph_metrics_t QFontEngineQPA::boundingBox(glyph_t glyph) +{ + glyph_metrics_t overall; + const Glyph *g = findGlyph(glyph); + if (!g) + return overall; + overall.x = g->x; + overall.y = g->y; + overall.width = g->width; + overall.height = g->height; + overall.xoff = g->advance; + return overall; +} + +QFixed QFontEngineQPA::ascent() const +{ + return QFixed::fromReal(extractHeaderField(fontData, Tag_Ascent).value()); +} + +QFixed QFontEngineQPA::descent() const +{ + return QFixed::fromReal(extractHeaderField(fontData, Tag_Descent).value()); +} + +QFixed QFontEngineQPA::leading() const +{ + return QFixed::fromReal(extractHeaderField(fontData, Tag_Leading).value()); +} + +qreal QFontEngineQPA::maxCharWidth() const +{ + return extractHeaderField(fontData, Tag_MaxCharWidth).value(); +} + +qreal QFontEngineQPA::minLeftBearing() const +{ + return extractHeaderField(fontData, Tag_MinLeftBearing).value(); +} + +qreal QFontEngineQPA::minRightBearing() const +{ + return extractHeaderField(fontData, Tag_MinRightBearing).value(); +} + +QFixed QFontEngineQPA::underlinePosition() const +{ + return QFixed::fromReal(extractHeaderField(fontData, Tag_UnderlinePosition).value()); +} + +QFixed QFontEngineQPA::lineThickness() const +{ + return QFixed::fromReal(extractHeaderField(fontData, Tag_LineThickness).value()); +} + +QFontEngine::Type QFontEngineQPA::type() const +{ + return QFontEngine::QPF2; +} + +bool QFontEngineQPA::canRender(const QChar *string, int len) +{ + const uchar *cmap = externalCMap ? externalCMap : (fontData + cmapOffset); + + if (symbol) { + for (int i = 0; i < len; ++i) { + unsigned int uc = getChar(string, i, len); + glyph_t g = getTrueTypeGlyphIndex(cmap, uc); + if(!g && uc < 0x100) + g = getTrueTypeGlyphIndex(cmap, uc + 0xf000); + if (!g) + return false; + } + } else { + for (int i = 0; i < len; ++i) { + unsigned int uc = getChar(string, i, len); + if (!getTrueTypeGlyphIndex(cmap, uc)) + return false; + } + } + return true; +} + +bool QFontEngineQPA::isValid() const +{ + return fontData && dataSize && (cmapOffset || externalCMap) + && glyphMapOffset && glyphDataOffset && glyphDataSize > 0; +} + +void QPAGenerator::generate() +{ + writeHeader(); + writeGMap(); + writeBlock(QFontEngineQPA::GlyphBlock, QByteArray()); + + dev->seek(4); // position of header.lock + writeUInt32(0); +} + +void QPAGenerator::writeHeader() +{ + QFontEngineQPA::Header header; + + header.magic[0] = 'Q'; + header.magic[1] = 'P'; + header.magic[2] = 'F'; + header.magic[3] = '2'; + header.lock = 1; + header.majorVersion = QFontEngineQPA::CurrentMajorVersion; + header.minorVersion = QFontEngineQPA::CurrentMinorVersion; + header.dataSize = 0; + dev->write((const char *)&header, sizeof(header)); + + writeTaggedString(QFontEngineQPA::Tag_FontName, fe->fontDef.family.toUtf8()); + + QFontEngine::FaceId face = fe->faceId(); + writeTaggedString(QFontEngineQPA::Tag_FileName, face.filename); + writeTaggedUInt32(QFontEngineQPA::Tag_FileIndex, face.index); + + { + uchar data[4]; + uint len = 4; + bool ok = fe->getSfntTableData(MAKE_TAG('h', 'e', 'a', 'd'), data, &len); + if (ok) { + const quint32 revision = qFromBigEndian(data); + writeTaggedUInt32(QFontEngineQPA::Tag_FontRevision, revision); + } + } + + writeTaggedQFixed(QFontEngineQPA::Tag_Ascent, fe->ascent()); + writeTaggedQFixed(QFontEngineQPA::Tag_Descent, fe->descent()); + writeTaggedQFixed(QFontEngineQPA::Tag_Leading, fe->leading()); + writeTaggedQFixed(QFontEngineQPA::Tag_XHeight, fe->xHeight()); + writeTaggedQFixed(QFontEngineQPA::Tag_AverageCharWidth, fe->averageCharWidth()); + writeTaggedQFixed(QFontEngineQPA::Tag_MaxCharWidth, QFixed::fromReal(fe->maxCharWidth())); + writeTaggedQFixed(QFontEngineQPA::Tag_LineThickness, fe->lineThickness()); + writeTaggedQFixed(QFontEngineQPA::Tag_MinLeftBearing, QFixed::fromReal(fe->minLeftBearing())); + writeTaggedQFixed(QFontEngineQPA::Tag_MinRightBearing, QFixed::fromReal(fe->minRightBearing())); + writeTaggedQFixed(QFontEngineQPA::Tag_UnderlinePosition, fe->underlinePosition()); + writeTaggedUInt8(QFontEngineQPA::Tag_PixelSize, fe->fontDef.pixelSize); + writeTaggedUInt8(QFontEngineQPA::Tag_Weight, fe->fontDef.weight); + writeTaggedUInt8(QFontEngineQPA::Tag_Style, fe->fontDef.style); + + writeTaggedUInt8(QFontEngineQPA::Tag_GlyphFormat, QFontEngineQPA::AlphamapGlyphs); + + writeTaggedString(QFontEngineQPA::Tag_EndOfHeader, QByteArray()); + align4(); + + const quint64 size = dev->pos(); + header.dataSize = qToBigEndian(size - sizeof(header)); + dev->seek(0); + dev->write((const char *)&header, sizeof(header)); + dev->seek(size); +} + +void QPAGenerator::writeGMap() +{ + const quint16 glyphCount = fe->glyphCount(); + + writeUInt16(QFontEngineQPA::GMapBlock); + writeUInt16(0); // padding + writeUInt32(glyphCount * 4); + + QByteArray &buffer = dev->buffer(); + const int numBytes = glyphCount * sizeof(quint32); + qint64 pos = buffer.size(); + buffer.resize(pos + numBytes); + qMemSet(buffer.data() + pos, 0xff, numBytes); + dev->seek(pos + numBytes); +} + +void QPAGenerator::writeBlock(QFontEngineQPA::BlockTag tag, const QByteArray &data) +{ + writeUInt16(tag); + writeUInt16(0); // padding + const int padSize = ((data.size() + 3) / 4) * 4 - data.size(); + writeUInt32(data.size() + padSize); + dev->write(data); + for (int i = 0; i < padSize; ++i) + writeUInt8(0); +} + +void QPAGenerator::writeTaggedString(QFontEngineQPA::HeaderTag tag, const QByteArray &string) +{ + writeUInt16(tag); + writeUInt16(string.length()); + dev->write(string); +} + +void QPAGenerator::writeTaggedUInt32(QFontEngineQPA::HeaderTag tag, quint32 value) +{ + writeUInt16(tag); + writeUInt16(sizeof(value)); + writeUInt32(value); +} + +void QPAGenerator::writeTaggedUInt8(QFontEngineQPA::HeaderTag tag, quint8 value) +{ + writeUInt16(tag); + writeUInt16(sizeof(value)); + writeUInt8(value); +} + +void QPAGenerator::writeTaggedQFixed(QFontEngineQPA::HeaderTag tag, QFixed value) +{ + writeUInt16(tag); + writeUInt16(sizeof(quint32)); + writeUInt32(value.value()); +} + + +/* + Creates a new multi QPA engine. + + This function takes ownership of the QFontEngine, increasing it's refcount. +*/ +QFontEngineMultiQPA::QFontEngineMultiQPA(QFontEngine *fe, int _script, const QStringList &fallbacks) + : QFontEngineMulti(fallbacks.size() + 1), + fallbackFamilies(fallbacks), script(_script) +{ + engines[0] = fe; + fe->ref.ref(); + fontDef = engines[0]->fontDef; +} + +void QFontEngineMultiQPA::loadEngine(int at) +{ + Q_ASSERT(at < engines.size()); + Q_ASSERT(engines.at(at) == 0); + + QFontDef request = fontDef; + request.styleStrategy |= QFont::NoFontMerging; + request.family = fallbackFamilies.at(at-1); + engines[at] = QFontDatabase::findFont(script, + /*fontprivate*/0, + request); + Q_ASSERT(engines[at]); + engines[at]->ref.ref(); + engines[at]->fontDef = request; +} + +QT_END_NAMESPACE diff --git a/src/gui/text/qfontengine_qpa_p.h b/src/gui/text/qfontengine_qpa_p.h new file mode 100644 index 0000000..467fca6 --- /dev/null +++ b/src/gui/text/qfontengine_qpa_p.h @@ -0,0 +1,262 @@ +/**************************************************************************** +** +** 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 QFONTENGINE_QPA_P_H +#define QFONTENGINE_QPA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +#include +#include +#include +#include + +#include "qfontengine_p.h" + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QFontEngine; +class QFreetypeFace; +class QBuffer; + +class Q_GUI_EXPORT QFontEngineQPA : public QFontEngine +{ +public: + // if you add new tags please make sure to update the tables in + // qpfutil.cpp and tools/makeqpf/qpf2.cpp + enum HeaderTag { + Tag_FontName, // 0 string + Tag_FileName, // 1 string + Tag_FileIndex, // 2 quint32 + Tag_FontRevision, // 3 quint32 + Tag_FreeText, // 4 string + Tag_Ascent, // 5 QFixed + Tag_Descent, // 6 QFixed + Tag_Leading, // 7 QFixed + Tag_XHeight, // 8 QFixed + Tag_AverageCharWidth, // 9 QFixed + Tag_MaxCharWidth, // 10 QFixed + Tag_LineThickness, // 11 QFixed + Tag_MinLeftBearing, // 12 QFixed + Tag_MinRightBearing, // 13 QFixed + Tag_UnderlinePosition, // 14 QFixed + Tag_GlyphFormat, // 15 quint8 + Tag_PixelSize, // 16 quint8 + Tag_Weight, // 17 quint8 + Tag_Style, // 18 quint8 + Tag_EndOfHeader, // 19 string + Tag_WritingSystems, // 20 bitfield + + NumTags + }; + + enum TagType { + StringType, + FixedType, + UInt8Type, + UInt32Type, + BitFieldType + }; + + struct Tag + { + quint16 tag; + quint16 size; + }; + + enum GlyphFormat { + BitmapGlyphs = 1, + AlphamapGlyphs = 8 + }; + + enum { + CurrentMajorVersion = 2, + CurrentMinorVersion = 0 + }; + + // The CMap is identical to the TrueType CMap table format + // The GMap table is a normal array with the total number of + // covered glyphs in the TrueType font + enum BlockTag { + CMapBlock, + GMapBlock, + GlyphBlock + }; + + struct Q_PACKED Header + { + char magic[4]; // 'QPF2' + quint32 lock; // values: 0 = unlocked, 0xffffffff = read-only, otherwise qws client id of locking process + quint8 majorVersion; + quint8 minorVersion; + quint16 dataSize; + }; + + struct Q_PACKED Block + { + quint16 tag; + quint16 pad; + quint32 dataSize; + }; + + struct Q_PACKED Glyph + { + quint8 width; + quint8 height; + quint8 bytesPerLine; + qint8 x; + qint8 y; + qint8 advance; + }; + + QFontEngineQPA(const QFontDef &def, const QByteArray &data); + ~QFontEngineQPA(); + + FaceId faceId() const { return face_id; } + bool getSfntTableData(uint tag, uchar *buffer, uint *length) const; + + bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const; + void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const; + + void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags); + QImage alphaMapForGlyph(glyph_t t); + + glyph_metrics_t boundingBox(const QGlyphLayout &glyphs); + glyph_metrics_t boundingBox(glyph_t glyph); + + QFixed ascent() const; + QFixed descent() const; + QFixed leading() const; + qreal maxCharWidth() const; + qreal minLeftBearing() const; + qreal minRightBearing() const; + QFixed underlinePosition() const; + QFixed lineThickness() const; + + Type type() const; + + bool canRender(const QChar *string, int len); + inline const char *name() const { return "QPF2"; } + + virtual int glyphCount() const { return glyphMapEntries; } + + bool isValid() const; + + const Glyph *findGlyph(glyph_t g) const; + + static bool verifyHeader(const uchar *data, int size); + static QVariant extractHeaderField(const uchar *data, HeaderTag tag); + +private: + + const uchar *fontData; + int dataSize; + const uchar *externalCMap; + quint32 cmapOffset; + int cmapSize; + quint32 glyphMapOffset; + quint32 glyphMapEntries; + quint32 glyphDataOffset; + quint32 glyphDataSize; + QString internalFileName; + QString encodedFileName; + bool readOnly; + + FaceId face_id; + QByteArray freetypeCMapTable; + mutable bool kerning_pairs_loaded; +}; + +struct QPAGenerator +{ + QPAGenerator(QBuffer *device, QFontEngine *engine) + : dev(device), fe(engine) {} + + void generate(); + void writeHeader(); + void writeGMap(); + void writeBlock(QFontEngineQPA::BlockTag tag, const QByteArray &data); + + void writeTaggedString(QFontEngineQPA::HeaderTag tag, const QByteArray &string); + void writeTaggedUInt32(QFontEngineQPA::HeaderTag tag, quint32 value); + void writeTaggedUInt8(QFontEngineQPA::HeaderTag tag, quint8 value); + void writeTaggedQFixed(QFontEngineQPA::HeaderTag tag, QFixed value); + + void writeUInt16(quint16 value) { value = qToBigEndian(value); dev->write((const char *)&value, sizeof(value)); } + void writeUInt32(quint32 value) { value = qToBigEndian(value); dev->write((const char *)&value, sizeof(value)); } + void writeUInt8(quint8 value) { dev->write((const char *)&value, sizeof(value)); } + void writeInt8(qint8 value) { dev->write((const char *)&value, sizeof(value)); } + + void align4() { while (dev->pos() & 3) { dev->putChar('\0'); } } + + QBuffer *dev; + QFontEngine *fe; +}; + +class QFontEngineMultiQPA : public QFontEngineMulti +{ +public: + QFontEngineMultiQPA(QFontEngine *fe, int script, const QStringList &fallbacks); + + void loadEngine(int at); + +private: + QStringList fallbackFamilies; + int script; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QFONTENGINE_QPA_P_H diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp new file mode 100644 index 0000000..7bb1f9a --- /dev/null +++ b/src/gui/text/qplatformfontdatabase_qpa.cpp @@ -0,0 +1,195 @@ +#include "qplatformfontdatabase_qpa.h" +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +extern void qt_registerFont(const QString &familyname, const QString &foundryname, int weight, + QFont::Style style, int stretch, bool antialiased,bool scalable, int pixelSize, + const QSupportedWritingSystems &writingSystems, void *hanlde); + +void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void *handle) +{ + if (dataArray.size() == 0) + return; + + const uchar *data = reinterpret_cast(dataArray.constData()); + if (QFontEngineQPA::verifyHeader(data, dataArray.size())) { + QString fontName = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_FontName).toString(); + int pixelSize = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_PixelSize).toInt(); + QVariant weight = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_Weight); + QVariant style = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_Style); + QByteArray writingSystemBits = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_WritingSystems).toByteArray(); + + if (!fontName.isEmpty() && pixelSize) { + int fontWeight = 50; + if (weight.type() == QVariant::Int || weight.type() == QVariant::UInt) + fontWeight = weight.toInt(); + + QFont::Style fontStyle = static_cast(style.toInt()); + + QSupportedWritingSystems writingSystems; + for (int i = 0; i < writingSystemBits.count(); ++i) { + uchar currentByte = writingSystemBits.at(i); + for (int j = 0; j < 8; ++j) { + if (currentByte & 1) + writingSystems.setSupported(QFontDatabase::WritingSystem(i * 8 + j)); + currentByte >>= 1; + } + } + + registerFont(fontName,QString(),fontWeight,fontStyle,100,true,false,pixelSize,writingSystems,handle); + } + } else { + qDebug() << "header verification of QPF2 font failed. maybe it is corrupt?"; + } +} + +void QPlatformFontDatabase::registerFont(const QString &familyname, const QString &foundryname, int weight, + QFont::Style style, int stretch, bool antialiased, bool scalable, int pixelSize, + const QSupportedWritingSystems &writingSystems, void *usrPtr) +{ + if (scalable) + pixelSize = 0; + qt_registerFont(familyname,foundryname,weight,style,stretch,antialiased,scalable,pixelSize,writingSystems,usrPtr); +} + +class QWritingSystemsPrivate +{ +public: + QWritingSystemsPrivate() + : ref(1) + , vector(QFontDatabase::WritingSystemsCount,false) + { + } + + QWritingSystemsPrivate(const QWritingSystemsPrivate *other) + : ref(1) + , vector(other->vector) + { + } + + QAtomicInt ref; + QVector vector; +}; + +QSupportedWritingSystems::QSupportedWritingSystems() +{ + d = new QWritingSystemsPrivate; +} + +QSupportedWritingSystems::QSupportedWritingSystems(const QSupportedWritingSystems &other) +{ + d = other.d; + d->ref.ref(); +} + +QSupportedWritingSystems &QSupportedWritingSystems::operator=(const QSupportedWritingSystems &other) +{ + if (d != other.d) { + other.d->ref.ref(); + if (!d->ref.deref()) + delete d; + d = other.d; + } + return *this; +} + +QSupportedWritingSystems::~QSupportedWritingSystems() +{ + if (!d->ref.deref()) + delete d; +} + +void QSupportedWritingSystems::detach() +{ + if (d->ref != 1) { + QWritingSystemsPrivate *newd = new QWritingSystemsPrivate(d); + if (!d->ref.deref()) + delete d; + d = newd; + } +} + +void QSupportedWritingSystems::setSupported(QFontDatabase::WritingSystem writingSystem, bool support) +{ + detach(); + d->vector[writingSystem] = support; +} + +bool QSupportedWritingSystems::supported(QFontDatabase::WritingSystem writingSystem) const +{ + return d->vector.at(writingSystem); +} + +void QPlatformFontDatabase::populateFontDatabase() +{ + QString fontpath = fontDir(); + + if(!QFile::exists(fontpath)) { + qFatal("QFontDatabase: Cannot find font directory %s - is Qt installed correctly?", + qPrintable(fontpath)); + } + + QDir dir(fontpath); + dir.setNameFilters(QStringList() << QLatin1String("*.qpf2")); + dir.refresh(); + for (int i = 0; i < int(dir.count()); ++i) { + const QByteArray fileName = QFile::encodeName(dir.absoluteFilePath(dir[i])); + QFile file(QString::fromLocal8Bit(fileName)); + if (file.open(QFile::ReadOnly)) { + const QByteArray fileData = file.readAll(); + QByteArray *fileDataPtr = new QByteArray(fileData); + registerQPF2Font(fileData, fileDataPtr); + } + } +} + +QFontEngine *QPlatformFontDatabase::fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle) +{ + Q_UNUSED(script); + Q_UNUSED(handle); + QByteArray *fileDataPtr = static_cast(handle); + QFontEngineQPA *engine = new QFontEngineQPA(fontDef,*fileDataPtr); + qDebug() << fontDef.pixelSize << fontDef.weight << fontDef.style << fontDef.stretch << fontDef.styleHint << fontDef.styleStrategy << fontDef.family << script; + return engine; +} + +QStringList QPlatformFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const +{ + Q_UNUSED(family); + Q_UNUSED(style); + Q_UNUSED(script); + return QStringList(); +} + +void QPlatformFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) +{ + Q_UNUSED(fontData); + Q_UNUSED(fileName); + + qWarning("This plugin does not support application fonts"); +} + +void QPlatformFontDatabase::releaseHandle(void *handle) +{ + QByteArray *fileDataPtr = static_cast(handle); + delete fileDataPtr; +} + +QString QPlatformFontDatabase::fontDir() const +{ + QString fontpath = QString::fromLocal8Bit(qgetenv("QT_QPA_FONTDIR")); + if (fontpath.isEmpty()) { +#ifndef QT_NO_SETTINGS + fontpath = QLibraryInfo::location(QLibraryInfo::LibrariesPath); + fontpath += QLatin1String("/fonts"); +#endif + } + + return fontpath; +} + +QT_END_NAMESPACE diff --git a/src/gui/text/qplatformfontdatabase_qpa.h b/src/gui/text/qplatformfontdatabase_qpa.h new file mode 100644 index 0000000..a34033f --- /dev/null +++ b/src/gui/text/qplatformfontdatabase_qpa.h @@ -0,0 +1,65 @@ +#ifndef QPLATFORMFONTDATABASE_QPA_H +#define QPLATFORMFONTDATABASE_QPA_H + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QWritingSystemsPrivate; + +class Q_GUI_EXPORT QSupportedWritingSystems +{ +public: + + QSupportedWritingSystems(); + QSupportedWritingSystems(const QSupportedWritingSystems &other); + QSupportedWritingSystems &operator=(const QSupportedWritingSystems &other); + ~QSupportedWritingSystems(); + + void setSupported(QFontDatabase::WritingSystem, bool supported = true); + bool supported(QFontDatabase::WritingSystem) const; + +private: + void detach(); + + QWritingSystemsPrivate *d; + + friend Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &); + friend Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &); +}; + +Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &); +Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &); + +class QFontRequestPrivate; + +class Q_GUI_EXPORT QPlatformFontDatabase +{ +public: + virtual void populateFontDatabase(); + virtual QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); + virtual QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const; + virtual void addApplicationFont(const QByteArray &fontData, const QString &fileName); + virtual void releaseHandle(void *handle); + + virtual QString fontDir() const; + + //callback + static void registerQPF2Font(const QByteArray &dataArray, void *handle); + static void registerFont(const QString &familyname, const QString &foundryname, int weight, + QFont::Style style, int stetch, bool antialiased, bool scalable, int pixelSize, + const QSupportedWritingSystems &writingSystems, void *handle); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMFONTDATABASE_QPA_H diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index 1040ad8..8721d80 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -25,7 +25,7 @@ HEADERS += \ text/qabstracttextdocumentlayout.h \ text/qtextdocumentlayout_p.h \ text/qtextcursor.h \ - text/qtextcursor_p.h \ + text/qtextcursor_p.h \ text/qtextdocumentfragment.h \ text/qtextdocumentfragment_p.h \ text/qtextimagehandler_p.h \ @@ -39,7 +39,7 @@ HEADERS += \ text/qzipwriter_p.h \ text/qtextodfwriter_p.h \ text/qstatictext_p.h \ - text/qstatictext.h + text/qstatictext.h SOURCES += \ text/qfont.cpp \ @@ -69,7 +69,7 @@ SOURCES += \ text/qcssparser.cpp \ text/qzip.cpp \ text/qtextodfwriter.cpp \ - text/qstatictext.cpp + text/qstatictext.cpp win32 { SOURCES += \ @@ -112,15 +112,15 @@ embedded { qpa { SOURCES += \ - text/qfont_qws.cpp \ - text/qfontengine_ft.cpp \ - text/qfontengine_qpf.cpp \ - text/qabstractfontengine_qws.cpp + text/qfont_qpa.cpp \ + text/qfontengine_qpa.cpp \ + text/qplatformfontdatabase_qpa.cpp + HEADERS += \ - text/qfontengine_ft_p.h \ - text/qabstractfontengine_qws.h \ - text/qabstractfontengine_p.h + text/qplatformfontdatabase_qpa.h + DEFINES += QT_NO_FONTCONFIG + DEFINES += QT_NO_FREETYPE } symbian { @@ -142,6 +142,7 @@ symbian { } } +!qpa { contains(QT_CONFIG, freetype) { SOURCES += \ ../3rdparty/freetype/src/base/ftbase.c \ @@ -215,6 +216,7 @@ contains(QT_CONFIG, freetype) { contains(QT_CONFIG, fontconfig) { CONFIG += opentype } +}#!qpa DEFINES += QT_NO_OPENTYPE INCLUDEPATH += ../3rdparty/harfbuzz/src diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro index f81ec31..48128fb 100644 --- a/src/plugins/platforms/directfb/directfb.pro +++ b/src/plugins/platforms/directfb/directfb.pro @@ -27,5 +27,7 @@ HEADERS = qdirectfbintegration.h \ qdirectfbinput.h \ qdirectfbcursor.h \ qdirectfbwindow.h + +include(../fontdatabases/genericunix/genericunix.pri) target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp index b19a1d9..64b98db 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp +++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp @@ -46,6 +46,8 @@ #include "qdirectfbcursor.h" #include "qdirectfbwindow.h" +#include "qgenericunixfontdatabase.h" + #include #include @@ -80,6 +82,7 @@ QDirectFbScreen::~QDirectFbScreen() } QDirectFbIntegration::QDirectFbIntegration() + : mFontDb(new QGenericUnixFontDatabase()) { const QStringList args = QCoreApplication::arguments(); int argc = args.size(); @@ -133,9 +136,9 @@ QWindowSurface *QDirectFbIntegration::createWindowSurface(QWidget *widget, WId w return new QDirectFbWindowSurface(widget,winId); } -QBlittable *QDirectFbIntegration::createBlittable(const QSize &size) const +QPlatformFontDatabase *QDirectFbIntegration::fontDatabase() const { - return new QDirectFbBlitter(size); + return mFontDb; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.h b/src/plugins/platforms/directfb/qdirectfbintegration.h index 27847e2..d2d8367 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.h +++ b/src/plugins/platforms/directfb/qdirectfbintegration.h @@ -87,14 +87,16 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; - QBlittable *createBlittable(const QSize &size) const; QList screens() const { return mScreens; } + QPlatformFontDatabase *fontDatabase() const; + private: QList mScreens; QDirectFbInput *mInput; QThread *mInputRunner; + QPlatformFontDatabase *mFontDb; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro index 5d1318a..7ad8fd9 100644 --- a/src/plugins/platforms/eglfs/eglfs.pro +++ b/src/plugins/platforms/eglfs/eglfs.pro @@ -25,5 +25,7 @@ HEADERS = qeglfsintegration.h \ qeglfswindowsurface.h \ qeglfsscreen.h +include(../fontdatabases/genericunix/genericunix.pri) + target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index 2b673ae..07605ec 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -48,11 +48,14 @@ #include #include +#include "qgenericunixfontdatabase.h" + #include QT_BEGIN_NAMESPACE QEglFSIntegration::QEglFSIntegration() + mFontDb(new QGenericUnixFontDatabase()) { m_primaryScreen = new QEglFSScreen(EGL_DEFAULT_DISPLAY); @@ -90,4 +93,9 @@ QWindowSurface *QEglFSIntegration::createWindowSurface(QWidget *widget, WId winI return new QEglFSWindowSurface(m_primaryScreen,widget); } +QPlatformFontDatabase *QEglFSIntegration::fontDatabase() const +{ + return mFontDb; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h index f15b6b2..0342539 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.h +++ b/src/plugins/platforms/eglfs/qeglfsintegration.h @@ -62,7 +62,10 @@ public: QList screens() const { return mScreens; } + QPlatformFontDatabase *fontDatabase() const; + private: + QPlatformFontDatabase *mFontDb; QList mScreens; QEglFSScreen *m_primaryScreen; }; diff --git a/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri b/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri new file mode 100644 index 0000000..21aedba --- /dev/null +++ b/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri @@ -0,0 +1,82 @@ +DEFINES += QT_NO_FONTCONFIG +HEADERS += \ + $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h \ + $$QT_SOURCE_TREE/src/gui/text/qfontengine_ft_p.h + +SOURCES += \ + $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp \ + $$QT_SOURCE_TREE/src/gui/text/qfontengine_ft.cpp + +INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src + +INCLUDEPATH += $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/basicunix + +CONFIG += opentype + +contains(QT_CONFIG, freetype) { + SOURCES += \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftbase.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftbbox.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftdebug.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftglyph.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftinit.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftmm.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/fttype1.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftsynth.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftbitmap.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/bdf/bdf.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/cache/ftcache.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/cff/cff.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/cid/type1cid.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/gzip/ftgzip.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/pcf/pcf.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/pfr/pfr.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/psaux/psaux.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/pshinter/pshinter.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/psnames/psmodule.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/raster/raster.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/sfnt/sfnt.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/smooth/smooth.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/truetype/truetype.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/type1/type1.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/type42/type42.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/winfonts/winfnt.c \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/lzw/ftlzw.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvalid.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvbase.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvgdef.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvjstf.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvcommn.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvgpos.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvgsub.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvmod.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afangles.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afglobal.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/aflatin.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afmodule.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afdummy.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afhints.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afloader.c\ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/autofit.c + + symbian { + SOURCES += \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftsystem.c + } else { + SOURCES += \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/builds/unix/ftsystem.c + INCLUDEPATH += \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/builds/unix + } + + INCLUDEPATH += \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/src \ + $$QT_SOURCE_TREE/src/3rdparty/freetype/include + + DEFINES += FT2_BUILD_LIBRARY 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) + LIBS_PRIVATE += -lfreetype + } + diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp new file mode 100644 index 0000000..5b8ca63 --- /dev/null +++ b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp @@ -0,0 +1,281 @@ +#include "qbasicunixfontdatabase.h" + +#include +#include + +#include +#include +#include + +#undef QT_NO_FREETYPE +#include +#include + +#include +#include FT_TRUETYPE_TABLES_H + +#define SimplifiedChineseCsbBit 18 +#define TraditionalChineseCsbBit 20 +#define JapaneseCsbBit 17 +#define KoreanCsbBit 21 + +static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = { + // Any, + { 127, 127 }, + // Latin, + { 0, 127 }, + // Greek, + { 7, 127 }, + // Cyrillic, + { 9, 127 }, + // Armenian, + { 10, 127 }, + // Hebrew, + { 11, 127 }, + // Arabic, + { 13, 127 }, + // Syriac, + { 71, 127 }, + //Thaana, + { 72, 127 }, + //Devanagari, + { 15, 127 }, + //Bengali, + { 16, 127 }, + //Gurmukhi, + { 17, 127 }, + //Gujarati, + { 18, 127 }, + //Oriya, + { 19, 127 }, + //Tamil, + { 20, 127 }, + //Telugu, + { 21, 127 }, + //Kannada, + { 22, 127 }, + //Malayalam, + { 23, 127 }, + //Sinhala, + { 73, 127 }, + //Thai, + { 24, 127 }, + //Lao, + { 25, 127 }, + //Tibetan, + { 70, 127 }, + //Myanmar, + { 74, 127 }, + // Georgian, + { 26, 127 }, + // Khmer, + { 80, 127 }, + // SimplifiedChinese, + { 126, 127 }, + // TraditionalChinese, + { 126, 127 }, + // Japanese, + { 126, 127 }, + // Korean, + { 56, 127 }, + // Vietnamese, + { 0, 127 }, // same as latin1 + // Other, + { 126, 127 }, + // Ogham, + { 78, 127 }, + // Runic, + { 79, 127 }, + // Nko, + { 14, 127 }, +}; + +static QSupportedWritingSystems determineWritingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2]) +{ + QSupportedWritingSystems writingSystems; + bool hasScript = false; + + int i; + for(i = 0; i < QFontDatabase::WritingSystemsCount; i++) { + int bit = requiredUnicodeBits[i][0]; + int index = bit/32; + int flag = 1 << (bit&31); + if (bit != 126 && unicodeRange[index] & flag) { + bit = requiredUnicodeBits[i][1]; + index = bit/32; + + flag = 1 << (bit&31); + if (bit == 127 || unicodeRange[index] & flag) { + writingSystems.setSupported(QFontDatabase::WritingSystem(i)); + hasScript = true; + // qDebug("font %s: index=%d, flag=%8x supports script %d", familyName.latin1(), index, flag, i); + } + } + } + if(codePageRange[0] & (1 << SimplifiedChineseCsbBit)) { + writingSystems.setSupported(QFontDatabase::SimplifiedChinese); + hasScript = true; + //qDebug("font %s supports Simplified Chinese", familyName.latin1()); + } + if(codePageRange[0] & (1 << TraditionalChineseCsbBit)) { + writingSystems.setSupported(QFontDatabase::TraditionalChinese); + hasScript = true; + //qDebug("font %s supports Traditional Chinese", familyName.latin1()); + } + if(codePageRange[0] & (1 << JapaneseCsbBit)) { + writingSystems.setSupported(QFontDatabase::Japanese); + hasScript = true; + //qDebug("font %s supports Japanese", familyName.latin1()); + } + if(codePageRange[0] & (1 << KoreanCsbBit)) { + writingSystems.setSupported(QFontDatabase::Korean); + hasScript = true; + //qDebug("font %s supports Korean", familyName.latin1()); + } + if (!hasScript) + writingSystems.setSupported(QFontDatabase::Symbol); + + return writingSystems; +} + +static inline bool scriptRequiresOpenType(int script) +{ + return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala) + || script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko); +} + +void QBasicUnixFontDatabase::populateFontDatabase() +{ + QPlatformFontDatabase::populateFontDatabase(); + QString fontpath = fontDir(); + + if(!QFile::exists(fontpath)) { + qFatal("QFontDatabase: Cannot find font directory %s - is Qt installed correctly?", + qPrintable(fontpath)); + } + + QDir dir(fontpath); + dir.setNameFilters(QStringList() << QLatin1String("*.ttf") + << QLatin1String("*.ttc") << QLatin1String("*.pfa") + << QLatin1String("*.pfb")); + dir.refresh(); + for (int i = 0; i < int(dir.count()); ++i) { + const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i])); +// qDebug() << "looking at" << file; + addTTFile(QByteArray(), file); + } +} + +QFontEngine *QBasicUnixFontDatabase::fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *usrPtr) +{ + QFontEngineFT *engine; + FontFile *fontfile = static_cast (usrPtr); + QFontEngine::FaceId fid; + fid.filename = fontfile->fileName.toLocal8Bit(); + fid.index = fontfile->indexValue; + engine = new QFontEngineFT(fontDef); + + bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias); + QFontEngineFT::GlyphFormat format = antialias? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono; + if (!engine->init(fid,antialias,format)) { + delete engine; + engine = 0; + return engine; + } + if (engine->invalid()) { + delete engine; + engine = 0; + } else if (scriptRequiresOpenType(script)) { + HB_Face hbFace = engine->harfbuzzFace(); + if (!hbFace || !hbFace->supported_scripts[script]) { + delete engine; + engine = 0; + } + } + + return engine; +} + +QStringList QBasicUnixFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const +{ + Q_UNUSED(family); + Q_UNUSED(style); + Q_UNUSED(script); + return QStringList(); +} + +void QBasicUnixFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) +{ + addTTFile(fontData,fileName.toLocal8Bit()); +} + +void QBasicUnixFontDatabase::releaseHandle(void *handle) +{ + FontFile *file = static_cast(handle); + delete file; +} + +void QBasicUnixFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file) +{ + extern FT_Library qt_getFreetype(); + FT_Library library = qt_getFreetype(); + + int index = 0; + int numFaces = 0; + do { + FT_Face face; + FT_Error error; + if (!fontData.isEmpty()) { + error = FT_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, &face); + } else { + error = FT_New_Face(library, file.constData(), index, &face); + } + if (error != FT_Err_Ok) { + qDebug() << "FT_New_Face failed with index" << index << ":" << hex << error; + break; + } + numFaces = face->num_faces; + + int weight = QFont::Normal; + + QFont::Style style = QFont::StyleNormal; + if (face->style_flags & FT_STYLE_FLAG_ITALIC) + style = QFont::StyleItalic; + + if (face->style_flags & FT_STYLE_FLAG_BOLD) + weight = QFont::Bold; + + QSupportedWritingSystems writingSystems; + // detect symbol fonts + for (int i = 0; i < face->num_charmaps; ++i) { + FT_CharMap cm = face->charmaps[i]; + if (cm->encoding == ft_encoding_adobe_custom + || cm->encoding == ft_encoding_symbol) { + writingSystems.setSupported(QFontDatabase::Symbol); + break; + } + } + + TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, ft_sfnt_os2); + if (os2) { + quint32 unicodeRange[4] = { + os2->ulUnicodeRange1, os2->ulUnicodeRange2, os2->ulUnicodeRange3, os2->ulUnicodeRange4 + }; + quint32 codePageRange[2] = { + os2->ulCodePageRange1, os2->ulCodePageRange2 + }; + + writingSystems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange); + } + + QString family = QString::fromAscii(face->family_name); + FontFile *fontFile = new FontFile; + fontFile->fileName = file; + fontFile->indexValue = index; + + registerFont(family,"",weight,style,100,true,true,0,writingSystems,fontFile); + + FT_Done_Face(face); + ++index; + } while (index < numFaces); +} diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h new file mode 100644 index 0000000..401a4aa --- /dev/null +++ b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h @@ -0,0 +1,26 @@ +#ifndef QBASICUNIXFONTDATABASE_H +#define QBASICUNIXFONTDATABASE_H + +#include +#include +#include + +struct FontFile +{ + QString fileName; + int indexValue; +}; + +class QBasicUnixFontDatabase : public QPlatformFontDatabase +{ +public: + void populateFontDatabase(); + QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); + QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const; + void addApplicationFont(const QByteArray &fontData, const QString &fileName); + void releaseHandle(void *handle); + + static void addTTFile(const QByteArray &fontData, const QByteArray &file); +}; + +#endif // QBASICUNIXFONTDATABASE_H diff --git a/src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri b/src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri new file mode 100644 index 0000000..19c74ed --- /dev/null +++ b/src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri @@ -0,0 +1,12 @@ +include(../basicunix/basicunix.pri) + +HEADERS += \ + $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h + +SOURCES += \ + $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp + +INCLUDEPATH += $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/fontconfig +LIBS_PRIVATE += -lfontconfig + + diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp new file mode 100644 index 0000000..562cb2d --- /dev/null +++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -0,0 +1,528 @@ +#include "qfontconfigdatabase.h" + +#include +#include + +#include + +#include +#include + +#include +#include + + + +#include +#include FT_TRUETYPE_TABLES_H + +#include + +#define SimplifiedChineseCsbBit 18 +#define TraditionalChineseCsbBit 20 +#define JapaneseCsbBit 17 +#define KoreanCsbBit 21 + +static inline bool requiresOpenType(int writingSystem) +{ + return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala) + || writingSystem == QFontDatabase::Khmer || writingSystem == QFontDatabase::Nko); +} +static inline bool scriptRequiresOpenType(int script) +{ + return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala) + || script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko); +} + +static int getFCWeight(int fc_weight) +{ + int qtweight = QFont::Black; + if (fc_weight <= (FC_WEIGHT_LIGHT + FC_WEIGHT_MEDIUM) / 2) + qtweight = QFont::Light; + else if (fc_weight <= (FC_WEIGHT_MEDIUM + FC_WEIGHT_DEMIBOLD) / 2) + qtweight = QFont::Normal; + else if (fc_weight <= (FC_WEIGHT_DEMIBOLD + FC_WEIGHT_BOLD) / 2) + qtweight = QFont::DemiBold; + else if (fc_weight <= (FC_WEIGHT_BOLD + FC_WEIGHT_BLACK) / 2) + qtweight = QFont::Bold; + + return qtweight; +} + +static const char *specialLanguages[] = { + "en", // Common + "el", // Greek + "ru", // Cyrillic + "hy", // Armenian + "he", // Hebrew + "ar", // Arabic + "syr", // Syriac + "div", // Thaana + "hi", // Devanagari + "bn", // Bengali + "pa", // Gurmukhi + "gu", // Gujarati + "or", // Oriya + "ta", // Tamil + "te", // Telugu + "kn", // Kannada + "ml", // Malayalam + "si", // Sinhala + "th", // Thai + "lo", // Lao + "bo", // Tibetan + "my", // Myanmar + "ka", // Georgian + "ko", // Hangul + "", // Ogham + "", // Runic + "km", // Khmer + "" // N'Ko +}; +enum { SpecialLanguageCount = sizeof(specialLanguages) / sizeof(const char *) }; + +static const ushort specialChars[] = { + 0, // English + 0, // Greek + 0, // Cyrillic + 0, // Armenian + 0, // Hebrew + 0, // Arabic + 0, // Syriac + 0, // Thaana + 0, // Devanagari + 0, // Bengali + 0, // Gurmukhi + 0, // Gujarati + 0, // Oriya + 0, // Tamil + 0xc15, // Telugu + 0xc95, // Kannada + 0xd15, // Malayalam + 0xd9a, // Sinhala + 0, // Thai + 0, // Lao + 0, // Tibetan + 0x1000, // Myanmar + 0, // Georgian + 0, // Hangul + 0x1681, // Ogham + 0x16a0, // Runic + 0, // Khmer + 0x7ca // N'Ko +}; +enum { SpecialCharCount = sizeof(specialChars) / sizeof(ushort) }; + +// this could become a list of all languages used for each writing +// system, instead of using the single most common language. +static const char *languageForWritingSystem[] = { + 0, // Any + "en", // Latin + "el", // Greek + "ru", // Cyrillic + "hy", // Armenian + "he", // Hebrew + "ar", // Arabic + "syr", // Syriac + "div", // Thaana + "hi", // Devanagari + "bn", // Bengali + "pa", // Gurmukhi + "gu", // Gujarati + "or", // Oriya + "ta", // Tamil + "te", // Telugu + "kn", // Kannada + "ml", // Malayalam + "si", // Sinhala + "th", // Thai + "lo", // Lao + "bo", // Tibetan + "my", // Myanmar + "ka", // Georgian + "km", // Khmer + "zh-cn", // SimplifiedChinese + "zh-tw", // TraditionalChinese + "ja", // Japanese + "ko", // Korean + "vi", // Vietnamese + 0, // Symbol + 0, // Ogham + 0, // Runic + 0 // N'Ko +}; +enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) }; + +// Unfortunately FontConfig doesn't know about some languages. We have to test these through the +// charset. The lists below contain the systems where we need to do this. +static const ushort sampleCharForWritingSystem[] = { + 0, // Any + 0, // Latin + 0, // Greek + 0, // Cyrillic + 0, // Armenian + 0, // Hebrew + 0, // Arabic + 0, // Syriac + 0, // Thaana + 0, // Devanagari + 0, // Bengali + 0, // Gurmukhi + 0, // Gujarati + 0, // Oriya + 0, // Tamil + 0xc15, // Telugu + 0xc95, // Kannada + 0xd15, // Malayalam + 0xd9a, // Sinhala + 0, // Thai + 0, // Lao + 0, // Tibetan + 0x1000, // Myanmar + 0, // Georgian + 0, // Khmer + 0, // SimplifiedChinese + 0, // TraditionalChinese + 0, // Japanese + 0, // Korean + 0, // Vietnamese + 0, // Symbol + 0x1681, // Ogham + 0x16a0, // Runic + 0x7ca // N'Ko +}; +enum { SampleCharCount = sizeof(sampleCharForWritingSystem) / sizeof(ushort) }; + +// Newer FontConfig let's us sort out fonts that contain certain glyphs, but no +// open type tables for is directly. Do this so we don't pick some strange +// pseudo unicode font +static const char *openType[] = { + 0, // Any + 0, // Latin + 0, // Greek + 0, // Cyrillic + 0, // Armenian + 0, // Hebrew + 0, // Arabic + "syrc", // Syriac + "thaa", // Thaana + "deva", // Devanagari + "beng", // Bengali + "guru", // Gurmukhi + "gurj", // Gujarati + "orya", // Oriya + "taml", // Tamil + "telu", // Telugu + "knda", // Kannada + "mlym", // Malayalam + "sinh", // Sinhala + 0, // Thai + 0, // Lao + "tibt", // Tibetan + "mymr", // Myanmar + 0, // Georgian + "khmr", // Khmer + 0, // SimplifiedChinese + 0, // TraditionalChinese + 0, // Japanese + 0, // Korean + 0, // Vietnamese + 0, // Symbol + 0, // Ogham + 0, // Runic + "nko " // N'Ko +}; + +void QFontconfigDatabase::populateFontDatabase() +{ + FcFontSet *fonts; + + QString familyName; + FcChar8 *value = 0; + int weight_value; + int slant_value; + int spacing_value; + FcChar8 *file_value; + int indexValue; + FcChar8 *foundry_value; + FcBool scalable; + FcBool antialias; + + { + FcObjectSet *os = FcObjectSetCreate(); + FcPattern *pattern = FcPatternCreate(); + const char *properties [] = { + FC_FAMILY, FC_WEIGHT, FC_SLANT, + FC_SPACING, FC_FILE, FC_INDEX, + FC_LANG, FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE, FC_WEIGHT, + FC_WIDTH, +#if FC_VERSION >= 20297 + FC_CAPABILITY, +#endif + (const char *)0 + }; + const char **p = properties; + while (*p) { + FcObjectSetAdd(os, *p); + ++p; + } + fonts = FcFontList(0, pattern, os); + FcObjectSetDestroy(os); + FcPatternDestroy(pattern); + } + + for (int i = 0; i < fonts->nfont; i++) { + if (FcPatternGetString(fonts->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch) + continue; + // capitalize(value); + familyName = QString::fromUtf8((const char *)value); + slant_value = FC_SLANT_ROMAN; + weight_value = FC_WEIGHT_MEDIUM; + spacing_value = FC_PROPORTIONAL; + file_value = 0; + indexValue = 0; + scalable = FcTrue; + + + if (FcPatternGetInteger (fonts->fonts[i], FC_SLANT, 0, &slant_value) != FcResultMatch) + slant_value = FC_SLANT_ROMAN; + if (FcPatternGetInteger (fonts->fonts[i], FC_WEIGHT, 0, &weight_value) != FcResultMatch) + weight_value = FC_WEIGHT_MEDIUM; + if (FcPatternGetInteger (fonts->fonts[i], FC_SPACING, 0, &spacing_value) != FcResultMatch) + spacing_value = FC_PROPORTIONAL; + if (FcPatternGetString (fonts->fonts[i], FC_FILE, 0, &file_value) != FcResultMatch) + file_value = 0; + if (FcPatternGetInteger (fonts->fonts[i], FC_INDEX, 0, &indexValue) != FcResultMatch) + indexValue = 0; + if (FcPatternGetBool(fonts->fonts[i], FC_SCALABLE, 0, &scalable) != FcResultMatch) + scalable = FcTrue; + if (FcPatternGetString(fonts->fonts[i], FC_FOUNDRY, 0, &foundry_value) != FcResultMatch) + foundry_value = 0; + if(FcPatternGetBool(fonts->fonts[i],FC_ANTIALIAS,0,&antialias) != FcResultMatch) + antialias = true; + + QSupportedWritingSystems writingSystems; + FcLangSet *langset = 0; + FcResult res = FcPatternGetLangSet(fonts->fonts[i], FC_LANG, 0, &langset); + if (res == FcResultMatch) { + for (int i = 1; i < LanguageCount; ++i) { + const FcChar8 *lang = (const FcChar8*) languageForWritingSystem[i]; + if (lang) { + FcLangResult langRes = FcLangSetHasLang(langset, lang); + if (langRes != FcLangDifferentLang) + writingSystems.setSupported(QFontDatabase::WritingSystem(i)); + } + } + } else { + // we set Other to supported for symbol fonts. It makes no + // sense to merge these with other ones, as they are + // special in a way. + writingSystems.setSupported(QFontDatabase::Other); + } + + FcCharSet *cs = 0; + res = FcPatternGetCharSet(fonts->fonts[i], FC_CHARSET, 0, &cs); + if (res == FcResultMatch) { + // some languages are not supported by FontConfig, we rather check the + // charset to detect these + for (int i = 1; i < SampleCharCount; ++i) { + if (!sampleCharForWritingSystem[i]) + continue; + if (FcCharSetHasChar(cs, sampleCharForWritingSystem[i])) + writingSystems.setSupported(QFontDatabase::WritingSystem(i)); + } + } + +#if FC_VERSION >= 20297 + for (int j = 1; j < LanguageCount; ++j) { + if (writingSystems.supported(QFontDatabase::WritingSystem(j)) + && requiresOpenType(j) && openType[j]) { + FcChar8 *cap; + res = FcPatternGetString (fonts->fonts[i], FC_CAPABILITY, 0, &cap); + if (res != FcResultMatch || !strstr((const char *)cap, openType[j])) + writingSystems.setSupported(QFontDatabase::WritingSystem(j),false); + } + } +#endif + + FontFile *fontFile = new FontFile; + fontFile->fileName = QLatin1String((const char *)file_value); + fontFile->indexValue = indexValue; + + QFont::Style style = (slant_value == FC_SLANT_ITALIC) + ? QFont::StyleItalic + : ((slant_value == FC_SLANT_OBLIQUE) + ? QFont::StyleOblique + : QFont::StyleNormal); + int weight = getFCWeight(weight_value); + + double pixel_size = 0; + if (!scalable) { + int width = 100; + FcPatternGetInteger (fonts->fonts[i], FC_WIDTH, 0, &width); + FcPatternGetDouble (fonts->fonts[i], FC_PIXEL_SIZE, 0, &pixel_size); + } + + QPlatformFontDatabase::registerFont(familyName,QLatin1String((const char *)foundry_value),weight,style,100,antialias,scalable,pixel_size,writingSystems,fontFile); +// qDebug() << familyName << (const char *)foundry_value << weight << style << &writingSystems << scalable << true << pixel_size; + } + + FcFontSetDestroy (fonts); + + struct FcDefaultFont { + const char *qtname; + const char *rawname; + bool fixed; + }; + const FcDefaultFont defaults[] = { + { "Serif", "serif", false }, + { "Sans Serif", "sans-serif", false }, + { "Monospace", "monospace", true }, + { 0, 0, false } + }; + const FcDefaultFont *f = defaults; + // aliases only make sense for 'common', not for any of the specials + QSupportedWritingSystems ws; + ws.setSupported(QFontDatabase::Latin); + + while (f->qtname) { + registerFont(f->qtname,"",50,QFont::StyleNormal,100,true,true,0,ws,0); + registerFont(f->qtname,"",50,QFont::StyleItalic,100,true,true,0,ws,0); + registerFont(f->qtname,"",50,QFont::StyleOblique,100,true,true,0,ws,0); + ++f; + } + + const FcDefaultFont *s = defaults; + QFont font("Sans Serif"); + font.setPointSize(9); + QApplication::setFont(font); +} + +QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::Script script, void *usrPtr) +{ + QFontDef fontDef = f; + + QFontEngineFT *engine; + FontFile *fontfile = static_cast (usrPtr); + QFontEngine::FaceId fid; + fid.filename = fontfile->fileName.toLocal8Bit(); + fid.index = fontfile->indexValue; + + //try and get the pattern + FcPattern *pattern = FcPatternCreate(); + + bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias); + QFontEngineFT::GlyphFormat format = antialias? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono; + + engine = new QFontEngineFT(fontDef); + + FcValue value; + value.type = FcTypeString; + QByteArray cs = fontDef.family.toUtf8(); + value.u.s = (const FcChar8 *)cs.data(); + FcPatternAdd(pattern,FC_FAMILY,value,true); + + + value.u.s = (const FcChar8 *)fid.filename.data(); + FcPatternAdd(pattern,FC_FILE,value,true); + + value.type = FcTypeInteger; + value.u.i = fid.index; + FcPatternAdd(pattern,FC_INDEX,value,true); + + QFontEngineFT::HintStyle default_hint_style; + + if (FcConfigSubstitute(0,pattern,FcMatchPattern)) { + + //hinting + int hint_style = 0; + if (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch) + hint_style = QFontEngineFT::HintFull; + switch (hint_style) { + case FC_HINT_NONE: + default_hint_style = QFontEngineFT::HintNone; + break; + case FC_HINT_SLIGHT: + default_hint_style = QFontEngineFT::HintLight; + break; + case FC_HINT_MEDIUM: + default_hint_style = QFontEngineFT::HintMedium; + break; + default: + default_hint_style = QFontEngineFT::HintFull; + break; + } + } + + engine->setDefaultHintStyle(default_hint_style); + if (!engine->init(fid,antialias,format)) { + delete engine; + engine = 0; + return engine; + } + if (engine->invalid()) { + delete engine; + engine = 0; + } else if (scriptRequiresOpenType(script)) { + HB_Face hbFace = engine->harfbuzzFace(); + if (!hbFace || !hbFace->supported_scripts[script]) { + delete engine; + engine = 0; + } + } + + return engine; +} + +QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const +{ + QStringList fallbackFamilies; + FcPattern *pattern = FcPatternCreate(); + if (!pattern) + return fallbackFamilies; + + FcValue value; + value.type = FcTypeString; + QByteArray cs = family.toUtf8(); + value.u.s = (const FcChar8 *)cs.data(); + FcPatternAdd(pattern,FC_FAMILY,value,true); + + int slant_value = FC_SLANT_ROMAN; + if (style == QFont::StyleItalic) + slant_value = FC_SLANT_ITALIC; + else if (style == QFont::StyleOblique) + slant_value = FC_SLANT_OBLIQUE; + FcPatternAddInteger(pattern, FC_SLANT, slant_value); + + if (script != QUnicodeTables::Common && *specialLanguages[script] != '\0') { + Q_ASSERT(script < QUnicodeTables::ScriptCount); + FcLangSet *ls = FcLangSetCreate(); + FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]); + FcPatternAddLangSet(pattern, FC_LANG, ls); + FcLangSetDestroy(ls); + } + + FcConfigSubstitute(0, pattern, FcMatchPattern); + FcConfigSubstitute(0, pattern, FcMatchFont); + + FcResult result = FcResultMatch; + FcFontSet *fontSet = FcFontSort(0,pattern,FcFalse,0,&result); + + if (fontSet && result == FcResultMatch) + { + for (int i = 0; i < fontSet->nfont; i++) { + FcChar8 *value = 0; + if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch) + continue; + // capitalize(value); + QString familyName = QString::fromUtf8((const char *)value); + if (!fallbackFamilies.contains(familyName,Qt::CaseInsensitive)) { + fallbackFamilies << familyName; + } + + } + } +// qDebug() << "fallbackFamilies for:" << family << fallbackFamilies; + + return fallbackFamilies; +} diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h new file mode 100644 index 0000000..5945b6e --- /dev/null +++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h @@ -0,0 +1,15 @@ +#ifndef QFONTCONFIGDATABASE_H +#define QFONTCONFIGDATABASE_H + +#include +#include "qbasicunixfontdatabase.h" + +class QFontconfigDatabase : public QBasicUnixFontDatabase +{ +public: + void populateFontDatabase(); + QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); + QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const; +}; + +#endif // QFONTCONFIGDATABASE_H diff --git a/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri b/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri new file mode 100644 index 0000000..dbcfbce --- /dev/null +++ b/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri @@ -0,0 +1,10 @@ +contains(QT_CONFIG, fontconfig) { + include(../fontconfig/fontconfig.pri) + DEFINES += Q_FONTCONFIGDATABASE +} else { + include(../basicunix/basicunix.pri) +} + +INCLUDEPATH += $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/genericunix +HEADERS += \ + $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h diff --git a/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h b/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h new file mode 100644 index 0000000..ec083f8 --- /dev/null +++ b/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h @@ -0,0 +1,12 @@ +#ifndef QGENERICUNIXFONTDATABASE_H +#define QGENERICUNIXFONTDATABASE_H + +#ifdef Q_FONTCONFIGDATABASE +#include "qfontconfigdatabase.h" +typedef QFontconfigDatabase QGenericUnixFontDatabase; +#else +#include "qbasicunixfontdatabase.h" +typedef QBasicUnixFontDatabase QGenericUnixFontDatabase; +#endif //Q_FONTCONFIGDATABASE + +#endif // QGENERICUNIXFONTDATABASE_H diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro index 8d4b6d7..216b899 100644 --- a/src/plugins/platforms/linuxfb/linuxfb.pro +++ b/src/plugins/platforms/linuxfb/linuxfb.pro @@ -7,6 +7,7 @@ SOURCES = main.cpp qlinuxfbintegration.cpp HEADERS = qlinuxfbintegration.h include(../fb_base/fb_base.pri) +include(../fontdatabases/genericunix/genericunix.pri) target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp index 437af81..aa1d401 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp @@ -41,6 +41,7 @@ #include "qlinuxfbintegration.h" #include "../fb_base/fb_base.h" +#include "qgenericunixfontdatabase.h" #include #include // overrides QT_OPEN #include @@ -156,6 +157,7 @@ void QLinuxFbIntegrationPrivate::closeTty() } QLinuxFbIntegration::QLinuxFbIntegration() + :fontDb(new QGenericUnixFontDatabase()) { d_ptr = new QLinuxFbIntegrationPrivate(); @@ -799,6 +801,11 @@ QPlatformWindow *QLinuxFbIntegration::createPlatformWindow(QWidget *widget, WId return w; } +QPlatformFontDatabase *QLinuxFbIntegration::fontDatabase() const +{ + return fontDb; +} + QLinuxFbScreen::QLinuxFbScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat) : compositePainter(0) { diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h index dc61df5..a5d7abd 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h @@ -82,6 +82,8 @@ public: QList screens() const { return mScreens; } + QPlatformFontDatabase *fontDatabase() const; + private: QLinuxFbScreen *mPrimaryScreen; QList mScreens; @@ -122,6 +124,7 @@ private: void setPixelFormat(struct fb_var_screeninfo); void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo); void blank(bool on); + QPlatformFontDatabase *fontDb; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro index b68230c..3446e81 100644 --- a/src/plugins/platforms/platforms.pro +++ b/src/plugins/platforms/platforms.pro @@ -5,7 +5,15 @@ contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl) { SUBDIRS += minimal -#this don't work. but leave it for now -qpa:x11 { +contains(QT_CONFIG, mitshm) { SUBDIRS += testlite } + +linux { + SUBDIRS += linuxfb +} + +unix { + SUBDIRS += vnc \ + qvfb +} diff --git a/src/plugins/platforms/qvfb/qvfb.pro b/src/plugins/platforms/qvfb/qvfb.pro index a560755..d2b332a 100644 --- a/src/plugins/platforms/qvfb/qvfb.pro +++ b/src/plugins/platforms/qvfb/qvfb.pro @@ -7,5 +7,7 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms SOURCES = main.cpp qvfbintegration.cpp qvfbwindowsurface.cpp HEADERS = qvfbintegration.h qvfbwindowsurface.h +include(../fontdatabases/genericunix/genericunix.pri) + target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/qvfb/qvfbintegration.cpp b/src/plugins/platforms/qvfb/qvfbintegration.cpp index a50763a..0cc3938 100644 --- a/src/plugins/platforms/qvfb/qvfbintegration.cpp +++ b/src/plugins/platforms/qvfb/qvfbintegration.cpp @@ -62,6 +62,8 @@ #include #include +#include "qgenericunixfontdatabase.h" + QT_BEGIN_NAMESPACE @@ -409,6 +411,7 @@ QImage *QVFbScreen::screenImage() } QVFbIntegration::QVFbIntegration(const QStringList ¶mList) + : mFontDb(new QGenericUnixFontDatabase()) { int displayId = 0; if (paramList.length() > 0) @@ -435,6 +438,11 @@ QPlatformWindow *QVFbIntegration::createPlatformWindow(QWidget *widget, WId) con return new QVFbWindow(mPrimaryScreen, widget); } +QPlatformFontDatabase *QVFbIntegration::fontDatabase() const +{ + return mFontDb; +} + QT_END_NAMESPACE #include "qvfbintegration.moc" diff --git a/src/plugins/platforms/qvfb/qvfbintegration.h b/src/plugins/platforms/qvfb/qvfbintegration.h index e46e0da..198a45c 100644 --- a/src/plugins/platforms/qvfb/qvfbintegration.h +++ b/src/plugins/platforms/qvfb/qvfbintegration.h @@ -84,9 +84,12 @@ public: QList screens() const { return mScreens; } + QPlatformFontDatabase *fontDatabase() const; + private: QVFbScreen *mPrimaryScreen; QList mScreens; + QPlatformFontDatabase *mFontDb; }; diff --git a/src/plugins/platforms/testlite/qtestliteintegration.cpp b/src/plugins/platforms/testlite/qtestliteintegration.cpp index a8e0fa7..68e9051 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.cpp +++ b/src/plugins/platforms/testlite/qtestliteintegration.cpp @@ -49,6 +49,7 @@ #include #include "qtestlitewindow.h" +#include "qgenericunixfontdatabase.h" #ifndef QT_NO_OPENGL #include @@ -84,8 +85,8 @@ public: QTestLiteIntegration::QTestLiteIntegration(bool useOpenGL) : mUseOpenGL(useOpenGL) + , mFontDb(new QGenericUnixFontDatabase()) { - xd = new MyDisplay; mPrimaryScreen = new QTestLiteScreen(); @@ -136,6 +137,11 @@ QPixmap QTestLiteIntegration::grabWindow(WId window, int x, int y, int width, in return QPixmap::fromImage(img); } +QPlatformFontDatabase *QTestLiteIntegration::fontDatabase() const +{ + return mFontDb; +} + bool QTestLiteIntegration::hasOpenGL() const { #ifndef QT_NO_OPENGL diff --git a/src/plugins/platforms/testlite/qtestliteintegration.h b/src/plugins/platforms/testlite/qtestliteintegration.h index ac10841..8286ef0 100644 --- a/src/plugins/platforms/testlite/qtestliteintegration.h +++ b/src/plugins/platforms/testlite/qtestliteintegration.h @@ -84,6 +84,8 @@ public: QList screens() const { return mScreens; } + QPlatformFontDatabase *fontDatabase() const; + bool hasOpenGL() const; MyDisplay *xd; @@ -92,6 +94,7 @@ private: bool mUseOpenGL; QTestLiteScreen *mPrimaryScreen; QList mScreens; + QPlatformFontDatabase *mFontDb; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp index 1f477db..1de4b9d 100644 --- a/src/plugins/platforms/testlite/qtestlitewindow.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp @@ -622,7 +622,7 @@ void QTestLiteWindow::handleKeyEvent(QEvent::Type type, void *ev) int qtcode = chars.toUpper()[0]; //Not exactly right... if (modifiers & Qt::ControlModifier && qtcode < ' ') qtcode = chars[0] + '@'; - QWindowSystemInterface::handleKeyEvent(widget(), e->time, type, qtcode, modifiers, QString::fromLatin1(chars)); + QWindowSystemInterface::handleKeyEvent(0, e->time, type, qtcode, modifiers, QString::fromLatin1(chars)); } else { qWarning() << "unknown X keycode" << hex << e->keycode << keySym; } @@ -647,9 +647,9 @@ WId QTestLiteWindow::winId() const void QTestLiteWindow::setParent(const QPlatformWindow *window) { - QPoint point = widget()->mapTo(widget()->nativeParentWidget(),QPoint()); - XReparentWindow(xd->display,x_window,window->winId(),point.x(),point.y()); - XMapWindow(xd->display, x_window); + QPoint point = widget()->mapTo(widget()->nativeParentWidget(),QPoint()); + XReparentWindow(xd->display,x_window,window->winId(),point.x(),point.y()); + XMapWindow(xd->display, x_window); } void QTestLiteWindow::raise() @@ -1441,7 +1441,7 @@ bool MyDisplay::handleEvent(XEvent *xe) xw->handleMouseEvent(QEvent::MouseMove, &xe->xbutton); break; - case XKeyPress: + case XKeyPress: xw->handleKeyEvent(QEvent::KeyPress, &xe->xkey); break; diff --git a/src/plugins/platforms/testlite/testlite.pro b/src/plugins/platforms/testlite/testlite.pro index 0a5ebb2..05bd384 100644 --- a/src/plugins/platforms/testlite/testlite.pro +++ b/src/plugins/platforms/testlite/testlite.pro @@ -1,18 +1,29 @@ -TARGET = qtestlitegraphicssystem -include(../../qpluginbase.pri) +TARGET = qtestlite +include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms -SOURCES = main.cpp qtestliteintegration.cpp qtestlitewindowsurface.cpp qtestlitewindow.cpp -HEADERS = qtestliteintegration.h qtestlitewindowsurface.h qtestlitewindow.h +SOURCES = \ + main.cpp \ + qtestliteintegration.cpp \ + qtestlitewindowsurface.cpp \ + qtestlitewindow.cpp + +HEADERS = \ + qtestliteintegration.h \ + qtestlitewindowsurface.h \ + qtestlitewindow.h + LIBS += -lX11 -lXext +include (../fontdatabases/genericunix/genericunix.pri) + contains(QT_CONFIG, opengl) { QT += opengl HEADERS += qglxintegration.h SOURCES += qglxintegration.cpp } -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp index 331c16a..b36ff33 100644 --- a/src/plugins/platforms/vnc/qvncintegration.cpp +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -49,6 +49,7 @@ #include #include +#include "qgenericunixfontdatabase.h" QVNCScreen::QVNCScreen(QRect screenSize, int screenId) : QFbScreen::QFbScreen() @@ -100,7 +101,7 @@ static void usage() } QVNCIntegration::QVNCIntegration(const QStringList& paramList) - : virtualDesktop(false) + : virtualDesktop(false), fontDb(new QGenericUnixFontDatabase()) { int sizeX = defaultWidth(); int sizeY = defaultHeight(); @@ -234,3 +235,8 @@ void QVNCIntegration::moveToScreen(QWidget *window, int screen) window->platformWindow()->setGeometry(window->geometry()); // this should be unified elsewhere newScreen->addWindow(static_cast(window->platformWindow())); } + +QPlatformFontDatabase *QVNCIntegration::fontDatabase() const +{ + return fontDb; +} diff --git a/src/plugins/platforms/vnc/qvncintegration.h b/src/plugins/platforms/vnc/qvncintegration.h index 241993d..dfc0e6b 100644 --- a/src/plugins/platforms/vnc/qvncintegration.h +++ b/src/plugins/platforms/vnc/qvncintegration.h @@ -45,6 +45,7 @@ #include "qvnccursor.h" #include "../fb_base/fb_base.h" #include +#include "qgenericunixfontdatabase.h" QT_BEGIN_NAMESPACE @@ -91,10 +92,13 @@ public: bool isVirtualDesktop() { return virtualDesktop; } void moveToScreen(QWidget *window, int screen); + QPlatformFontDatabase *fontDatabase() const; + private: QVNCScreen *mPrimaryScreen; QList mScreens; bool virtualDesktop; + QPlatformFontDatabase *fontDb; }; diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro index 65824a2..6c448f5 100644 --- a/src/plugins/platforms/vnc/vnc.pro +++ b/src/plugins/platforms/vnc/vnc.pro @@ -13,6 +13,7 @@ HEADERS += qvnccursor.h SOURCES += qvnccursor.cpp include(../fb_base/fb_base.pri) +include(../fontdatabases/genericunix/genericunix.pri) target.path += $$[QT_INSTALL_PLUGINS]/platforms -- cgit v0.12 From 4e630e3af2f33a123abb58f15f95d640d9054cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 2 Sep 2010 15:27:27 +0200 Subject: Lighthouse: Move shared context init so it is not created untill anyone asks for it. --- src/plugins/platforms/testlite/qglxintegration.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index fbffcab..e262d5b 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -241,18 +241,18 @@ QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindow , m_drawable((Drawable)window) , m_context(0) { - if (!QPlatformGLContext::defaultSharedContext()) { - if (m_defaultSharedContextMutex.tryLock()){ - createDefaultSharedContex(xd); - m_defaultSharedContextMutex.unlock(); - } else { - m_defaultSharedContextMutex.lock(); //wait to the the shared context is created - m_defaultSharedContextMutex.unlock(); - } - } QPlatformGLContext *sharePlatformContext; if (format.useDefaultSharedContext()) { + if (!QPlatformGLContext::defaultSharedContext()) { + if (m_defaultSharedContextMutex.tryLock()){ + createDefaultSharedContex(xd); + 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(); @@ -309,9 +309,6 @@ void QGLXGLContext::createDefaultSharedContex(MyDisplay *xd) } else { qWarning("Warning no shared context created"); } - - - } void QGLXGLContext::makeCurrent() -- cgit v0.12 From c8ae543a3b649778d8f6e1b2d45faf3a4b1d4012 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 3 Sep 2010 10:03:23 +0200 Subject: Compile fix Note: the #ifdef matches the one around eglReleaseBuffer, but it may be that that should have checked for EGL instead of GL_ES --- src/opengl/qgl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 2145001..cd3121e 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -93,6 +93,9 @@ #include "qlibrary.h" #include +#ifdef QT_OPENGL_ES +#include +#endif // #define QT_GL_CONTEXT_RESOURCE_DEBUG -- cgit v0.12 From 975490d721ca98251aefa7e7f50e6e54e63b79c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 3 Sep 2010 09:27:44 +0200 Subject: Lighthouse: Fix eventhandling for when widgets are in destructor This is a problem when you send events from a seperate thread --- src/gui/kernel/qwindowsysteminterface_qpa.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index c49bd36..f10c038 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -61,6 +61,10 @@ extern QPointer qt_last_mouse_receiver; void QWindowSystemInterface::handleEnterEvent(QWidget *tlw) { + QWidgetData *data = qt_qwidget_data(tlw); + if (data->in_destructor) + return; + if (tlw) { QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); @@ -69,12 +73,20 @@ void QWindowSystemInterface::handleEnterEvent(QWidget *tlw) void QWindowSystemInterface::handleLeaveEvent(QWidget *tlw) { + QWidgetData *data = qt_qwidget_data(tlw); + if (data->in_destructor) + return; + QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(tlw); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect) { + QWidgetData *data = qt_qwidget_data(tlw); + if (data->in_destructor) + return; + QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } @@ -102,6 +114,9 @@ void QWindowSystemInterface::handleMouseEvent(QWidget *w, const QPoint & local, void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { + QWidgetData *data = qt_qwidget_data(tlw); + if (data->in_destructor) + tlw = 0; QWindowSystemInterfacePrivate::MouseEvent * e = new QWindowSystemInterfacePrivate::MouseEvent(tlw, timestamp, local, global, b); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); @@ -114,6 +129,10 @@ void QWindowSystemInterface::handleKeyEvent(QWidget *w, QEvent::Type t, int k, Q void QWindowSystemInterface::handleKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) { + QWidgetData *data = qt_qwidget_data(tlw); + if (data->in_destructor) + tlw = 0; + QWindowSystemInterfacePrivate::KeyEvent * e = new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); @@ -126,6 +145,10 @@ void QWindowSystemInterface::handleWheelEvent(QWidget *w, const QPoint & local, void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { + QWidgetData *data = qt_qwidget_data(tlw); + if (data->in_destructor) + tlw = 0; + QWindowSystemInterfacePrivate::WheelEvent *e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, d, o); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); -- cgit v0.12 From 136c32ddb97a12eefcbbfebf63075237c07d4cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 3 Sep 2010 12:53:14 +0200 Subject: Lighthouse: Added QDirectFbGlContext This is untested since I have no HW to test on, but its in the public api, so that we have something to build on. --- src/plugins/platforms/directfb/directfb.pro | 6 ++- .../platforms/directfb/qdirectfbglcontext.cpp | 58 ++++++++++++++++++++++ .../platforms/directfb/qdirectfbglcontext.h | 28 +++++++++++ src/plugins/platforms/directfb/qdirectfbwindow.cpp | 23 ++++++++- src/plugins/platforms/directfb/qdirectfbwindow.h | 3 ++ 5 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 src/plugins/platforms/directfb/qdirectfbglcontext.cpp create mode 100644 src/plugins/platforms/directfb/qdirectfbglcontext.h diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro index 48128fb..65c49e3 100644 --- a/src/plugins/platforms/directfb/directfb.pro +++ b/src/plugins/platforms/directfb/directfb.pro @@ -19,14 +19,16 @@ SOURCES = main.cpp \ qdirectfbconvenience.cpp \ qdirectfbinput.cpp \ qdirectfbcursor.cpp \ - qdirectfbwindow.cpp + qdirectfbwindow.cpp \ + qdirectfbglcontext.cpp HEADERS = qdirectfbintegration.h \ qdirectfbwindowsurface.h \ qdirectfbblitter.h \ qdirectfbconvenience.h \ qdirectfbinput.h \ qdirectfbcursor.h \ - qdirectfbwindow.h + qdirectfbwindow.h \ + qdirectfbglcontext.h include(../fontdatabases/genericunix/genericunix.pri) target.path += $$[QT_INSTALL_PLUGINS]/platforms diff --git a/src/plugins/platforms/directfb/qdirectfbglcontext.cpp b/src/plugins/platforms/directfb/qdirectfbglcontext.cpp new file mode 100644 index 0000000..fe96efe --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbglcontext.cpp @@ -0,0 +1,58 @@ +#include "qdirectfbglcontext.h" + +#include + +#include + +QDirectFbGLContext::QDirectFbGLContext(IDirectFBGL *glContext) + : m_dfbGlContext(glContext) +{ + DFBResult result; + DFBGLAttributes glAttribs; + result = m_dfbGlContext->GetAttributes(glContext, &glAttribs); + if (result == DFB_OK) { + m_windowFormat.setDepthBufferSize(glAttribs.depth_size); + m_windowFormat.setStencilBufferSize(glAttribs.stencil_size); + + m_windowFormat.setRedBufferSize(glAttribs.red_size); + m_windowFormat.setGreenBufferSize(glAttribs.green_size); + m_windowFormat.setBlueBufferSize(glAttribs.blue_size); + m_windowFormat.setAlphaBufferSize(glAttribs.alpha_size); + + m_windowFormat.setAccumBufferSize(glAttribs.accum_red_size); + m_windowFormat.setAlpha(glAttribs.accum_alpha_size); + + m_windowFormat.setDoubleBuffer(glAttribs.double_buffer); + m_windowFormat.setStereo(glAttribs.stereo); + } +} + +void QDirectFbGLContext::makeCurrent() +{ + m_dfbGlContext->Lock(m_dfbGlContext); +} + +void QDirectFbGLContext::doneCurrent() +{ + m_dfbGlContext->Unlock(m_dfbGlContext); +} + +void *QDirectFbGLContext::getProcAddress(const QString &procName) +{ + void *proc; + DFBResult result = m_dfbGlContext->GetProcAddress(m_dfbGlContext,qPrintable(procName),&proc); + if (result == DFB_OK) + return proc; + return 0; +} + +void QDirectFbGLContext::swapBuffers() +{ +// m_dfbGlContext->Unlock(m_dfbGlContext); //maybe not in doneCurrent() + qDebug() << "Swap buffers"; +} + +QPlatformWindowFormat QDirectFbGLContext::platformWindowFormat() const +{ + return m_windowFormat; +} diff --git a/src/plugins/platforms/directfb/qdirectfbglcontext.h b/src/plugins/platforms/directfb/qdirectfbglcontext.h new file mode 100644 index 0000000..037587e --- /dev/null +++ b/src/plugins/platforms/directfb/qdirectfbglcontext.h @@ -0,0 +1,28 @@ +#ifndef QDIRECTFBGLCONTEXT_H +#define QDIRECTFBGLCONTEXT_H + +#include + +#include "qdirectfbconvenience.h" + +class QDirectFbGLContext : public QPlatformGLContext +{ +public: + explicit QDirectFbGLContext(IDirectFBGL *glContext); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void *getProcAddress(const QString &procName); + + QPlatformWindowFormat platformWindowFormat() const; + + +private: + IDirectFBGL *m_dfbGlContext; + + QPlatformWindowFormat m_windowFormat; + +}; + +#endif // QDIRECTFBGLCONTEXT_H diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.cpp b/src/plugins/platforms/directfb/qdirectfbwindow.cpp index 30e6f5a..f82fbd6 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindow.cpp +++ b/src/plugins/platforms/directfb/qdirectfbwindow.cpp @@ -40,13 +40,14 @@ ****************************************************************************/ #include "qdirectfbwindow.h" #include "qdirectfbinput.h" +#include "qdirectfbglcontext.h" #include #include QDirectFbWindow::QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler) - : QPlatformWindow(tlw), m_inputHandler(inputhandler) + : QPlatformWindow(tlw), m_inputHandler(inputhandler), m_context(0) { IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); DFBDisplayLayerConfig layerConfig; @@ -155,3 +156,23 @@ WId QDirectFbWindow::winId() const m_dfbWindow->GetID(m_dfbWindow, &id); return WId(id); } + +QPlatformGLContext *QDirectFbWindow::glContext() const +{ + if (!m_context) { + IDirectFBSurface *surface; + DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&surface); + if (result != DFB_OK) { + qWarning("could not retrieve surface in QDirectFbWindow::glContext()"); + return 0; + } + IDirectFBGL *gl; + result = surface->GetGL(surface,&gl); + if (result != DFB_OK) { + qWarning("could not retrieve IDirectFBGL in QDirectFbWindow::glContext()"); + return 0; + } + const_cast(this)->m_context = new QDirectFbGLContext(gl); + } + return m_context; +} diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.h b/src/plugins/platforms/directfb/qdirectfbwindow.h index b512afd..eaf5173 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindow.h +++ b/src/plugins/platforms/directfb/qdirectfbwindow.h @@ -65,10 +65,13 @@ public: void lower(); WId winId() const; + QPlatformGLContext *glContext() const; + private: IDirectFBWindow *m_dfbWindow; QDirectFbInput *m_inputHandler; + QPlatformGLContext *m_context; }; QT_END_NAMESPACE -- cgit v0.12 From cbbca7d2e30e7bb5411b9c7d89feaf6eae54af7e Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 6 Sep 2010 10:27:34 +0200 Subject: Switch to 32 bits per pixel --- src/plugins/platforms/eglfs/qeglfsscreen.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index 0d72862..1b64e7e 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE +//#define QEGL_EXTRA_DEBUG + #ifdef QEGL_EXTRA_DEBUG struct AttrInfo { EGLint attr; const char *name; }; static struct AttrInfo attrs[] = { @@ -84,7 +86,7 @@ static struct AttrInfo attrs[] = { #endif //QEGL_EXTRA_DEBUG QEglFSScreen::QEglFSScreen(EGLNativeDisplayType display) - : m_depth(16), m_format(QImage::Format_RGB16), m_platformContext(0) + : m_depth(32), m_format(QImage::Format_ARGB32_Premultiplied), m_platformContext(0) { #ifdef QEGL_EXTRA_DEBUG qWarning("QEglScreen %p\n", this); @@ -114,11 +116,11 @@ QEglFSScreen::QEglFSScreen(EGLNativeDisplayType display) qWarning("Initialized display %d %d\n", major, minor); QPlatformWindowFormat platformFormat; - platformFormat.setDepth(16); + platformFormat.setDepth(32); platformFormat.setWindowApi(QPlatformWindowFormat::OpenGL); - platformFormat.setRedBufferSize(5); - platformFormat.setGreenBufferSize(6); - platformFormat.setBlueBufferSize(5); + platformFormat.setRedBufferSize(8); + platformFormat.setGreenBufferSize(8); + platformFormat.setBlueBufferSize(8); EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat); EGLNativeWindowType eglWindow = 0; -- cgit v0.12 From c5fe294667d9d8dfcec5c9529185a13ba5a47e91 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 6 Sep 2010 14:53:51 +0200 Subject: Send mouse release events for touch screens --- src/plugins/generic/linuxinput/qlinuxinput.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 32137ee..955aed9 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -155,6 +155,9 @@ void QLinuxInputMouseHandler::readMouseData() } } else if (data->type == EV_KEY && data->code == BTN_TOUCH) { m_buttons = data->value ? Qt::LeftButton : Qt::NoButton; + + QWindowSystemInterface::handleMouseEvent(0, QPoint(m_x, m_y), + QPoint(m_x, m_y), m_buttons); } else if (data->type == EV_KEY) { Qt::MouseButton button = Qt::NoButton; switch (data->code) { -- cgit v0.12 From 04f0d0064eb5bb42123e1519df6073c3b09442ec Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 6 Sep 2010 14:53:51 +0200 Subject: Send mouse release events for touch screens --- src/plugins/generic/linuxinput/qlinuxinput.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 32137ee..955aed9 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -155,6 +155,9 @@ void QLinuxInputMouseHandler::readMouseData() } } else if (data->type == EV_KEY && data->code == BTN_TOUCH) { m_buttons = data->value ? Qt::LeftButton : Qt::NoButton; + + QWindowSystemInterface::handleMouseEvent(0, QPoint(m_x, m_y), + QPoint(m_x, m_y), m_buttons); } else if (data->type == EV_KEY) { Qt::MouseButton button = Qt::NoButton; switch (data->code) { -- cgit v0.12 From 8a92433b5deb14a27457715241b14764c28ffb39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 3 Sep 2010 14:45:43 +0200 Subject: Make phonon gst backend build properly Only software rendering for now... also fix regression I made in QWindowSystemInterface. Its allowed to send in NULL pointers for tlw in some of the functions. So dont ask for the widget data of a NULL pointer. --- src/3rdparty/phonon/gstreamer/devicemanager.cpp | 4 +- src/3rdparty/phonon/gstreamer/videowidget.cpp | 4 ++ src/3rdparty/phonon/gstreamer/x11renderer.h | 4 -- src/gui/kernel/qwindowsysteminterface_qpa.cpp | 50 +++++++++++++--------- src/plugins/phonon/gstreamer/gstreamer.pro | 2 +- .../platforms/testlite/qtestlitewindowsurface.cpp | 2 +- 6 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/3rdparty/phonon/gstreamer/devicemanager.cpp b/src/3rdparty/phonon/gstreamer/devicemanager.cpp index c3826eb..518aa85 100644 --- a/src/3rdparty/phonon/gstreamer/devicemanager.cpp +++ b/src/3rdparty/phonon/gstreamer/devicemanager.cpp @@ -22,7 +22,9 @@ #include "videowidget.h" #include "glrenderer.h" #include "widgetrenderer.h" +#ifdef Q_WS_X11 #include "x11renderer.h" +#endif #include "artssink.h" #include "pulsesupport.h" @@ -264,7 +266,7 @@ AbstractRenderer *DeviceManager::createVideoRenderer(VideoWidget *parent) if (m_videoSinkWidget == "software") { return new WidgetRenderer(parent); } -#ifndef Q_WS_QWS +#ifdef Q_WS_X11 else if (m_videoSinkWidget == "xwindow") { return new X11Renderer(parent); } else { diff --git a/src/3rdparty/phonon/gstreamer/videowidget.cpp b/src/3rdparty/phonon/gstreamer/videowidget.cpp index e1f0ec9..a4c6f79 100644 --- a/src/3rdparty/phonon/gstreamer/videowidget.cpp +++ b/src/3rdparty/phonon/gstreamer/videowidget.cpp @@ -31,7 +31,9 @@ #include "glrenderer.h" #include "widgetrenderer.h" +#ifdef Q_WS_X11 #include "x11renderer.h" +#endif #ifndef QT_NO_PHONON_VIDEO QT_BEGIN_NAMESPACE @@ -116,10 +118,12 @@ void VideoWidget::setupVideoBin() GstPad *videopad = gst_element_get_pad (queue, "sink"); gst_element_add_pad (m_videoBin, gst_ghost_pad_new ("sink", videopad)); gst_object_unref (videopad); +#ifndef Q_WS_QPA QWidget *parentWidget = qobject_cast(parent()); if (parentWidget) parentWidget->winId(); // Due to some existing issues with alien in 4.4, // we must currently force the creation of a parent widget. +#endif m_isValid = true; //initialization ok, accept input } } diff --git a/src/3rdparty/phonon/gstreamer/x11renderer.h b/src/3rdparty/phonon/gstreamer/x11renderer.h index f7140da..8e2ea19 100644 --- a/src/3rdparty/phonon/gstreamer/x11renderer.h +++ b/src/3rdparty/phonon/gstreamer/x11renderer.h @@ -27,8 +27,6 @@ QT_BEGIN_NAMESPACE -#ifndef Q_WS_QWS - class QString; namespace Phonon @@ -61,8 +59,6 @@ private: } } //namespace Phonon::Gstreamer -#endif // Q_WS_QWS - QT_END_NAMESPACE #endif // Phonon_GSTREAMER_X11RENDERER_H diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index f10c038..7b83fd3 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -61,11 +61,11 @@ extern QPointer qt_last_mouse_receiver; void QWindowSystemInterface::handleEnterEvent(QWidget *tlw) { - QWidgetData *data = qt_qwidget_data(tlw); - if (data->in_destructor) - return; - if (tlw) { + QWidgetData *data = qt_qwidget_data(tlw); + if (data->in_destructor) + return; + QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } @@ -73,20 +73,22 @@ void QWindowSystemInterface::handleEnterEvent(QWidget *tlw) void QWindowSystemInterface::handleLeaveEvent(QWidget *tlw) { - QWidgetData *data = qt_qwidget_data(tlw); - if (data->in_destructor) - return; - + if (tlw) { + QWidgetData *data = qt_qwidget_data(tlw); + if (data->in_destructor) + return; + } QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(tlw); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect) { - QWidgetData *data = qt_qwidget_data(tlw); - if (data->in_destructor) - return; - + if (tlw) { + QWidgetData *data = qt_qwidget_data(tlw); + if (data->in_destructor) + return; + } QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } @@ -114,9 +116,11 @@ void QWindowSystemInterface::handleMouseEvent(QWidget *w, const QPoint & local, void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b) { - QWidgetData *data = qt_qwidget_data(tlw); - if (data->in_destructor) - tlw = 0; + if (tlw) { + QWidgetData *data = qt_qwidget_data(tlw); + if (data->in_destructor) + tlw = 0; + } QWindowSystemInterfacePrivate::MouseEvent * e = new QWindowSystemInterfacePrivate::MouseEvent(tlw, timestamp, local, global, b); QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); @@ -129,9 +133,11 @@ void QWindowSystemInterface::handleKeyEvent(QWidget *w, QEvent::Type t, int k, Q void QWindowSystemInterface::handleKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) { - QWidgetData *data = qt_qwidget_data(tlw); - if (data->in_destructor) - tlw = 0; + if (tlw) { + QWidgetData *data = qt_qwidget_data(tlw); + if (data->in_destructor) + tlw = 0; + } QWindowSystemInterfacePrivate::KeyEvent * e = new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count); @@ -145,9 +151,11 @@ void QWindowSystemInterface::handleWheelEvent(QWidget *w, const QPoint & local, void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) { - QWidgetData *data = qt_qwidget_data(tlw); - if (data->in_destructor) - tlw = 0; + if (tlw) { + QWidgetData *data = qt_qwidget_data(tlw); + if (data->in_destructor) + tlw = 0; + } QWindowSystemInterfacePrivate::WheelEvent *e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, d, o); diff --git a/src/plugins/phonon/gstreamer/gstreamer.pro b/src/plugins/phonon/gstreamer/gstreamer.pro index 1013205..02e0848 100644 --- a/src/plugins/phonon/gstreamer/gstreamer.pro +++ b/src/plugins/phonon/gstreamer/gstreamer.pro @@ -58,7 +58,7 @@ SOURCES += $$PHONON_GSTREAMER_DIR/abstractrenderer.cpp \ $$PHONON_GSTREAMER_DIR/volumefadereffect.cpp \ $$PHONON_GSTREAMER_DIR/widgetrenderer.cpp -!embedded { +x11 { HEADERS += $$PHONON_GSTREAMER_DIR/x11renderer.h SOURCES += $$PHONON_GSTREAMER_DIR/x11renderer.cpp } diff --git a/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp b/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp index 53f4791..b3232c8 100644 --- a/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp +++ b/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp @@ -180,7 +180,7 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const } #else // Use MIT_SHM - if (image_info->image) { + if (image_info && image_info->image) { //qDebug() << "Here we go" << image_info->image->width << image_info->image->height; int x = 0; int y = 0; -- cgit v0.12 From 8fbcf5d1a93f50fa59f650468d203115f7a6965b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 7 Sep 2010 16:33:09 +0200 Subject: Lighthouse: fix reparenting from topLevel to child widget also fix Directfb with a hack so that moving windows works --- src/gui/kernel/qwidget_qpa.cpp | 18 ++++++++++-------- src/plugins/platforms/directfb/qdirectfbwindow.cpp | 8 ++++++++ .../platforms/directfb/qdirectfbwindowsurface.cpp | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index b3599bd..ac8b37d 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -145,12 +145,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) } } if (destroyWindow) { - QTLWExtra *topData = d->maybeTopData(); - if (topData) { - delete topData->platformWindow; - topData->platformWindow = 0; - d->data.winid = 0; - } + d->deleteTLSysExtra(); } else { if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) { d->hide_sys(); @@ -403,9 +398,10 @@ void QWidgetPrivate::show_sys() window->setGeometry(geomRect); } if (q->isWindow()) { - if (QWindowSurface *surface = q->windowSurface()) + if (QWindowSurface *surface = q->windowSurface()) { if (windowRect.size() != geomRect.size()) { - surface->resize(geomRect.size()); + surface->resize(geomRect.size()); + } } if (window) @@ -781,6 +777,7 @@ void QWidgetPrivate::createSysExtra() void QWidgetPrivate::deleteSysExtra() { + } void QWidgetPrivate::createTLSysExtra() @@ -789,6 +786,11 @@ void QWidgetPrivate::createTLSysExtra() void QWidgetPrivate::deleteTLSysExtra() { + if (extra && extra->topextra) { + delete extra->topextra->platformWindow; + extra->topextra->platformWindow = 0; + extra->topextra->backingStore.destroy(); + } } void QWidgetPrivate::registerDropSite(bool on) diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.cpp b/src/plugins/platforms/directfb/qdirectfbwindow.cpp index f82fbd6..21eefc4 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindow.cpp +++ b/src/plugins/platforms/directfb/qdirectfbwindow.cpp @@ -44,6 +44,8 @@ #include +#include "qdirectfbwindowsurface.h" + #include QDirectFbWindow::QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler) @@ -95,10 +97,16 @@ QDirectFbWindow::~QDirectFbWindow() void QDirectFbWindow::setGeometry(const QRect &rect) { + bool isMoveOnly = (rect.topLeft() != geometry().topLeft()) && (rect.size() == geometry().size()); QPlatformWindow::setGeometry(rect); m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), rect.width(), rect.height()); + //Hack. When moving since the WindowSurface of a window becomes invalid when moved + if (isMoveOnly) { //if resize then windowsurface is updated. + widget()->windowSurface()->resize(rect.size()); + widget()->update(); + } } void QDirectFbWindow::setOpacity(qreal level) diff --git a/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp b/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp index 271d061..2aef70d 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp @@ -70,7 +70,7 @@ QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window, WId wId) QDirectFbWindowSurface::~QDirectFbWindowSurface() { - + delete m_pixmap; } QPaintDevice *QDirectFbWindowSurface::paintDevice() -- cgit v0.12 From 184a4c66165ab49940e1eae7140a6474531c5f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 8 Sep 2010 07:40:59 +0200 Subject: Lighthouse, DFb don't show windows that Qt::WA_DontShowOnScreen --- src/plugins/platforms/directfb/qdirectfbwindow.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.cpp b/src/plugins/platforms/directfb/qdirectfbwindow.cpp index 21eefc4..74e7a72 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindow.cpp +++ b/src/plugins/platforms/directfb/qdirectfbwindow.cpp @@ -84,6 +84,8 @@ QDirectFbWindow::QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler) m_dfbWindow->SetOpacity(m_dfbWindow,0xff); + setVisible(widget()->isVisible()); + DFBWindowID id; m_dfbWindow->GetID(m_dfbWindow, &id); m_inputHandler->addWindow(id,tlw); @@ -99,13 +101,15 @@ void QDirectFbWindow::setGeometry(const QRect &rect) { bool isMoveOnly = (rect.topLeft() != geometry().topLeft()) && (rect.size() == geometry().size()); QPlatformWindow::setGeometry(rect); - m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), - rect.width(), rect.height()); - - //Hack. When moving since the WindowSurface of a window becomes invalid when moved - if (isMoveOnly) { //if resize then windowsurface is updated. - widget()->windowSurface()->resize(rect.size()); - widget()->update(); + if (widget()->isVisible() && !(widget()->testAttribute(Qt::WA_DontShowOnScreen))) { + m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), + rect.width(), rect.height()); + + //Hack. When moving since the WindowSurface of a window becomes invalid when moved + if (isMoveOnly) { //if resize then windowsurface is updated. + widget()->windowSurface()->resize(rect.size()); + widget()->update(); + } } } -- cgit v0.12 From 1aa1346645c30690c46c0bec7aaeee09c8b68690 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 8 Sep 2010 11:47:50 +0200 Subject: Compile --- src/plugins/platforms/vnc/vnc.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro index 65824a2..affeea0 100644 --- a/src/plugins/platforms/vnc/vnc.pro +++ b/src/plugins/platforms/vnc/vnc.pro @@ -1,6 +1,8 @@ TARGET = qvncgraphicssystem include(../../qpluginbase.pri) +QT += network + QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms SOURCES = main.cpp qvncintegration.cpp -- cgit v0.12 From 59a2ff150795e1281e6b4fea435e74d3434a5ad2 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 8 Sep 2010 12:40:36 +0200 Subject: Experimental multi-touch implementation --- src/gui/kernel/qwindowsysteminterface_qpa.h | 2 +- src/plugins/generic/linuxinput/qlinuxinput.cpp | 152 ++++++++++++++++++++++--- src/plugins/generic/linuxinput/qlinuxinput.h | 3 + 3 files changed, 143 insertions(+), 14 deletions(-) diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h index 5ff4275..1c79f2a 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa.h @@ -73,7 +73,7 @@ public: QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1) QRectF area; // the touched area, centered at position in screen coordinates qreal pressure; // 0 to 1 - Qt::TouchPointStates state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released} + Qt::TouchPointState state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released} }; static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &points); diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 955aed9..2b01973 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -64,9 +64,74 @@ QT_BEGIN_NAMESPACE + +#define QT_QPA_EXPERIMENTAL_MULTITOUCH + +#ifdef QT_QPA_EXPERIMENTAL_MULTITOUCH +class QLinuxInputMouseHandlerData +{ +public: + QLinuxInputMouseHandlerData() :seenMT(false), state(QEvent::TouchBegin), currentIdx(0) {} + + void ensureCurrentPoint() { + if (currentIdx >= touchPoints.size()) { + Q_ASSERT(currentIdx == touchPoints.size()); + QWindowSystemInterface::TouchPoint tp; + tp.id = currentIdx; + tp.isPrimary = (currentIdx == 0); + tp.pressure = 1; + tp.area = QRectF(0,0,1,1); + tp.state = Qt::TouchPointReleased; // init in neutral state + touchPoints.append(tp); + } + } + void setCurrentPoint(int i) { + currentIdx = i; + if (currentIdx < touchPoints.size()) { + currentX = int(touchPoints[currentIdx].area.left()); + currentY = int(touchPoints[currentIdx].area.top()); + } else { + currentY = currentX = -999; + } + } + void advanceCurrentPoint() { + setCurrentPoint(currentIdx + 1); + } + int currentPoint() { return currentIdx; } + void setCurrentX(int value) { + ensureCurrentPoint(); + touchPoints[currentIdx].area.moveLeft(value); + } + bool currentMoved() { + return currentX != touchPoints[currentIdx].area.left() || currentY != touchPoints[currentIdx].area.top(); + } + void updateCurrentPos() { + ensureCurrentPoint(); + touchPoints[currentIdx].area.moveTopLeft(QPointF(currentX, currentY)); + } + void setCurrentState(Qt::TouchPointState state) { + ensureCurrentPoint(); + touchPoints[currentIdx].state = state; + } + Qt::TouchPointState currentState() const { + if (currentIdx < touchPoints.size()) + return touchPoints[currentIdx].state; + return Qt::TouchPointReleased; + } + QList touchPoints; + int currentX; + int currentY; + bool seenMT; + QEvent::Type state; +private: + int currentIdx; +}; +#endif + + QLinuxInputMouseHandler::QLinuxInputMouseHandler(const QString &key, const QString &specification) - : m_notify(0), m_x(0), m_y(0), m_buttons(0) + : m_notify(0), m_x(0), m_y(0), m_buttons(0), d(0) { qDebug() << "QLinuxInputMouseHandler" << key << specification; @@ -85,7 +150,9 @@ QLinuxInputMouseHandler::QLinuxInputMouseHandler(const QString &key, qWarning("Cannot open mouse input device '%s': %s", qPrintable(dev), strerror(errno)); return; } - +#ifdef QT_QPA_EXPERIMENTAL_MULTITOUCH + d = new QLinuxInputMouseHandlerData; +#endif } @@ -93,6 +160,7 @@ QLinuxInputMouseHandler::~QLinuxInputMouseHandler() { if (m_fd >= 0) QT_CLOSE(m_fd); + delete d; } void QLinuxInputMouseHandler::readMouseData() @@ -119,7 +187,7 @@ void QLinuxInputMouseHandler::readMouseData() for (int i = 0; i < n; ++i) { struct ::input_event *data = &buffer[i]; - + //qDebug() << ">>" << hex << data->type << data->code << dec << data->value; bool unknown = false; if (data->type == EV_ABS) { if (data->code == ABS_X && m_x != data->value) { @@ -128,6 +196,28 @@ void QLinuxInputMouseHandler::readMouseData() } else if (data->code == ABS_Y && m_y != data->value) { m_y = data->value; posChanged = true; + } else if (data->code == ABS_PRESSURE) { + //ignore for now... + } else if (data->code == ABS_TOOL_WIDTH) { + //ignore for now... + } else if (data->code == ABS_HAT0X) { + //ignore for now... + } else if (data->code == ABS_HAT0Y) { + //ignore for now... +#ifdef QT_QPA_EXPERIMENTAL_MULTITOUCH + } else if (data->code == ABS_MT_POSITION_X) { + d->currentX = data->value; + d->seenMT = true; + } else if (data->code == ABS_MT_POSITION_Y) { + d->currentY = data->value; + d->seenMT = true; + } else if (data->code == ABS_MT_TOUCH_MAJOR) { + if (data->value == 0) + d->setCurrentState(Qt::TouchPointReleased); + //otherwise, ignore for now... + } else if (data->code == ABS_MT_TOUCH_MINOR) { + //ignore for now... +#endif } else { unknown = true; } @@ -158,7 +248,7 @@ void QLinuxInputMouseHandler::readMouseData() QWindowSystemInterface::handleMouseEvent(0, QPoint(m_x, m_y), QPoint(m_x, m_y), m_buttons); - } else if (data->type == EV_KEY) { + } else if (data->type == EV_KEY && data->code >= BTN_LEFT && data->code <= BTN_MIDDLE) { Qt::MouseButton button = Qt::NoButton; switch (data->code) { case BTN_LEFT: button = Qt::LeftButton; break; @@ -173,17 +263,53 @@ void QLinuxInputMouseHandler::readMouseData() QWindowSystemInterface::handleMouseEvent(0, QPoint(m_x, m_y), QPoint(m_x, m_y), m_buttons); } else if (data->type == EV_SYN && data->code == SYN_REPORT) { - if (!posChanged) - continue; - posChanged = false; - QPoint pos(m_x, m_y); - - QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons); + if (posChanged) { + posChanged = false; + QPoint pos(m_x, m_y); - // pos = m_handler->transform(pos); - //m_handler->limitToScreen(pos); - //m_handler->mouseChanged(pos, m_buttons); + QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons); + } +#ifdef QT_QPA_EXPERIMENTAL_MULTITOUCH + if (d->state == QEvent::TouchBegin && !d->seenMT) { + //no multi-touch events to send + } else { + if (!d->seenMT) + d->state = QEvent::TouchEnd; + + for (int i = d->currentPoint(); i < d->touchPoints.size(); ++i) { + d->touchPoints[i].pressure = 0; + d->touchPoints[i].state = Qt::TouchPointReleased; + } + //qDebug() << "handleTouchEvent" << d->state << d->touchPoints.size() << d->touchPoints[0].state; + QWindowSystemInterface::handleTouchEvent(0, d->state, QTouchEvent::TouchScreen, d->touchPoints); + if (d->seenMT) { + d->state = QEvent::TouchUpdate; + } else { + d->state = QEvent::TouchBegin; + d->touchPoints.clear(); + } + d->setCurrentPoint(0); + d->seenMT = false; + } + } else if (data->type == EV_SYN && data->code == SYN_MT_REPORT) { + //store data for this touch point + + if (!d->seenMT) { + d->setCurrentState(Qt::TouchPointReleased); + } else if (d->currentState() == Qt::TouchPointReleased) { + d->updateCurrentPos(); + d->setCurrentState(Qt::TouchPointPressed); + } else if (d->currentMoved()) { + d->updateCurrentPos(); + d->setCurrentState(Qt::TouchPointMoved); + } else { + d->setCurrentState(Qt::TouchPointStationary); + } + //qDebug() << "end of point" << d->currentPoint() << d->currentX << d->currentY << d->currentState(); + //advance to next tp: + d->advanceCurrentPoint(); +#endif } else if (data->type == EV_MSC && data->code == MSC_SCAN) { // kernel encountered an unmapped key - just ignore it continue; diff --git a/src/plugins/generic/linuxinput/qlinuxinput.h b/src/plugins/generic/linuxinput/qlinuxinput.h index 26ba6a7..535816d 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.h +++ b/src/plugins/generic/linuxinput/qlinuxinput.h @@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE class QSocketNotifier; +class QLinuxInputMouseHandlerData; + class QLinuxInputMouseHandler : public QObject { Q_OBJECT @@ -67,6 +69,7 @@ private: int m_fd; int m_x, m_y; Qt::MouseButtons m_buttons; + QLinuxInputMouseHandlerData *d; }; -- cgit v0.12 From 34625a376b7d08856c6de1f52179d86aaaa30f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 8 Sep 2010 12:55:44 +0200 Subject: Lighthouse, compile fix eglfs --- src/plugins/platforms/eglfs/qeglfsintegration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index 07605ec..a48fde8 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE QEglFSIntegration::QEglFSIntegration() - mFontDb(new QGenericUnixFontDatabase()) + : mFontDb(new QGenericUnixFontDatabase()) { m_primaryScreen = new QEglFSScreen(EGL_DEFAULT_DISPLAY); -- cgit v0.12 From bb5c934d3e2e07ddf3a1c299b2111d7119a01eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 9 Sep 2010 09:26:25 +0200 Subject: Lighthouse: Various compiler warning/error fixes compliments from Vapula --- src/gui/kernel/qapplication_qpa.cpp | 1 - src/gui/kernel/qplatformcursor_qpa.cpp | 8 ++------ src/gui/kernel/qplatformcursor_qpa.h | 2 +- src/gui/kernel/qwindowsysteminterface_qpa.cpp | 2 -- src/gui/kernel/qwindowsysteminterface_qpa_p.h | 2 -- src/plugins/platforms/fb_base/fb_base.cpp | 4 ++-- src/plugins/platforms/fb_base/fb_base.h | 2 +- src/plugins/platforms/linuxfb/qlinuxfbintegration.h | 1 + 8 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index e5b5396..d432829 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -68,7 +68,6 @@ QT_BEGIN_NAMESPACE static QString appName; -static const char *appFont = 0; // application font QWidget *qt_button_down = 0; // widget got last button-down diff --git a/src/gui/kernel/qplatformcursor_qpa.cpp b/src/gui/kernel/qplatformcursor_qpa.cpp index 6665396..ac557b9 100644 --- a/src/gui/kernel/qplatformcursor_qpa.cpp +++ b/src/gui/kernel/qplatformcursor_qpa.cpp @@ -187,10 +187,6 @@ static const uchar mcur_fdiag_bits[] = { 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; -static const uchar cur_blank_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // 20 x 20 static const uchar forbidden_bits[] = { @@ -546,11 +542,11 @@ void QPlatformCursorImage::set(Qt::CursorShape id) \a hy the y coordinate of the cursor's hotspot */ -void QPlatformCursorImage::set(const QImage * image, int hx, int hy) +void QPlatformCursorImage::set(const QImage &image, int hx, int hy) { hot.setX(hx); hot.setY(hy); - cursorImage = *image; + cursorImage = image; } /*! diff --git a/src/gui/kernel/qplatformcursor_qpa.h b/src/gui/kernel/qplatformcursor_qpa.h index abdbfee..71d0e87 100644 --- a/src/gui/kernel/qplatformcursor_qpa.h +++ b/src/gui/kernel/qplatformcursor_qpa.h @@ -63,7 +63,7 @@ public: QImage * image() { return &cursorImage; } QPoint hotspot() { return hot; } void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); - void set(const QImage * image, int hx, int hy); + void set(const QImage &image, int hx, int hy); void set(Qt::CursorShape); private: static void createSystemCursor(int id); diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index 7b83fd3..bb29cbf 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -207,7 +207,6 @@ void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEv Qt::TouchPointStates states; QTouchEvent::TouchPoint p; - int primaryPoint = -1; QList::const_iterator point = points.constBegin(); QList::const_iterator end = points.constEnd(); while (point != end) { @@ -217,7 +216,6 @@ void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEv Qt::TouchPointStates state = point->state; if (point->isPrimary) { state |= Qt::TouchPointPrimary; - primaryPoint = point->id; } p.setState(state); p.setRect(point->area); diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h index 5f3ac5d..78e1f33 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h @@ -49,8 +49,6 @@ QT_BEGIN_NAMESPACE class QWindowSystemInterfacePrivate { public: - Q_ENUMS(EventType); - enum EventType { Close, GeometryChange, diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index ef7ab02..48488d4 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -67,7 +67,7 @@ void QPlatformSoftwareCursor::setCursor(Qt::CursorShape shape) graphic->set(shape); } -void QPlatformSoftwareCursor::setCursor(const QImage * image, int hotx, int hoty) +void QPlatformSoftwareCursor::setCursor(const QImage &image, int hotx, int hoty) { graphic->set(image, hotx, hoty); } @@ -85,7 +85,7 @@ void QPlatformSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget * wid if (shape == Qt::BitmapCursor) { // application supplied cursor QPoint spot = widgetCursor->hotSpot(); - setCursor(&widgetCursor->pixmap().toImage(), spot.x(), spot.y()); + setCursor(widgetCursor->pixmap().toImage(), spot.x(), spot.y()); } else { // system cursor setCursor(shape); diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index 10f292e..e52455a 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -40,7 +40,7 @@ protected: private: void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY); void setCursor(Qt::CursorShape shape); - void setCursor(const QImage * image, int hotx, int hoty); + void setCursor(const QImage &image, int hotx, int hoty); QRect currentRect; // next place to draw the cursor QRect prevRect; // last place the cursor was drawn QRect getCurrentRect(); diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h index a5d7abd..e93495c 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE class QLinuxFbScreen : public QFbScreen { + Q_OBJECT public: QLinuxFbScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat); void setGeometry(QRect rect); -- cgit v0.12 From ee7afe2536c7078c0a29dd409b4317869670c170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 9 Sep 2010 13:27:24 +0200 Subject: Lighthouse Compilefix --- src/gui/kernel/qapplication_qpa.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index d432829..ece035c 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -68,6 +68,7 @@ QT_BEGIN_NAMESPACE static QString appName; +static QString appFont; QWidget *qt_button_down = 0; // widget got last button-down @@ -522,7 +523,7 @@ void qt_init(QApplicationPrivate *priv, int type) QByteArray arg = argv[i]; if (arg == "-fn" || arg == "-font") { if (++i < argc) - appFont = argv[i]; + appFont = QString::fromLocal8Bit(argv[i]); } else if (arg == "-platform") { if (++i < argc) platformName = QLatin1String(argv[i]); -- cgit v0.12 From 41243160f7a9fb5e2eea365ec9757f5496d0387f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 10 Sep 2010 10:22:12 +0200 Subject: Lighthouse: Fixing the openkode implementation --- .../platforms/openkode/qopenkodeintegration.cpp | 136 ++++++++------------- .../platforms/openkode/qopenkodeintegration.h | 3 +- src/plugins/platforms/openkode/qopenkodewindow.cpp | 5 +- 3 files changed, 55 insertions(+), 89 deletions(-) diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index 8fc3862..f8b715f 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -60,33 +60,13 @@ #include "GLES2/gl2ext.h" -#include - - QT_BEGIN_NAMESPACE -QOpenKODEScreen::QOpenKODEScreen() +QOpenKODEScreen::QOpenKODEScreen(KDDisplayNV *kdDisplay, KDDesktopNV *kdDesktop) : mIsFullScreen(false) { - KDDesktopNV *kdDesktop = KD_NULL; - KDDisplayNV *kdDisplay = KD_NULL; - qDebug() << "QOpenKODEScreen::QOpenKODEIntegrationScreen()"; - // Get the default desktop and display - kdDesktop = kdGetDesktopNV(KD_DEFAULT_DESKTOP_NV, KD_NULL); - if (!kdDesktop || kdDesktop == (void*)-1) { - qErrnoWarning(kdGetError(), "Could not obtain KDDesktopNV pointer"); - return; - } - - kdDisplay = kdGetDisplayNV(KD_DEFAULT_DISPLAY_NV, KD_NULL); - if (!kdDisplay || kdDisplay == (void*)-1) { - qErrnoWarning(kdGetError(), "Could not obtain KDDisplayNV pointer"); - kdReleaseDesktopNV(kdDesktop); - return; - } - KDboolean enabled = KD_TRUE; kdSetDisplayPropertybvNV(kdDisplay, KD_DISPLAYPROPERTY_ENABLED_NV, @@ -139,64 +119,64 @@ QOpenKODEScreen::QOpenKODEScreen() } -static GLuint loadShaders(const QString &vertexShader, const QString &fragmentShader) -{ - GLuint prog = 0; - GLuint vertShader; - GLuint fragShader; - - // Create the program - prog = glCreateProgram(); - - // Create the GL shader objects - vertShader = glCreateShader(GL_VERTEX_SHADER); - fragShader = glCreateShader(GL_FRAGMENT_SHADER); - - // Load shader sources into GL and compile - QFile vertexFile(vertexShader); - vertexFile.open(QFile::ReadOnly); - QByteArray vertSource = vertexFile.readAll(); - const char *vertChar = vertSource.constData(); - int vertSize = vertSource.size(); - - QFile fragFile(fragmentShader); - fragFile.open(QFile::ReadOnly); - QByteArray fragSource = fragFile.readAll(); - const char *fragChar = fragSource.constData(); - int fragSize = fragSource.size(); - - glShaderSource(vertShader, 1, (const char**)&vertChar, &vertSize); - glCompileShader(vertShader); - - glShaderSource(fragShader, 1, (const char**)&fragChar, &fragSize); - glCompileShader(fragShader); - - // Attach the shaders to the program - glAttachShader(prog, vertShader); - glAttachShader(prog, fragShader); - - // Delete the shaders - glDeleteShader(vertShader); - glDeleteShader(fragShader); - - // Link and validate the shader program - glLinkProgram(prog); - glValidateProgram(prog); - - return prog; -} - QOpenKODEIntegration::QOpenKODEIntegration() : mEventLoopIntegration(0) { if (kdInitializeNV() == KD_ENOTINITIALIZED) { qFatal("Did not manage to initialize openkode"); } - QOpenKODEScreen *mPrimaryScreen = new QOpenKODEScreen(); - - mScreens.append(mPrimaryScreen); + KDDisplaySystemNV *kdDisplaySystem = kdCreateDisplaySystemSnapshotNV(this); + KDint32 displayCount = 0; + kdGetDisplaySystemPropertyivNV(kdDisplaySystem, KD_DISPLAYPROPERTY_COUNT_NV, 0, &displayCount); + + for (int i = 0; i < displayCount; i++) { + KDchar *displayName = 0; + KDsize displayNameLength = 0; + kdGetDisplaySystemPropertycvNV(kdDisplaySystem,KD_DISPLAYPROPERTY_NAME_NV,i,0,&displayNameLength); + if (!displayNameLength) + continue; + displayName = new KDchar[displayNameLength]; + kdGetDisplaySystemPropertycvNV(kdDisplaySystem,KD_DISPLAYPROPERTY_NAME_NV,i,displayName,&displayNameLength); + + KDDisplayNV *display = kdGetDisplayNV(displayName,this); + if (!display || display == (void*)-1) { + qErrnoWarning(kdGetError(), "Could not obtain KDDisplayNV pointer"); + return; + } + if (displayNameLength) + delete displayName; + + KDchar *desktopName = 0; + KDsize desktopNameLength = 0; + bool openkodeImpDoesNotFail = false; + if (openkodeImpDoesNotFail) { + qDebug() << "printing desktopname"; + kdGetDisplayPropertycvNV(display,KD_DISPLAYPROPERTY_DESKTOP_NAME_NV,desktopName,&desktopNameLength); + if (desktopNameLength) { + desktopName = new KDchar[desktopNameLength]; + kdGetDisplayPropertycvNV(display,KD_DISPLAYPROPERTY_DESKTOP_NAME_NV,desktopName,&desktopNameLength); + } else { + desktopName = KD_DEFAULT_DESKTOP_NV; + } + } else { + desktopName = KD_DEFAULT_DESKTOP_NV; + } + + KDDesktopNV *desktop = kdGetDesktopNV(desktopName,this); + if (!desktop || desktop == (void*)-1) { + qErrnoWarning(kdGetError(), "Could not obtain KDDesktopNV pointer"); + kdReleaseDisplayNV(display); + return; + } + if (desktopNameLength) + delete desktopName; + + QOpenKODEScreen *screen = new QOpenKODEScreen(display,desktop); + mScreens.append(screen); + } } + QOpenKODEIntegration::~QOpenKODEIntegration() { delete mEventLoopIntegration; @@ -212,7 +192,7 @@ QPlatformWindow *QOpenKODEIntegration::createPlatformWindow(QWidget *tlw, WId ) return new QOpenKODEWindow(tlw); } -QWindowSurface *QOpenKODEIntegration::createWindowSurface(QWidget *widget, WId wid) const +QWindowSurface *QOpenKODEIntegration::createWindowSurface(QWidget *widget, WId) const { QWindowSurface *returnSurface = 0; switch (widget->platformWindowFormat().windowApi()) { @@ -248,17 +228,5 @@ QPlatformEventLoopIntegration *QOpenKODEIntegration::createEventLoopIntegration( return mEventLoopIntegration; } -GLuint QOpenKODEIntegration::blitterProgram() -{ - static GLuint shaderProgram = 0; - if (!shaderProgram) { - - shaderProgram = loadShaders(":/shaders/vert.glslv",":/shaders/frag.glslf"); - if (!shaderProgram) - qFatal("QOpenKodeGraphicsSystem(): Cannot load shaders!"); - } - return shaderProgram; -} - QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h index 454aa90..939cae3 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeintegration.h @@ -57,13 +57,14 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE struct KDDesktopNV; +struct KDDisplayNV; class QOpenKODECursor; class QOpenKODEScreen : public QPlatformScreen { Q_OBJECT public: - QOpenKODEScreen(); + QOpenKODEScreen(KDDisplayNV *kdDisplay, KDDesktopNV *kdDesktop); ~QOpenKODEScreen() {} QRect geometry() const { return mGeometry; } diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index 454a50f..fadf564 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -104,9 +104,8 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) format.setRedBufferSize(5); format.setGreenBufferSize(6); format.setBlueBufferSize(5); - tlw->setPlatformWindowFormat(format); - m_eglConfig = q_configFromQPlatformWindowFormat(screen->eglDisplay(),tlw->platformWindowFormat()); + m_eglConfig = q_configFromQPlatformWindowFormat(screen->eglDisplay(),format); m_kdWindow = kdCreateWindow(screen->eglDisplay(), m_eglConfig, @@ -169,7 +168,6 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) QOpenKODEWindow::~QOpenKODEWindow() { - qDebug() << "destroying window" << m_kdWindow; if (m_platformGlContext != QPlatformGLContext::defaultSharedContext()) { delete m_platformGlContext; } @@ -274,7 +272,6 @@ void QOpenKODEWindow::processMouseEvents(const KDEvent *event) default: buttons = Qt::NoButton; } - qDebug() << x << y; QPoint pos(x,y); QWindowSystemInterface::handleMouseEvent(0,event->timestamp,pos,pos,buttons); } -- cgit v0.12 From 0bf1b83cd7d972a69388cdbd759dbba8b1baffd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 10 Sep 2010 15:27:31 +0200 Subject: Lighthouse: Adding QGenericUnixFontDatabase to OpenKODE --- src/plugins/platforms/openkode/openkode.pro | 2 ++ src/plugins/platforms/openkode/qopenkodeintegration.cpp | 10 +++++++++- src/plugins/platforms/openkode/qopenkodeintegration.h | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/openkode/openkode.pro b/src/plugins/platforms/openkode/openkode.pro index 5f2c1cc..c8ae415 100644 --- a/src/plugins/platforms/openkode/openkode.pro +++ b/src/plugins/platforms/openkode/openkode.pro @@ -19,6 +19,8 @@ HEADERS = qopenkodeintegration.h \ qopenkodeeventloopintegration.h \ openkodekeytranslator.h +include (../fontdatabases/genericunix/genericunix.pri) + RESOURCES = resources.qrc target.path += $$[QT_INSTALL_PLUGINS]/platforms diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index f8b715f..0c29a33 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -52,6 +52,8 @@ #include #include +#include "qgenericunixfontdatabase.h" + #include #include #include @@ -120,7 +122,7 @@ QOpenKODEScreen::QOpenKODEScreen(KDDisplayNV *kdDisplay, KDDesktopNV *kdDesktop } QOpenKODEIntegration::QOpenKODEIntegration() - : mEventLoopIntegration(0) + : mEventLoopIntegration(0), mFontDb(new QGenericUnixFontDatabase()) { if (kdInitializeNV() == KD_ENOTINITIALIZED) { qFatal("Did not manage to initialize openkode"); @@ -180,6 +182,7 @@ QOpenKODEIntegration::QOpenKODEIntegration() QOpenKODEIntegration::~QOpenKODEIntegration() { delete mEventLoopIntegration; + delete mFontDb; } QPixmapData *QOpenKODEIntegration::createPixmapData(QPixmapData::PixelType type) const @@ -228,5 +231,10 @@ QPlatformEventLoopIntegration *QOpenKODEIntegration::createEventLoopIntegration( return mEventLoopIntegration; } +QPlatformFontDatabase *QOpenKODEIntegration::fontDatabase() const +{ + return mFontDb; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h index 939cae3..907b7e2 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeintegration.h @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -97,6 +98,8 @@ public: QPlatformEventLoopIntegration *createEventLoopIntegration() const; + QPlatformFontDatabase *fontDatabase() const; + virtual QList screens() const { return mScreens; } static GLuint blitterProgram(); @@ -104,6 +107,7 @@ public: private: QList mScreens; QOpenKODEEventLoopIntegration *mEventLoopIntegration; + QPlatformFontDatabase *mFontDb; }; QT_END_NAMESPACE -- cgit v0.12 From 18e35b4764766ef8171ec30b00d0d6bc19edb0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 16 Sep 2010 10:15:08 +0200 Subject: Lighthouse: Remove auto building platform plugins Reviewed-by: paul --- configure | 6 ------ src/plugins/platforms/platforms.pro | 17 +---------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/configure b/configure index d252f51..0723af1 100755 --- a/configure +++ b/configure @@ -6116,12 +6116,6 @@ if [ "$PLATFORM_QPA" = "yes" ]; then fi fi - # MIT_SHM is required for testlite - if [ "$CFG_MITSHM" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/mitshm "mitshm" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then - QT_CONFIG="$QT_CONFIG mitshm" - fi - fi fi diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro index 3446e81..26ccd44 100644 --- a/src/plugins/platforms/platforms.pro +++ b/src/plugins/platforms/platforms.pro @@ -1,19 +1,4 @@ TEMPLATE = subdirs -contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl) { - SUBDIRS += openvglite -} - SUBDIRS += minimal +SUBDIRS += minimal -contains(QT_CONFIG, mitshm) { - SUBDIRS += testlite -} - -linux { - SUBDIRS += linuxfb -} - -unix { - SUBDIRS += vnc \ - qvfb -} -- cgit v0.12 From e28b1810ba5979dcf2146f9389007b4cfd67a31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 16 Sep 2010 12:45:26 +0200 Subject: Lighthouse: fix QDirectFbScreen::depth to not be fixed to 32 --- src/plugins/platforms/directfb/qdirectfbintegration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp index 64b98db..1b3e035 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp +++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp @@ -71,7 +71,7 @@ QDirectFbScreen::QDirectFbScreen(int display) m_geometry = QRect(0,0,config.width,config.height); const int dpi = 72; const qreal inch = 25.4; - m_depth = 32; + m_depth = QDirectFbConvenience::colorDepthForSurface(config.pixelformat); m_physicalSize = QSize(qRound(config.width * inch / dpi), qRound(config.height *inch / dpi)); cursor = new QDirectFBCursor(this); -- cgit v0.12 From dc8d0961a50e28224dc36febb3530c47444f8638 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 27 Sep 2010 14:00:23 +0200 Subject: Compile when detecting ARMv5 The macro is called QT_END_INCLUDE_HEADER, not QT_END_INCLUDE_HEADERS (no trailing S). --- src/corelib/arch/qatomic_arm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/arch/qatomic_arm.h b/src/corelib/arch/qatomic_arm.h index f9d71e9..1c1c8a5 100644 --- a/src/corelib/arch/qatomic_arm.h +++ b/src/corelib/arch/qatomic_arm.h @@ -68,7 +68,7 @@ QT_END_INCLUDE_HEADER # define QT_ARCH_ARMV5 QT_BEGIN_INCLUDE_HEADER # include "QtCore/qatomic_armv5.h" -QT_END_INCLUDE_HEADERS +QT_END_INCLUDE_HEADER #endif QT_END_HEADER -- cgit v0.12 From 534d22fd647f79b9fde08329a6b9e355c6611132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 30 Sep 2010 13:29:28 +0200 Subject: Lighthouse: Make application fonts work Reviewed-by:paul --- src/gui/text/qfontdatabase_qpa.cpp | 3 ++- src/gui/text/qplatformfontdatabase_qpa.cpp | 7 ++++++- src/gui/text/qplatformfontdatabase_qpa.h | 2 +- .../fontdatabases/basicunix/qbasicunixfontdatabase.cpp | 10 +++++++--- .../platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h | 4 ++-- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp index 53594aa..19ce1be 100644 --- a/src/gui/text/qfontdatabase_qpa.cpp +++ b/src/gui/text/qfontdatabase_qpa.cpp @@ -199,7 +199,8 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) { QFontDatabasePrivate *db = privateDb(); - QApplicationPrivate::platformIntegration()->fontDatabase()->addApplicationFont(fnt->data,fnt->fileName); + fnt->families = QApplicationPrivate::platformIntegration()->fontDatabase()->addApplicationFont(fnt->data,fnt->fileName); + db->reregisterAppFonts = true; } diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp index 7bb1f9a..26f4faa 100644 --- a/src/gui/text/qplatformfontdatabase_qpa.cpp +++ b/src/gui/text/qplatformfontdatabase_qpa.cpp @@ -165,12 +165,17 @@ QStringList QPlatformFontDatabase::fallbacksForFamily(const QString family, cons return QStringList(); } -void QPlatformFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) +/*! + Adds an application font. Returns a list of family names, or an empty list if the font could + not be added +*/ +QStringList QPlatformFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) { Q_UNUSED(fontData); Q_UNUSED(fileName); qWarning("This plugin does not support application fonts"); + return QStringList(); } void QPlatformFontDatabase::releaseHandle(void *handle) diff --git a/src/gui/text/qplatformfontdatabase_qpa.h b/src/gui/text/qplatformfontdatabase_qpa.h index a34033f..adaa4cb 100644 --- a/src/gui/text/qplatformfontdatabase_qpa.h +++ b/src/gui/text/qplatformfontdatabase_qpa.h @@ -46,7 +46,7 @@ public: virtual void populateFontDatabase(); virtual QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); virtual QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const; - virtual void addApplicationFont(const QByteArray &fontData, const QString &fileName); + virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); virtual void releaseHandle(void *handle); virtual QString fontDir() const; diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp index 5b8ca63..5b6f69a 100644 --- a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp +++ b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp @@ -204,9 +204,9 @@ QStringList QBasicUnixFontDatabase::fallbacksForFamily(const QString family, con return QStringList(); } -void QBasicUnixFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) +QStringList QBasicUnixFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) { - addTTFile(fontData,fileName.toLocal8Bit()); + return addTTFile(fontData,fileName.toLocal8Bit()); } void QBasicUnixFontDatabase::releaseHandle(void *handle) @@ -215,13 +215,14 @@ void QBasicUnixFontDatabase::releaseHandle(void *handle) delete file; } -void QBasicUnixFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file) +QStringList QBasicUnixFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file) { extern FT_Library qt_getFreetype(); FT_Library library = qt_getFreetype(); int index = 0; int numFaces = 0; + QStringList families; do { FT_Face face; FT_Error error; @@ -275,7 +276,10 @@ void QBasicUnixFontDatabase::addTTFile(const QByteArray &fontData, const QByteAr registerFont(family,"",weight,style,100,true,true,0,writingSystems,fontFile); + families.append(family); + FT_Done_Face(face); ++index; } while (index < numFaces); + return families; } diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h index 401a4aa..95015df 100644 --- a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h +++ b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h @@ -17,10 +17,10 @@ public: void populateFontDatabase(); QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const; - void addApplicationFont(const QByteArray &fontData, const QString &fileName); + QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); void releaseHandle(void *handle); - static void addTTFile(const QByteArray &fontData, const QByteArray &file); + static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file); }; #endif // QBASICUNIXFONTDATABASE_H -- cgit v0.12 From d9f42e554c1da7aafad59881e1d143ff8672b833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 30 Sep 2010 14:19:46 +0200 Subject: Lighthouse: make QFontconfigDatabase not override application font --- .../fontdatabases/fontconfig/qfontconfigdatabase.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 562cb2d..85515ed 100644 --- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -392,10 +392,13 @@ void QFontconfigDatabase::populateFontDatabase() ++f; } - const FcDefaultFont *s = defaults; - QFont font("Sans Serif"); - font.setPointSize(9); - QApplication::setFont(font); + //Lighthouse has very lazy population of the font db. We want it to be initialized when + //QApplication is constructed, so that the population procedure can do something like this to + //set the default font +// const FcDefaultFont *s = defaults; +// QFont font("Sans Serif"); +// font.setPointSize(9); +// QApplication::setFont(font); } QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::Script script, void *usrPtr) -- cgit v0.12 From 33cdcafb24f21278d2ab34fa04cbf82ba57fa2aa Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 7 Oct 2010 08:28:46 +0200 Subject: use swapInterval=1 by default in EglFS to potentially avoid tearing --- src/plugins/platforms/eglfs/qeglfsscreen.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index 1b64e7e..b31b204 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -121,6 +121,8 @@ QEglFSScreen::QEglFSScreen(EGLNativeDisplayType display) platformFormat.setRedBufferSize(8); platformFormat.setGreenBufferSize(8); platformFormat.setBlueBufferSize(8); + platformFormat.setSwapInterval(1); + EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat); EGLNativeWindowType eglWindow = 0; -- cgit v0.12 From c235ecf5bae30fbd88845ec60e2ba2eaf2e8079e Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 7 Oct 2010 14:42:13 +0200 Subject: Make it possible to choose some EGLFS configuration options via envvars --- src/plugins/platforms/eglfs/qeglfsscreen.cpp | 36 +++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index b31b204..682f2f4 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE -//#define QEGL_EXTRA_DEBUG +// #define QEGL_EXTRA_DEBUG #ifdef QEGL_EXTRA_DEBUG struct AttrInfo { EGLint attr; const char *name; }; @@ -116,12 +116,36 @@ QEglFSScreen::QEglFSScreen(EGLNativeDisplayType display) qWarning("Initialized display %d %d\n", major, minor); QPlatformWindowFormat platformFormat; - platformFormat.setDepth(32); platformFormat.setWindowApi(QPlatformWindowFormat::OpenGL); - platformFormat.setRedBufferSize(8); - platformFormat.setGreenBufferSize(8); - platformFormat.setBlueBufferSize(8); - platformFormat.setSwapInterval(1); + + QByteArray depthString = qgetenv("QT_QPA_EGLFS_DEPTH"); + if (depthString.toInt() == 16) { + platformFormat.setDepth(16); + platformFormat.setRedBufferSize(5); + platformFormat.setGreenBufferSize(6); + platformFormat.setBlueBufferSize(5); + m_depth = 16; + m_format = QImage::Format_RGB16; + } else { + platformFormat.setDepth(32); + platformFormat.setRedBufferSize(8); + platformFormat.setGreenBufferSize(8); + platformFormat.setBlueBufferSize(8); + } + + if (!qgetenv("QT_QPA_EGLFS_MULTISAMPLE").isEmpty()) { + platformFormat.setSampleBuffers(true); + } + + int swapInterval = 1; + QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL"); + if (!swapIntervalString.isEmpty()) { + bool ok; + swapInterval = swapIntervalString.toInt(&ok); + if (!ok) + swapInterval = 1; + } + platformFormat.setSwapInterval(swapInterval); EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat); -- cgit v0.12 From e2ba67cd1d2887cec84058e260dd0f76cbab8771 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 11 Oct 2010 16:58:18 +0200 Subject: Add keycodes for some additional multimedia keys --- src/gui/embedded/qkbd_defaultmap_qws_p.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/embedded/qkbd_defaultmap_qws_p.h b/src/gui/embedded/qkbd_defaultmap_qws_p.h index 16c3459..703dfcd 100644 --- a/src/gui/embedded/qkbd_defaultmap_qws_p.h +++ b/src/gui/embedded/qkbd_defaultmap_qws_p.h @@ -642,7 +642,14 @@ const QWSKeyboard::Mapping QWSKbPrivate::s_keymap_default[] = { { 111, 0xffff, 0x01000007, 0x00, 0x00, 0x0000 }, { 111, 0xffff, 0x01000000, 0x06, 0x08, 0x0200 }, { 111, 0xffff, 0x01000000, 0x0c, 0x08, 0x0200 }, + { 113, 0xffff, 0x01000071, 0x00, 0x00, 0x0000 }, + { 114, 0xffff, 0x01000070, 0x00, 0x00, 0x0000 }, + { 115, 0xffff, 0x01000072, 0x00, 0x00, 0x0000 }, + { 116, 0xffff, 0x0100010b, 0x00, 0x00, 0x0000 }, { 119, 0xffff, 0x01000008, 0x00, 0x00, 0x0000 }, + { 138, 0xffff, 0x01000058, 0x00, 0x00, 0x0000 }, + { 139, 0xffff, 0x01000055, 0x00, 0x00, 0x0000 }, + }; const QWSKeyboard::Composing QWSKbPrivate::s_keycompose_default[] = { -- cgit v0.12 From 8b2ec1a88db8b2b932e2218080adf6202fd9f559 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 12 Oct 2010 17:43:54 +0200 Subject: Mouse event compression Compression turned on by default, can be turned off by adding "nocompress" to the specification. Also turn off experimental touch event support by default. --- src/plugins/generic/linuxinput/qlinuxinput.cpp | 41 +++++++++++++++++++------- src/plugins/generic/linuxinput/qlinuxinput.h | 1 + 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 2b01973..782194d 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -65,9 +65,9 @@ QT_BEGIN_NAMESPACE -#define QT_QPA_EXPERIMENTAL_MULTITOUCH +//#define QT_QPA_EXPERIMENTAL_TOUCHEVENT -#ifdef QT_QPA_EXPERIMENTAL_MULTITOUCH +#ifdef QT_QPA_EXPERIMENTAL_TOUCHEVENT class QLinuxInputMouseHandlerData { public: @@ -139,8 +139,15 @@ QLinuxInputMouseHandler::QLinuxInputMouseHandler(const QString &key, setObjectName(QLatin1String("LinuxInputSubsystem Mouse Handler")); QString dev = QLatin1String("/dev/input/event0"); - if (specification.startsWith(QLatin1String("/dev/"))) - dev = specification; + m_compression = true; + + QStringList args = specification.split(QLatin1Char(':')); + foreach (const QString &arg, args) { + if (arg == "nocompress") + m_compression = false; + else if (arg.startsWith(QLatin1String("/dev/"))) + dev = arg; + } m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0); if (m_fd >= 0) { @@ -150,7 +157,7 @@ QLinuxInputMouseHandler::QLinuxInputMouseHandler(const QString &key, qWarning("Cannot open mouse input device '%s': %s", qPrintable(dev), strerror(errno)); return; } -#ifdef QT_QPA_EXPERIMENTAL_MULTITOUCH +#ifdef QT_QPA_EXPERIMENTAL_TOUCHEVENT d = new QLinuxInputMouseHandlerData; #endif } @@ -160,7 +167,9 @@ QLinuxInputMouseHandler::~QLinuxInputMouseHandler() { if (m_fd >= 0) QT_CLOSE(m_fd); +#ifdef QT_QPA_EXPERIMENTAL_TOUCHEVENT delete d; +#endif } void QLinuxInputMouseHandler::readMouseData() @@ -168,7 +177,7 @@ void QLinuxInputMouseHandler::readMouseData() struct ::input_event buffer[32]; int n = 0; bool posChanged = false; - + bool pendingMouseEvent = false; forever { n = QT_READ(m_fd, reinterpret_cast(buffer) + n, sizeof(buffer) - n); @@ -204,7 +213,7 @@ void QLinuxInputMouseHandler::readMouseData() //ignore for now... } else if (data->code == ABS_HAT0Y) { //ignore for now... -#ifdef QT_QPA_EXPERIMENTAL_MULTITOUCH +#ifdef QT_QPA_EXPERIMENTAL_TOUCHEVENT } else if (data->code == ABS_MT_POSITION_X) { d->currentX = data->value; d->seenMT = true; @@ -248,6 +257,7 @@ void QLinuxInputMouseHandler::readMouseData() QWindowSystemInterface::handleMouseEvent(0, QPoint(m_x, m_y), QPoint(m_x, m_y), m_buttons); + pendingMouseEvent = false; } else if (data->type == EV_KEY && data->code >= BTN_LEFT && data->code <= BTN_MIDDLE) { Qt::MouseButton button = Qt::NoButton; switch (data->code) { @@ -262,16 +272,19 @@ void QLinuxInputMouseHandler::readMouseData() QWindowSystemInterface::handleMouseEvent(0, QPoint(m_x, m_y), QPoint(m_x, m_y), m_buttons); + pendingMouseEvent = false; } else if (data->type == EV_SYN && data->code == SYN_REPORT) { if (posChanged) { posChanged = false; QPoint pos(m_x, m_y); - - QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons); + if (m_compression) + pendingMouseEvent = true; + else + QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons); } -#ifdef QT_QPA_EXPERIMENTAL_MULTITOUCH +#ifdef QT_QPA_EXPERIMENTAL_TOUCHEVENT if (d->state == QEvent::TouchBegin && !d->seenMT) { - //no multi-touch events to send + //no multipoint-touch events to send } else { if (!d->seenMT) d->state = QEvent::TouchEnd; @@ -316,9 +329,15 @@ void QLinuxInputMouseHandler::readMouseData() } else { unknown = true; } +#ifdef QLINUXINPUT_EXTRA_DEBUG if (unknown) { qWarning("unknown mouse event type=%x, code=%x, value=%x", data->type, data->code, data->value); } +#endif + } + if (m_compression && pendingMouseEvent) { + QPoint pos(m_x, m_y); + QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons); } } diff --git a/src/plugins/generic/linuxinput/qlinuxinput.h b/src/plugins/generic/linuxinput/qlinuxinput.h index 535816d..4b7d7de 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.h +++ b/src/plugins/generic/linuxinput/qlinuxinput.h @@ -69,6 +69,7 @@ private: int m_fd; int m_x, m_y; Qt::MouseButtons m_buttons; + bool m_compression; QLinuxInputMouseHandlerData *d; }; -- cgit v0.12 From 0cb3705195b54f199280ab0b8554c793f67425e2 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 13 Oct 2010 11:09:58 +0200 Subject: Jitter removal --- src/plugins/generic/linuxinput/qlinuxinput.cpp | 40 +++++++++++++++++--------- src/plugins/generic/linuxinput/qlinuxinput.h | 5 ++++ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 782194d..07f7a43 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -131,7 +131,7 @@ private: QLinuxInputMouseHandler::QLinuxInputMouseHandler(const QString &key, const QString &specification) - : m_notify(0), m_x(0), m_y(0), m_buttons(0), d(0) + : m_notify(0), m_x(0), m_y(0), m_prevx(0), m_prevy(0), m_buttons(0), d(0) { qDebug() << "QLinuxInputMouseHandler" << key << specification; @@ -140,15 +140,20 @@ QLinuxInputMouseHandler::QLinuxInputMouseHandler(const QString &key, QString dev = QLatin1String("/dev/input/event0"); m_compression = true; + m_smooth = false; + int jitterLimit = 0; QStringList args = specification.split(QLatin1Char(':')); foreach (const QString &arg, args) { if (arg == "nocompress") m_compression = false; + else if (arg.startsWith("dejitter=")) + jitterLimit = arg.mid(9).toInt(); else if (arg.startsWith(QLatin1String("/dev/"))) dev = arg; } - + m_jitterLimitSquared = jitterLimit*jitterLimit; + m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0); if (m_fd >= 0) { m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); @@ -172,12 +177,21 @@ QLinuxInputMouseHandler::~QLinuxInputMouseHandler() #endif } +void QLinuxInputMouseHandler::sendMouseEvent(int x, int y, Qt::MouseButtons buttons) +{ + QPoint pos(x, y); + QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons); + m_prevx = x; + m_prevy = y; +} + void QLinuxInputMouseHandler::readMouseData() { struct ::input_event buffer[32]; int n = 0; bool posChanged = false; bool pendingMouseEvent = false; + int eventCompressCount = 0; forever { n = QT_READ(m_fd, reinterpret_cast(buffer) + n, sizeof(buffer) - n); @@ -255,8 +269,7 @@ void QLinuxInputMouseHandler::readMouseData() } else if (data->type == EV_KEY && data->code == BTN_TOUCH) { m_buttons = data->value ? Qt::LeftButton : Qt::NoButton; - QWindowSystemInterface::handleMouseEvent(0, QPoint(m_x, m_y), - QPoint(m_x, m_y), m_buttons); + sendMouseEvent(m_x, m_y, m_buttons); pendingMouseEvent = false; } else if (data->type == EV_KEY && data->code >= BTN_LEFT && data->code <= BTN_MIDDLE) { Qt::MouseButton button = Qt::NoButton; @@ -269,18 +282,17 @@ void QLinuxInputMouseHandler::readMouseData() m_buttons |= button; else m_buttons &= ~button; - - QWindowSystemInterface::handleMouseEvent(0, QPoint(m_x, m_y), - QPoint(m_x, m_y), m_buttons); + sendMouseEvent(m_x, m_y, m_buttons); pendingMouseEvent = false; } else if (data->type == EV_SYN && data->code == SYN_REPORT) { if (posChanged) { posChanged = false; - QPoint pos(m_x, m_y); - if (m_compression) + if (m_compression) { pendingMouseEvent = true; - else - QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons); + eventCompressCount++; + } else { + sendMouseEvent(m_x, m_y, m_buttons); + } } #ifdef QT_QPA_EXPERIMENTAL_TOUCHEVENT if (d->state == QEvent::TouchBegin && !d->seenMT) { @@ -336,8 +348,9 @@ void QLinuxInputMouseHandler::readMouseData() #endif } if (m_compression && pendingMouseEvent) { - QPoint pos(m_x, m_y); - QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons); + int distanceSquared = (m_x - m_prevx)*(m_x - m_prevx) + (m_y - m_prevy)*(m_y - m_prevy); + if (distanceSquared > m_jitterLimitSquared) + sendMouseEvent(m_x, m_y, m_buttons); } } @@ -531,3 +544,4 @@ void QLinuxInputKeyboardHandler::readKeycode() QT_END_NAMESPACE + diff --git a/src/plugins/generic/linuxinput/qlinuxinput.h b/src/plugins/generic/linuxinput/qlinuxinput.h index 4b7d7de..37123f1 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.h +++ b/src/plugins/generic/linuxinput/qlinuxinput.h @@ -65,11 +65,16 @@ private slots: void readMouseData(); private: + void sendMouseEvent(int x, int y, Qt::MouseButtons buttons); QSocketNotifier * m_notify; int m_fd; int m_x, m_y; + int m_prevx, m_prevy; + int m_smoothx, m_smoothy; Qt::MouseButtons m_buttons; bool m_compression; + bool m_smooth; + int m_jitterLimitSquared; QLinuxInputMouseHandlerData *d; }; -- cgit v0.12 From 5a8078cb2cf1c95e8d853b9b0bd8c8303f52aceb Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 13 Oct 2010 13:37:37 +0200 Subject: Add touch offset --- src/plugins/generic/linuxinput/qlinuxinput.cpp | 8 ++++++-- src/plugins/generic/linuxinput/qlinuxinput.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index 07f7a43..b3ef6bd 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -131,7 +131,7 @@ private: QLinuxInputMouseHandler::QLinuxInputMouseHandler(const QString &key, const QString &specification) - : m_notify(0), m_x(0), m_y(0), m_prevx(0), m_prevy(0), m_buttons(0), d(0) + : m_notify(0), m_x(0), m_y(0), m_prevx(0), m_prevy(0), m_xoffset(0), m_yoffset(0), m_buttons(0), d(0) { qDebug() << "QLinuxInputMouseHandler" << key << specification; @@ -149,6 +149,10 @@ QLinuxInputMouseHandler::QLinuxInputMouseHandler(const QString &key, m_compression = false; else if (arg.startsWith("dejitter=")) jitterLimit = arg.mid(9).toInt(); + else if (arg.startsWith("xoffset=")) + m_xoffset = arg.mid(8).toInt(); + else if (arg.startsWith("yoffset=")) + m_yoffset = arg.mid(8).toInt(); else if (arg.startsWith(QLatin1String("/dev/"))) dev = arg; } @@ -179,7 +183,7 @@ QLinuxInputMouseHandler::~QLinuxInputMouseHandler() void QLinuxInputMouseHandler::sendMouseEvent(int x, int y, Qt::MouseButtons buttons) { - QPoint pos(x, y); + QPoint pos(x+m_xoffset, y+m_yoffset); QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons); m_prevx = x; m_prevy = y; diff --git a/src/plugins/generic/linuxinput/qlinuxinput.h b/src/plugins/generic/linuxinput/qlinuxinput.h index 37123f1..c94c0f4 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.h +++ b/src/plugins/generic/linuxinput/qlinuxinput.h @@ -70,6 +70,7 @@ private: int m_fd; int m_x, m_y; int m_prevx, m_prevy; + int m_xoffset, m_yoffset; int m_smoothx, m_smoothy; Qt::MouseButtons m_buttons; bool m_compression; -- cgit v0.12 From c118708a9886643db887a89b02f31a1879604116 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 13 Oct 2010 15:34:38 +0200 Subject: Don't clobber the tty by default Add a ttymode option to LinuxInputKeyboard which turns on setting the keyboard mode and turns off Ctrl-C --- src/plugins/generic/linuxinput/qlinuxinput.cpp | 62 ++++++++++++++------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index b3ef6bd..bd57fa3 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -404,12 +404,16 @@ QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(const QString &key, const int repeat_delay = -1; int repeat_rate = -1; + bool ttymode = false; + QStringList args = specification.split(QLatin1Char(':')); foreach (const QString &arg, args) { if (arg.startsWith(QLatin1String("repeat-delay="))) repeat_delay = arg.mid(13).toInt(); else if (arg.startsWith(QLatin1String("repeat-rate="))) repeat_rate = arg.mid(12).toInt(); + else if (arg.startsWith(QLatin1String("ttymode"))) + ttymode = true; else if (arg.startsWith(QLatin1String("/dev/"))) dev = arg; } @@ -427,34 +431,36 @@ QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(const QString &key, const notifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode())); - // play nice in case we are started from a shell (e.g. for debugging) - m_tty_fd = isatty(0) ? 0 : -1; - - if (m_tty_fd >= 0) { - // save tty config for restore. - tcgetattr(m_tty_fd, &m_tty_attr); - - struct ::termios termdata; - tcgetattr(m_tty_fd, &termdata); - - // record the original mode so we can restore it again in the destructor. - ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode); - - // setting this tranlation mode is even needed in INPUT mode to prevent - // the shell from also interpreting codes, if the process has a tty - // attached: e.g. Ctrl+C wouldn't copy, but kill the application. - ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW); - - // set the tty layer to pass-through - termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); - termdata.c_oflag = 0; - termdata.c_cflag = CREAD | CS8; - termdata.c_lflag = 0; - termdata.c_cc[VTIME]=0; - termdata.c_cc[VMIN]=1; - cfsetispeed(&termdata, 9600); - cfsetospeed(&termdata, 9600); - tcsetattr(m_tty_fd, TCSANOW, &termdata); + if (ttymode) { + // play nice in case we are started from a shell (e.g. for debugging) + m_tty_fd = isatty(0) ? 0 : -1; + + if (m_tty_fd >= 0) { + // save tty config for restore. + tcgetattr(m_tty_fd, &m_tty_attr); + + struct ::termios termdata; + tcgetattr(m_tty_fd, &termdata); + + // record the original mode so we can restore it again in the destructor. + ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode); + + // setting this tranlation mode is even needed in INPUT mode to prevent + // the shell from also interpreting codes, if the process has a tty + // attached: e.g. Ctrl+C wouldn't copy, but kill the application. + ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW); + + // set the tty layer to pass-through + termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); + termdata.c_oflag = 0; + termdata.c_cflag = CREAD | CS8; + termdata.c_lflag = 0; + termdata.c_cc[VTIME]=0; + termdata.c_cc[VMIN]=1; + cfsetispeed(&termdata, 9600); + cfsetospeed(&termdata, 9600); + tcsetattr(m_tty_fd, TCSANOW, &termdata); + } } } else { qWarning("Cannot open keyboard input device '%s': %s", qPrintable(dev), strerror(errno)); -- cgit v0.12 From 78f3600423e6e48cd7d99c631f634c7949eb4227 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 14 Oct 2010 17:08:13 +0200 Subject: Update sections if model content changes. We didn't handle the section property changing, e.g. due to asynchronous model. Task-number: QT-4093 Reviewed-by: Aaron Kennedy Conflicts: src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h --- .../graphicsitems/qdeclarativelistview.cpp | 40 ++++++++++++++++++++-- .../graphicsitems/qdeclarativelistview_p.h | 2 ++ .../graphicsitems/qdeclarativevisualitemmodel.cpp | 21 ++++++++++++ .../graphicsitems/qdeclarativevisualitemmodel_p.h | 6 +++- .../tst_qdeclarativelistview.cpp | 11 ++++++ 5 files changed, 76 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index c1e6aaa..3261dd7 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -775,7 +775,6 @@ void QDeclarativeListViewPrivate::layout() setPosition(0); return; } - updateSections(); if (!visibleItems.isEmpty()) { qreal oldEnd = visibleItems.last()->endPosition(); qreal pos = visibleItems.first()->endPosition() + spacing + 1; @@ -934,6 +933,7 @@ void QDeclarativeListViewPrivate::createSection(FxListItem *listItem) return; if (listItem->attached->m_prevSection != listItem->attached->m_section) { if (!listItem->section) { + qreal pos = listItem->position(); int i = sectionCacheSize-1; while (i >= 0 && !sectionCache[i]) --i; @@ -961,8 +961,10 @@ void QDeclarativeListViewPrivate::createSection(FxListItem *listItem) delete context; } } + listItem->setPosition(pos); } } else if (listItem->section) { + qreal pos = listItem->position(); int i = 0; do { if (!sectionCache[i]) { @@ -975,12 +977,13 @@ void QDeclarativeListViewPrivate::createSection(FxListItem *listItem) } while (i < sectionCacheSize); delete listItem->section; listItem->section = 0; + listItem->setPosition(pos); } } void QDeclarativeListViewPrivate::updateSections() { - if (sectionCriteria) { + if (sectionCriteria && !visibleItems.isEmpty()) { QString prevSection; if (visibleIndex > 0) prevSection = sectionAt(visibleIndex-1); @@ -990,6 +993,8 @@ void QDeclarativeListViewPrivate::updateSections() if (visibleItems.at(i)->index != -1) { QDeclarativeListViewAttached *attached = visibleItems.at(i)->attached; attached->setPrevSection(prevSection); + QString propValue = model->stringValue(visibleItems.at(i)->index, sectionCriteria->property()); + attached->setSection(sectionCriteria->sectionString(propValue)); if (prevAtt) prevAtt->setNextSection(attached->section()); createSection(visibleItems.at(i)); @@ -1551,6 +1556,7 @@ void QDeclarativeListView::setModel(const QVariant &model) disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); + disconnect(d->model, SIGNAL(itemsChanged(int,int)), this, SLOT(itemsChanged(int,int))); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); @@ -1581,6 +1587,7 @@ void QDeclarativeListView::setModel(const QVariant &model) if (d->model) { d->bufferMode = QDeclarativeListViewPrivate::BufferBefore | QDeclarativeListViewPrivate::BufferAfter; if (isComponentComplete()) { + updateSections(); refill(); if (d->currentIndex >= d->model->count() || d->currentIndex < 0) { setCurrentIndex(0); @@ -1596,6 +1603,7 @@ void QDeclarativeListView::setModel(const QVariant &model) connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); + connect(d->model, SIGNAL(itemsChanged(int,int)), this, SLOT(itemsChanged(int,int))); connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); @@ -1653,6 +1661,7 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) d->visibleItems.clear(); d->releaseItem(d->currentItem); d->currentItem = 0; + updateSections(); refill(); d->moveReason = QDeclarativeListViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); @@ -2066,8 +2075,10 @@ void QDeclarativeListView::setCacheBuffer(int b) QDeclarativeViewSection *QDeclarativeListView::sectionCriteria() { Q_D(QDeclarativeListView); - if (!d->sectionCriteria) + if (!d->sectionCriteria) { d->sectionCriteria = new QDeclarativeViewSection(this); + connect(d->sectionCriteria, SIGNAL(propertyChanged()), this, SLOT(updateSections())); + } return d->sectionCriteria; } @@ -2660,6 +2671,7 @@ void QDeclarativeListView::componentComplete() { Q_D(QDeclarativeListView); QDeclarativeFlickable::componentComplete(); + updateSections(); if (d->isValid()) { refill(); d->moveReason = QDeclarativeListViewPrivate::SetIndex; @@ -2676,6 +2688,18 @@ void QDeclarativeListView::componentComplete() } } +void QDeclarativeListView::updateSections() +{ + Q_D(QDeclarativeListView); + if (isComponentComplete() && d->model) { + QList roles; + if (d->sectionCriteria && !d->sectionCriteria->property().isEmpty()) + roles << d->sectionCriteria->property().toUtf8(); + d->model->setWatchedRoles(roles); + d->updateSections(); + } +} + void QDeclarativeListView::refill() { Q_D(QDeclarativeListView); @@ -2885,6 +2909,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) for (int j = 0; j < added.count(); ++j) added.at(j)->attached->emitAdd(); + d->updateSections(); d->itemCount += count; emit countChanged(); } @@ -2977,6 +3002,7 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count) } } + d->updateSections(); emit countChanged(); } @@ -3098,6 +3124,14 @@ void QDeclarativeListView::itemsMoved(int from, int to, int count) // Ensure we don't cause an ugly list scroll. d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + moveBy); + d->updateSections(); + d->layout(); +} + +void QDeclarativeListView::itemsChanged(int, int) +{ + Q_D(QDeclarativeListView); + d->updateSections(); d->layout(); } diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h index 735b248..2678b90 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview_p.h +++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h @@ -250,11 +250,13 @@ protected: virtual void componentComplete(); private Q_SLOTS: + void updateSections(); void refill(); void trackedPositionChanged(); void itemsInserted(int index, int count); void itemsRemoved(int index, int count); void itemsMoved(int from, int to, int count); + void itemsChanged(int index, int count); void modelReset(); void destroyRemoved(); void createdItem(int index, QDeclarativeItem *item); diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 439f500..e569dd2 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -403,6 +403,8 @@ public: QDeclarativeListAccessor *m_listAccessor; QModelIndex m_root; + QList watchedRoles; + QList watchedRoleIds; }; class QDeclarativeVisualDataModelDataMetaObject : public QDeclarativeOpenMetaObject @@ -1170,10 +1172,25 @@ int QDeclarativeVisualDataModel::indexOf(QDeclarativeItem *item, QObject *) cons return -1; } +void QDeclarativeVisualDataModel::setWatchedRoles(QList roles) +{ + Q_D(QDeclarativeVisualDataModel); + d->watchedRoles = roles; + d->watchedRoleIds.clear(); +} + void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count, const QList &roles) { Q_D(QDeclarativeVisualDataModel); + bool changed = false; + if (!d->watchedRoles.isEmpty() && d->watchedRoleIds.isEmpty()) { + foreach (QByteArray r, d->watchedRoles) { + if (d->m_roleNames.contains(r)) + d->watchedRoleIds << d->m_roleNames.value(r); + } + } + for (QHash::ConstIterator iter = d->m_cache.begin(); iter != d->m_cache.end(); ++iter) { const int idx = iter.key(); @@ -1183,6 +1200,8 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count, QDeclarativeVisualDataModelData *data = d->data(objRef.obj); for (int roleIdx = 0; roleIdx < roles.count(); ++roleIdx) { int role = roles.at(roleIdx); + if (!changed && !d->watchedRoleIds.isEmpty() && d->watchedRoleIds.contains(role)) + changed = true; int propId = data->propForRole(role); if (propId != -1) { if (data->hasValue(propId)) { @@ -1217,6 +1236,8 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count, } } } + if (changed) + emit itemsChanged(index, count); } void QDeclarativeVisualDataModel::_q_itemsInserted(int index, int count) diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h index e159786..1d15dba 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h @@ -79,7 +79,8 @@ public: virtual ReleaseFlags release(QDeclarativeItem *item) = 0; virtual bool completePending() const = 0; virtual void completeItem() = 0; - virtual QString stringValue(int, const QString &) { return QString(); } + virtual QString stringValue(int, const QString &) = 0; + virtual void setWatchedRoles(QList roles) = 0; virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const = 0; @@ -88,6 +89,7 @@ Q_SIGNALS: void itemsInserted(int index, int count); void itemsRemoved(int index, int count); void itemsMoved(int from, int to, int count); + void itemsChanged(int index, int count); void modelReset(); void createdItem(int index, QDeclarativeItem *item); void destroyingItem(QDeclarativeItem *item); @@ -121,6 +123,7 @@ public: virtual bool completePending() const; virtual void completeItem(); virtual QString stringValue(int index, const QString &role); + virtual void setWatchedRoles(QList) {} virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const; @@ -175,6 +178,7 @@ public: bool completePending() const; void completeItem(); virtual QString stringValue(int index, const QString &role); + virtual void setWatchedRoles(QList roles); int indexOf(QDeclarativeItem *item, QObject *objectContext) const; diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 6452bae..3b2ab6d 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -979,6 +979,17 @@ void tst_QDeclarativeListView::sections() QTRY_VERIFY(item); QTRY_COMPARE(item->height(), 20.0); + // check that headers change when item changes + listview->setContentY(0); + model.modifyItem(0, "changed", "2"); + + canvas->show(); + qApp->exec(); + + item = findItem(contentItem, "wrapper", 1); + QTRY_VERIFY(item); + QTRY_COMPARE(item->height(), 40.0); + delete canvas; } -- cgit v0.12 From 74768276a7b69ad54b93188abcf2ca4bf50dff8a Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 13 Oct 2010 14:55:07 +1000 Subject: Remove debug code added by 650a0078e2cef43eff107fe8d2505f64a0bfedf0 Task-number: QT-4093 --- .../auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 3b2ab6d..ec8ee82 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -983,9 +983,6 @@ void tst_QDeclarativeListView::sections() listview->setContentY(0); model.modifyItem(0, "changed", "2"); - canvas->show(); - qApp->exec(); - item = findItem(contentItem, "wrapper", 1); QTRY_VERIFY(item); QTRY_COMPARE(item->height(), 40.0); -- cgit v0.12 From d22741b4bee0e526aefbbd7b851c2aa1b0b1c5b6 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 15 Oct 2010 07:19:08 +0200 Subject: actually set egl swap interval --- src/plugins/platforms/eglfs/qeglfsscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index 682f2f4..2d23cca 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -145,9 +145,9 @@ QEglFSScreen::QEglFSScreen(EGLNativeDisplayType display) if (!ok) swapInterval = 1; } - platformFormat.setSwapInterval(swapInterval); EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat); + eglSwapInterval(display, swapInterval); EGLNativeWindowType eglWindow = 0; #ifdef Q_OPENKODE -- cgit v0.12 From 4346b33024c76760752fc1dc4b46847883cd0453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 19 Oct 2010 08:49:06 +0200 Subject: Fix QWS generic mac mkspec --- mkspecs/qws/macx-generic-g++/qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/qws/macx-generic-g++/qmake.conf b/mkspecs/qws/macx-generic-g++/qmake.conf index 63bfc57..8dcbb39 100644 --- a/mkspecs/qws/macx-generic-g++/qmake.conf +++ b/mkspecs/qws/macx-generic-g++/qmake.conf @@ -27,7 +27,7 @@ QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses QMAKE_CFLAGS_THREAD = -D_REENTRANT QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden -QMAKE_CXX = $(TB)c++ +QMAKE_CXX = c++ QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -DQT_NO_QWS_TRANSFORMED QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -- cgit v0.12 From b895d7af3a75cbbc2b14a993679538ed02190b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 18 Oct 2010 09:51:15 +0200 Subject: Lighthouse on OS X. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jørgen --- config.tests/mac/coreservices/coreservices.mm | 48 ++++++++++++++++++++++++++ config.tests/mac/coreservices/coreservices.pro | 3 ++ configure | 6 ++++ src/corelib/corelib.pro | 9 ++++- src/corelib/global/qfeatures.h | 10 +++--- src/corelib/global/qfeatures.txt | 2 +- src/corelib/global/qglobal.cpp | 9 +++-- src/corelib/io/qfilesystemwatcher_fsevents.cpp | 3 ++ src/corelib/io/qfilesystemwatcher_fsevents_p.h | 4 +++ src/corelib/io/qfilesystemwatcher_kqueue.cpp | 4 +++ src/corelib/io/qfilesystemwatcher_kqueue_p.h | 2 ++ src/corelib/io/qfsfileengine.cpp | 2 +- src/corelib/io/qfsfileengine_unix.cpp | 8 ++--- src/corelib/kernel/qcore_mac_p.h | 8 +++++ src/corelib/thread/qthread_unix.cpp | 4 ++- src/gui/kernel/mac.pri | 2 +- src/script/script.pro | 10 +++++- src/testlib/testlib.pro | 10 +++++- 18 files changed, 125 insertions(+), 19 deletions(-) create mode 100644 config.tests/mac/coreservices/coreservices.mm create mode 100644 config.tests/mac/coreservices/coreservices.pro diff --git a/config.tests/mac/coreservices/coreservices.mm b/config.tests/mac/coreservices/coreservices.mm new file mode 100644 index 0000000..0091e49 --- /dev/null +++ b/config.tests/mac/coreservices/coreservices.mm @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** 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 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 + +int main() +{ + FSRef ref; + return 0; +} diff --git a/config.tests/mac/coreservices/coreservices.pro b/config.tests/mac/coreservices/coreservices.pro new file mode 100644 index 0000000..c9bf8ec --- /dev/null +++ b/config.tests/mac/coreservices/coreservices.pro @@ -0,0 +1,3 @@ +SOURCES = coreservices.mm +LIBS += -framework CoreServices +CONFIG -= app_bundle qt diff --git a/configure b/configure index b771562..a79efef 100755 --- a/configure +++ b/configure @@ -6139,6 +6139,12 @@ if [ "$PLATFORM_QPA" = "yes" ]; then fi fi + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/mac/coreservices "CoreServices" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then + QT_CONFIG="$QT_CONFIG coreservices" + else + QMakeVar add DEFINES QT_NO_CORESERVICES + fi + fi diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 88b9252..349b3d4 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -19,7 +19,14 @@ include(codecs/codecs.pri) include(statemachine/statemachine.pri) include(xml/xml.pri) -!nacl:mac|darwin:LIBS_PRIVATE += -framework ApplicationServices +!qpa:mac|darwin:LIBS_PRIVATE += -framework ApplicationServices +qpa:mac|darwin { + contains(QT_CONFIG, coreservices) { + LIBS_PRIVATE += -framework CoreServices + } else { + 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/qfeatures.h b/src/corelib/global/qfeatures.h index b606843..9710079 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -523,11 +523,6 @@ #define QT_NO_FTP #endif -// Hyper Text Transfer Protocol -#if !defined(QT_NO_HTTP) && (defined(QT_NO_HOSTINFO)) -#define QT_NO_HTTP -#endif - // QInputContext #if !defined(QT_NO_IM) && (defined(QT_NO_LIBRARY)) #define QT_NO_IM @@ -583,6 +578,11 @@ #define QT_NO_GRAPHICSVIEW #endif +// Hyper Text Transfer Protocol +#if !defined(QT_NO_HTTP) && (defined(QT_NO_HOSTINFO) || defined(QT_NO_NETWORKPROXY)) +#define QT_NO_HTTP +#endif + // QMdiArea #if !defined(QT_NO_MDIAREA) && (defined(QT_NO_SCROLLAREA)) #define QT_NO_MDIAREA diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index 4d938a9..f07fbd5 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -1050,7 +1050,7 @@ SeeAlso: ??? Feature: HTTP Description: Supports HTTP file access. Section: Networking -Requires: HOSTINFO +Requires: HOSTINFO NETWORKPROXY Name: Hyper Text Transfer Protocol SeeAlso: ??? diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index a160010..eeeccd3 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -74,7 +74,7 @@ # include #endif -#if defined(Q_CC_MWERKS) && defined(Q_OS_MACX) +#if defined(Q_OS_MACX) && !defined(QT_NO_CORESERVICES) #include #endif @@ -1643,7 +1643,7 @@ static const unsigned int qt_one = 1; const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian); #endif -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) QT_BEGIN_INCLUDE_NAMESPACE #include "private/qcore_mac_p.h" @@ -1697,15 +1697,18 @@ Q_CORE_EXPORT void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding e Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) { return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding())); } +#endif //!defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) - +#if !defined(QWS) && defined(Q_OS_MAC) static QSysInfo::MacVersion macVersion() { +#ifndef QT_NO_CORESERVICES SInt32 gestalt_version; if (Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) { return QSysInfo::MacVersion(((gestalt_version & 0x00F0) >> 4) + 2); } +#endif return QSysInfo::MV_Unknown; } const QSysInfo::MacVersion QSysInfo::MacintoshVersion = macVersion(); diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.cpp b/src/corelib/io/qfilesystemwatcher_fsevents.cpp index d3276bd..0f96792 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.cpp +++ b/src/corelib/io/qfilesystemwatcher_fsevents.cpp @@ -45,6 +45,8 @@ #include "qfilesystemwatcher.h" #include "qfilesystemwatcher_fsevents_p.h" +#ifndef QT_NO_FILESYSTEMWATCHER + #include #include #include @@ -487,3 +489,4 @@ void QFSEventsFileSystemWatcherEngine::run() } QT_END_NAMESPACE +#endif //QT_NO_FILESYSTEMWATCHER diff --git a/src/corelib/io/qfilesystemwatcher_fsevents_p.h b/src/corelib/io/qfilesystemwatcher_fsevents_p.h index b0462b6..c888c61 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents_p.h +++ b/src/corelib/io/qfilesystemwatcher_fsevents_p.h @@ -56,6 +56,8 @@ #include "qfilesystemwatcher_p.h" +#ifndef QT_NO_FILESYSTEMWATCHER + #include #include #include @@ -123,6 +125,8 @@ private: #endif }; +#endif //QT_NO_FILESYSTEMWATCHER + #endif QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemwatcher_kqueue.cpp b/src/corelib/io/qfilesystemwatcher_kqueue.cpp index 378ad20..7960792 100644 --- a/src/corelib/io/qfilesystemwatcher_kqueue.cpp +++ b/src/corelib/io/qfilesystemwatcher_kqueue.cpp @@ -45,6 +45,8 @@ #include "qfilesystemwatcher_kqueue_p.h" #include "private/qcore_unix_p.h" +#ifndef QT_NO_FILESYSTEMWATCHER + #include #include #include @@ -343,4 +345,6 @@ process_next_event: } } +#endif //QT_NO_FILESYSTEMWATCHER + QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemwatcher_kqueue_p.h b/src/corelib/io/qfilesystemwatcher_kqueue_p.h index eda646b..edc20ae 100644 --- a/src/corelib/io/qfilesystemwatcher_kqueue_p.h +++ b/src/corelib/io/qfilesystemwatcher_kqueue_p.h @@ -60,6 +60,7 @@ #include #include +#ifndef QT_NO_FILESYSTEMWATCHER struct kevent; QT_BEGIN_NAMESPACE @@ -92,4 +93,5 @@ private: QT_END_NAMESPACE +#endif //QT_NO_FILESYSTEMWATCHER #endif // FILEWATCHER_KQUEUE_P_H diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index a1ffb81..90c6ea8 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -152,7 +152,7 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) // ... but Linux with uClibc does not have it #if !defined(__UCLIBC__) char *ret = 0; -#if defined(Q_OS_MAC) +#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES) // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here. if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) { ret = realpath(path.toLocal8Bit().constData(), (char*)0); diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index d83f7ee..67bcf45 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -739,7 +739,7 @@ static bool _q_isSymbianHidden(const QString &path, bool isDir) } #endif -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) static bool _q_isMacHidden(const QString &path) { OSErr err = noErr; @@ -824,7 +824,7 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const if (exists && (type & PermsMask)) ret |= d->getPermissions(type); if (type & TypesMask) { -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) bool foundAlias = false; { FSRef fref; @@ -878,7 +878,7 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const } else { QString baseName = fileName(BaseName); if ((baseName.size() > 0 && baseName.at(0) == QLatin1Char('.')) -# if !defined(QWS) && defined(Q_OS_MAC) +# if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) || _q_isMacHidden(d->filePath) # endif ) { @@ -1133,7 +1133,7 @@ QString QFSFileEngine::fileName(FileName file) const return ret; } } -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) { FSRef fref; if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->filePath)).data(), &fref, 0) == noErr) { diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index 9591f08..22b6a36 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -68,7 +68,15 @@ # undef qDebug #endif +#if defined(QT_BUILD_QMAKE) || defined(QT_BOOTSTRAPPED) #include +#else +#include +#endif + +#ifndef QT_NO_CORESERVICES +#include +#endif #undef DEBUG #ifdef OLD_DEBUG diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 20c6fb7..5eba09c 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -83,7 +83,9 @@ # define old_qDebug qDebug # undef qDebug # endif +#ifndef QT_NO_CORESERVICES # include +#endif //QT_NO_CORESERVICES # ifdef old_qDebug # undef qDebug @@ -358,7 +360,7 @@ int QThread::idealThreadCount() { int cores = -1; -#if defined(Q_OS_MAC) +#if defined(Q_OS_MAC) && !defined(Q_WS_QPA) // Mac OS X cores = MPProcessorsScheduled(); #elif defined(Q_OS_HPUX) diff --git a/src/gui/kernel/mac.pri b/src/gui/kernel/mac.pri index eb47ce9..21acd06 100644 --- a/src/gui/kernel/mac.pri +++ b/src/gui/kernel/mac.pri @@ -1,4 +1,4 @@ -!x11:!embedded:!nacl:mac { +!x11:!embedded:!qpa:mac { LIBS_PRIVATE += -framework Carbon -lz *-mwerks:INCLUDEPATH += compat } diff --git a/src/script/script.pro b/src/script/script.pro index 4ee86d7..56d3f7a 100644 --- a/src/script/script.pro +++ b/src/script/script.pro @@ -39,10 +39,18 @@ wince* { LIBS += -lmmtimer } -mac { +!qpa:mac { DEFINES += ENABLE_JSC_MULTIPLE_THREADS=0 LIBS_PRIVATE += -framework AppKit } +qpa:mac { + DEFINES += ENABLE_JSC_MULTIPLE_THREADS=0 + contains(QT_CONFIG, coreservices) { + LIBS_PRIVATE += -framework CoreServices + } else { + LIBS_PRIVATE += -framework CoreFoundation + } +} include($$WEBKITDIR/JavaScriptCore/JavaScriptCore.pri) diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index a8186d8..c25d23d 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -70,8 +70,16 @@ wince*::LIBS += libcmt.lib \ coredll.lib \ winsock.lib mac:LIBS += -framework IOKit \ - -framework ApplicationServices \ -framework Security +!qpa:mac: LIBS += -framework ApplicationServices +qpa:mac: { + contains(QT_CONFIG, coreservices) { + LIBS_PRIVATE += -framework CoreServices + } else { + LIBS_PRIVATE += -framework CoreFoundation + } +} + include(../qbase.pri) QMAKE_TARGET_PRODUCT = QTestLib QMAKE_TARGET_DESCRIPTION = Qt \ -- cgit v0.12 From 4e6790c8dc21c5287bff6799fb0984a72e2f2766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 18 Oct 2010 14:40:16 +0200 Subject: Lighthouse: initial COCOA plugin --- demos/demos.pro | 2 +- src/plugins/platforms/cocoa/cocoa.pro | 29 +++ src/plugins/platforms/cocoa/main.mm | 74 ++++++++ .../platforms/cocoa/qcocoaautoreleasepool.h | 57 ++++++ .../platforms/cocoa/qcocoaautoreleasepool.mm | 52 +++++ .../platforms/cocoa/qcocoaeventloopintegration.h | 74 ++++++++ .../platforms/cocoa/qcocoaeventloopintegration.mm | 128 +++++++++++++ src/plugins/platforms/cocoa/qcocoaintegration.h | 98 ++++++++++ src/plugins/platforms/cocoa/qcocoaintegration.mm | 122 ++++++++++++ src/plugins/platforms/cocoa/qcocoawindow.h | 75 ++++++++ src/plugins/platforms/cocoa/qcocoawindow.mm | 116 +++++++++++ src/plugins/platforms/cocoa/qcocoawindowsurface.h | 73 +++++++ src/plugins/platforms/cocoa/qcocoawindowsurface.mm | 103 ++++++++++ src/plugins/platforms/cocoa/qnsview.h | 79 ++++++++ src/plugins/platforms/cocoa/qnsview.mm | 211 +++++++++++++++++++++ src/plugins/platforms/cocoa/qnswindowdelegate.h | 61 ++++++ src/plugins/platforms/cocoa/qnswindowdelegate.mm | 73 +++++++ 17 files changed, 1426 insertions(+), 1 deletion(-) create mode 100644 src/plugins/platforms/cocoa/cocoa.pro create mode 100644 src/plugins/platforms/cocoa/main.mm create mode 100644 src/plugins/platforms/cocoa/qcocoaautoreleasepool.h create mode 100644 src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm create mode 100644 src/plugins/platforms/cocoa/qcocoaeventloopintegration.h create mode 100644 src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm create mode 100644 src/plugins/platforms/cocoa/qcocoaintegration.h create mode 100644 src/plugins/platforms/cocoa/qcocoaintegration.mm create mode 100644 src/plugins/platforms/cocoa/qcocoawindow.h create mode 100644 src/plugins/platforms/cocoa/qcocoawindow.mm create mode 100644 src/plugins/platforms/cocoa/qcocoawindowsurface.h create mode 100644 src/plugins/platforms/cocoa/qcocoawindowsurface.mm create mode 100644 src/plugins/platforms/cocoa/qnsview.h create mode 100644 src/plugins/platforms/cocoa/qnsview.mm create mode 100644 src/plugins/platforms/cocoa/qnswindowdelegate.h create mode 100644 src/plugins/platforms/cocoa/qnswindowdelegate.mm diff --git a/demos/demos.pro b/demos/demos.pro index fdc1e4c..362a3bc 100644 --- a/demos/demos.pro +++ b/demos/demos.pro @@ -44,7 +44,7 @@ contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles1):!contains(QT_CONFIG, SUBDIRS += demos_boxes } -mac*: SUBDIRS += demos_macmainwindow +mac* && !qpa: SUBDIRS += demos_macmainwindow wince*|symbian|embedded|x11: SUBDIRS += demos_embedded !contains(QT_EDITION, Console):!cross_compile:!embedded:!wince*:SUBDIRS += demos_arthurplugin diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro new file mode 100644 index 0000000..7701b9c --- /dev/null +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -0,0 +1,29 @@ +TARGET = qcocoa +include(../../qpluginbase.pri) +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms + +OBJECTIVE_SOURCES = main.mm \ + qcocoaintegration.mm \ + qcocoawindowsurface.mm \ + qcocoawindow.mm \ + qnsview.mm \ + qcocoaeventloopintegration.mm \ + qcocoaautoreleasepool.mm \ + qnswindowdelegate.mm + +OBJECTIVE_HEADERS = qcocoaintegration.h \ + qcocoawindowsurface.h \ + qcocoawindow.h \ + qnsview.h \ + qcocoaeventloopintegration.h \ + qcocoaautoreleasepool.h \ + qnswindowdelegate.h + +#add libz for freetype. +LIBS += -lz +LIBS += -framework cocoa + +include(../fontdatabases/genericunix/genericunix.pri) +target.path += $$[QT_INSTALL_PLUGINS]/platforms +INSTALLS += target + diff --git a/src/plugins/platforms/cocoa/main.mm b/src/plugins/platforms/cocoa/main.mm new file mode 100644 index 0000000..8be8883 --- /dev/null +++ b/src/plugins/platforms/cocoa/main.mm @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include "qcocoaintegration.h" + +QT_BEGIN_NAMESPACE + +class QCocoaIntegrationPlugin : public QPlatformIntegrationPlugin +{ +public: + QStringList keys() const; + QPlatformIntegration *create(const QString&, const QStringList&); +}; + +QStringList QCocoaIntegrationPlugin::keys() const +{ + QStringList list; + list << "Cocoa"; + return list; +} + +QPlatformIntegration * QCocoaIntegrationPlugin::create(const QString& system, const QStringList& paramList) +{ + Q_UNUSED(paramList); + if (system.toLower() == "cocoa") + return new QCocoaIntegration; + + return 0; +} + +Q_EXPORT_PLUGIN2(Cocoa, QCocoaIntegrationPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h new file mode 100644 index 0000000..47b94d1 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOCOAAUTORELEASEPOOL_H +#define QCOCOAAUTORELEASEPOOL_H + +#include + +class QCocoaAutoReleasePool +{ +public: + QCocoaAutoReleasePool(); + ~QCocoaAutoReleasePool(); + +private: + NSAutoreleasePool *pool; +}; + +#endif // QCOCOAAUTORELEASEPOOL_H diff --git a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm new file mode 100644 index 0000000..9a18fe2 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoaautoreleasepool.h" + +QCocoaAutoReleasePool::QCocoaAutoReleasePool() +{ + pool = [[NSAutoreleasePool alloc] init]; +} + +QCocoaAutoReleasePool::~QCocoaAutoReleasePool() +{ + [pool release]; +} diff --git a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h new file mode 100644 index 0000000..8c21944 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOCAEVENTLOOPINTEGRATION_H +#define QCOCAEVENTLOOPINTEGRATION_H + +#include + +#include + +@interface OurApplication: NSApplication +{ + bool shouldKeepRunning; +} + +- (void) run; +- (void) processEvents: (int) msec; + +@end + +class QCocoaEventLoopIntegration : public QPlatformEventLoopIntegration +{ +public: + QCocoaEventLoopIntegration(); + void processEvents( qint64 msec ); + void wakeup(); + + static int wakeupEventId; +private: + OurApplication *app; +}; + + + +#endif // QCOCAEVENTLOOPINTEGRATION_H + diff --git a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm new file mode 100644 index 0000000..b184f90 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoaeventloopintegration.h" + +#import + +#include "qcocoaautoreleasepool.h" + +#include + +#include + +@implementation OurApplication + +- (void) run +{ + QCocoaAutoReleasePool pool; + [self finishLaunching]; + + shouldKeepRunning = YES; +} + +- (void) processEvents : (int) msec +{ + QCocoaAutoReleasePool pool; + Q_UNUSED(pool); + + QElapsedTimer timer; + timer.start(); + + NSTimeInterval seconds = NSTimeInterval(msec)/1000; + id untilDate = [NSDate dateWithTimeIntervalSinceNow:seconds]; + bool continueLooping = true; + while ((timer.elapsed() < (msec-1)) && continueLooping) { + NSEvent *event = + [self nextEventMatchingMask:NSAnyEventMask + untilDate:untilDate + inMode:NSDefaultRunLoopMode + dequeue:YES]; + if ([event type] == NSApplicationDefined + && [event subtype] == QCocoaEventLoopIntegration::wakeupEventId) { + continueLooping = false; + } else { + [self sendEvent:event]; + } + + } + [self updateWindows]; +} + +@end + +int QCocoaEventLoopIntegration::wakeupEventId = SHRT_MAX; + +QCocoaEventLoopIntegration::QCocoaEventLoopIntegration() : + QPlatformEventLoopIntegration() +{ + app = (OurApplication *)[OurApplication sharedApplication]; + [app run]; +} + +void QCocoaEventLoopIntegration::processEvents(qint64 msec) +{ + [app processEvents:msec]; +} + +void QCocoaEventLoopIntegration::wakeup() +{ + QCocoaAutoReleasePool pool; + Q_UNUSED(pool); + + NSPoint p = NSMakePoint(0,0); + NSWindow *nswin = [app keyWindow]; + double timestamp = (double)(AbsoluteToDuration(UpTime())) / 1000.0; + NSEvent *event = [NSEvent + otherEventWithType:NSApplicationDefined + location:NSZeroPoint + modifierFlags:0 + timestamp: timestamp + windowNumber:[nswin windowNumber] + context:0 + subtype:QCocoaEventLoopIntegration::wakeupEventId + data1:0 + data2:0 + ]; + [app postEvent:event atStart:NO]; + +} + diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h new file mode 100644 index 0000000..e7ecf2a --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMINTEGRATION_COCOA_H +#define QPLATFORMINTEGRATION_COCOA_H + +#include + +#include "qcocoaautoreleasepool.h" + +#include + +QT_BEGIN_NAMESPACE + +class QCocoaScreen : public QPlatformScreen +{ +public: + QCocoaScreen(int screenIndex); + ~QCocoaScreen(); + + 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; } + +public: + NSScreen *m_screen; + QRect m_geometry; + int m_depth; + QImage::Format m_format; + QSize m_physicalSize; +}; + +class QCocoaIntegration : public QPlatformIntegration +{ +public: + QCocoaIntegration(); + ~QCocoaIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; + QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + + QList screens() const { return mScreens; } + + QPlatformFontDatabase *fontDatabase() const; + + QPlatformEventLoopIntegration *createEventLoopIntegration() const; + +private: + QList mScreens; + QPlatformFontDatabase *mFontDb; + + QCocoaAutoReleasePool *mPool; +}; + +QT_END_NAMESPACE + +#endif + diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm new file mode 100644 index 0000000..baf5a73 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoaintegration.h" + +#include "qcocoawindow.h" +#include "qcocoawindowsurface.h" +#include "qcocoaeventloopintegration.h" + +#include "qgenericunixfontdatabase.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +QCocoaScreen::QCocoaScreen(int screenIndex) + :QPlatformScreen() +{ + m_screen = [[NSScreen screens] objectAtIndex:screenIndex]; + NSRect rect = [m_screen frame]; + m_geometry = QRect(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height); + + m_format = QImage::Format_ARGB32; + + m_depth = NSBitsPerPixelFromDepth([m_screen depth]); + + const int dpi = 72; + const qreal inch = 25.4; + m_physicalSize = QSize(qRound(m_geometry.width() * inch / dpi), qRound(m_geometry.height() *inch / dpi)); +} + +QCocoaScreen::~QCocoaScreen() +{ +} + +QCocoaIntegration::QCocoaIntegration() + : mFontDb(new QGenericUnixFontDatabase()) +{ + mPool = new QCocoaAutoReleasePool; + + //Make sure we have a nsapplication :) + [OurApplication sharedApplication]; +// [[OurApplication alloc] init]; + + NSArray *screens = [NSScreen screens]; + for (uint i = 0; i < [screens count]; i++) { + QCocoaScreen *screen = new QCocoaScreen(i); + mScreens.append(screen); + } +} + +QCocoaIntegration::~QCocoaIntegration() +{ + delete mPool; +} + +QPixmapData *QCocoaIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QPlatformWindow *QCocoaIntegration::createPlatformWindow(QWidget *widget, WId winId) const +{ + Q_UNUSED(winId); + return new QCocoaWindow(widget); +} + +QWindowSurface *QCocoaIntegration::createWindowSurface(QWidget *widget, WId winId) const +{ + return new QCocoaWindowSurface(widget,winId); +} + +QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const +{ + return mFontDb; +} + +QPlatformEventLoopIntegration *QCocoaIntegration::createEventLoopIntegration() const +{ + return new QCocoaEventLoopIntegration(); +} +QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h new file mode 100644 index 0000000..660e9f8 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 QCOCOAWINDOW_H +#define QCOCOAWINDOW_H + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QCocoaWindow : public QPlatformWindow +{ +public: + QCocoaWindow(QWidget *tlw); + ~QCocoaWindow(); + + void setGeometry(const QRect &rect); + + void setVisible(bool visible); + + WId winId() const; + + NSView *contentView() const; + void setContentView(NSView *contentView); + + void windowDidResize(); + +private: + NSWindow *m_nsWindow; +}; + +QT_END_NAMESPACE + +#endif // QCOCOAWINDOW_H + diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm new file mode 100644 index 0000000..f004cb8 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qcocoawindow.h" +#include "qnswindowdelegate.h" +#include "qcocoaautoreleasepool.h" + +#include + +#include + +#include + +#include + +QCocoaWindow::QCocoaWindow(QWidget *tlw) + : QPlatformWindow(tlw) +{ + QCocoaAutoReleasePool pool; + const QRect geo = tlw->geometry(); + NSRect frame = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height()); + + m_nsWindow = [[NSWindow alloc] initWithContentRect:frame + styleMask:NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask + backing:NSBackingStoreBuffered + defer:YES]; + + QNSWindowDelegate *delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:this]; + [m_nsWindow setDelegate:delegate]; + + [m_nsWindow makeKeyAndOrderFront:nil]; + [m_nsWindow setAcceptsMouseMovedEvents:YES]; +} + +QCocoaWindow::~QCocoaWindow() +{ +} + +void QCocoaWindow::setGeometry(const QRect &rect) +{ + QPlatformWindow::setGeometry(rect); + + NSRect bounds = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); + [[m_nsWindow contentView]setFrameSize:bounds.size]; +} + +void QCocoaWindow::setVisible(bool visible) +{ + Q_UNUSED(visible); +} + +WId QCocoaWindow::winId() const +{ + return WId([m_nsWindow windowNumber]); +} + +NSView *QCocoaWindow::contentView() const +{ + return [m_nsWindow contentView]; +} + +void QCocoaWindow::setContentView(NSView *contentView) +{ + [m_nsWindow setContentView:contentView]; +} + +void QCocoaWindow::windowDidResize() +{ + //jlind: XXX This isn't ideal. Eventdispatcher does not run when resizing... + NSRect rect = [[m_nsWindow contentView]frame]; + QRect geo(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height); + if (geometry() != geo) { + widget()->setGeometry(geo); + QResizeEvent e(geo.size(), geometry().size()); + setGeometry(geo); + QApplication::sendEvent(widget(), &e); + widget()->repaint(); + } +} diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.h b/src/plugins/platforms/cocoa/qcocoawindowsurface.h new file mode 100644 index 0000000..35f4064 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoawindowsurface.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_COCOA_H +#define QWINDOWSURFACE_COCOA_H + +#include + +#include "qcocoawindow.h" +#include "qnsview.h" + +#include + +QT_BEGIN_NAMESPACE + +class QCocoaWindowSurface : public QWindowSurface +{ +public: + QCocoaWindowSurface(QWidget *window, WId wid); + ~QCocoaWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void resize (const QSize &size); + +private: + + QCocoaWindow *m_cocoaWindow; + QImage *m_image; + QNSView *m_contentView; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.mm b/src/plugins/platforms/cocoa/qcocoawindowsurface.mm new file mode 100644 index 0000000..443a486 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoawindowsurface.mm @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoawindowsurface.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +QRect flipedRect(const QRect &sourceRect,int height) +{ + if (!sourceRect.isValid()) + return QRect(); + QRect flippedRect = sourceRect; + flippedRect.moveTop(height - sourceRect.y()); + return flippedRect; +} + +QCocoaWindowSurface::QCocoaWindowSurface(QWidget *window, WId wId) + : QWindowSurface(window) +{ + m_cocoaWindow = static_cast(window->platformWindow()); + + const QRect geo = window->geometry(); + NSRect rect = NSMakeRect(geo.x(),geo.y(),geo.width(),geo.height()); + m_contentView = [[QNSView alloc] initWithWidget:window]; + m_cocoaWindow->setContentView(m_contentView); + + m_image = new QImage(window->size(),QImage::Format_ARGB32); +} + +QCocoaWindowSurface::~QCocoaWindowSurface() +{ + delete m_image; +} + +QPaintDevice *QCocoaWindowSurface::paintDevice() +{ + return m_image; +} + +void QCocoaWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(offset); + + QRect geo = region.boundingRect(); + + NSRect rect = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height()); + [m_contentView displayRect:rect]; +} + +void QCocoaWindowSurface::resize(const QSize &size) +{ + QWindowSurface::resize(size); + delete m_image; + m_image = new QImage(size,QImage::Format_ARGB32_Premultiplied); + NSSize newSize = NSMakeSize(size.width(),size.height()); + [m_contentView setImage:m_image]; + +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h new file mode 100644 index 0000000..0523725 --- /dev/null +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QNSVIEW_H +#define QNSVIEW_H + +#include + +#include + +@interface QNSView : NSView { + CGImageRef m_cgImage; + QWidget *m_widget; + Qt::MouseButtons m_buttons; +} + +- (id)init; +- (id)initWithWidget:(QWidget *)widget; + +- (void)setImage:(QImage *)image; +- (void)drawRect:(NSRect)dirtyRect; + +- (BOOL)isFlipped; + +- (void)handleMouseEvent:(NSEvent *)theEvent; +- (void)mouseDown:(NSEvent *)theEvent; +- (void)mouseDragged:(NSEvent *)theEvent; +- (void)mouseUp:(NSEvent *)theEvent; +- (void)mouseMoved:(NSEvent *)theEvent; +- (void)mouseEntered:(NSEvent *)theEvent; +- (void)mouseExited:(NSEvent *)theEvent; +- (void)rightMouseDown:(NSEvent *)theEvent; +- (void)rightMouseDragged:(NSEvent *)theEvent; +- (void)rightMouseUp:(NSEvent *)theEvent; +- (void)otherMouseDown:(NSEvent *)theEvent; +- (void)otherMouseDragged:(NSEvent *)theEvent; +- (void)otherMouseUp:(NSEvent *)theEvent; + +@end + +#endif //QNSVIEW_H diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm new file mode 100644 index 0000000..60de6ba --- /dev/null +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnsview.h" + +#include + +#include + +@implementation QNSView + +- (id) init +{ + self = [super init]; + if (self) { + m_cgImage = 0; + m_widget = 0; + m_buttons = Qt::NoButton; + } + return self; +} + +- (id)initWithWidget:(QWidget *)widget { + self = [self init]; + if (self) { + m_widget = widget; + } + return self; +} + +- (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, + kCGImageAlphaNone, + cgDataProviderRef, + NULL, + false, + kCGRenderingIntentDefault); + + CGColorSpaceRelease(cgColourSpaceRef); + +} + +- (void) drawRect:(NSRect)dirtyRect +{ + if (!m_cgImage) + return; + + CGRect dirtyCGRect = NSRectToCGRect(dirtyRect); + + NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext currentContext]; + CGContextRef cgContext = (CGContextRef) [nsGraphicsContext graphicsPort]; + + CGContextSaveGState( cgContext ); + int dy = dirtyCGRect.origin.y + CGRectGetMaxY(dirtyCGRect); + CGContextTranslateCTM(cgContext, 0, dy); + CGContextScaleCTM(cgContext, 1, -1); + + CGImageRef subImage = CGImageCreateWithImageInRect(m_cgImage, dirtyCGRect); + CGContextDrawImage(cgContext,dirtyCGRect,subImage); + + CGContextRestoreGState(cgContext); + + CGImageRelease(subImage); + +} + +- (BOOL) isFlipped +{ + return YES; +} + +- (void)handleMouseEvent:(NSEvent *)theEvent; +{ + NSPoint point = [self convertPoint: [theEvent locationInWindow] fromView: nil]; + QPoint qt_localPoint(point.x,point.y); + + NSTimeInterval timestamp = [theEvent timestamp]; + ulong qt_timestamp = timestamp * 1000; + + QWindowSystemInterface::handleMouseEvent(m_widget,qt_timestamp,qt_localPoint,QPoint(),m_buttons); + +} + - (void)mouseDown:(NSEvent *)theEvent + { + m_buttons |= Qt::LeftButton; + [self handleMouseEvent:theEvent]; + } + - (void)mouseDragged:(NSEvent *)theEvent + { + if (!(m_buttons & Qt::LeftButton)) + qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton"); + [self handleMouseEvent:theEvent]; + } + - (void)mouseUp:(NSEvent *)theEvent + { + m_buttons &= QFlag(~int(Qt::LeftButton)); + [self handleMouseEvent:theEvent]; + } + +- (void)mouseMoved:(NSEvent *)theEvent +{ + qDebug() << "mouseMove"; + [self handleMouseEvent:theEvent]; +} +- (void)mouseEntered:(NSEvent *)theEvent +{ + Q_UNUSED(theEvent); + QWindowSystemInterface::handleEnterEvent(m_widget); +} +- (void)mouseExited:(NSEvent *)theEvent +{ + Q_UNUSED(theEvent); + QWindowSystemInterface::handleLeaveEvent(m_widget); +} +- (void)rightMouseDown:(NSEvent *)theEvent +{ + m_buttons |= Qt::RightButton; + [self handleMouseEvent:theEvent]; +} +- (void)rightMouseDragged:(NSEvent *)theEvent +{ + if (!(m_buttons & Qt::LeftButton)) + qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton"); + [self handleMouseEvent:theEvent]; +} +- (void)rightMouseUp:(NSEvent *)theEvent +{ + m_buttons &= QFlag(~int(Qt::RightButton)); + [self handleMouseEvent:theEvent]; +} +- (void)otherMouseDown:(NSEvent *)theEvent +{ + m_buttons |= Qt::RightButton; + [self handleMouseEvent:theEvent]; +} +- (void)otherMouseDragged:(NSEvent *)theEvent +{ + if (!(m_buttons & Qt::LeftButton)) + qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton"); + [self handleMouseEvent:theEvent]; +} +- (void)otherMouseUp:(NSEvent *)theEvent +{ + m_buttons &= QFlag(~int(Qt::MiddleButton)); + [self handleMouseEvent:theEvent]; +} + + + +@end diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h new file mode 100644 index 0000000..9fc1d63 --- /dev/null +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QNSWINDOWDELEGATE_H +#define QNSWINDOWDELEGATE_H + +#include + +#include "qcocoawindow.h" + +@interface QNSWindowDelegate : NSObject +{ + QCocoaWindow *m_cocoaWindow; +} + +- (id)initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow; + +- (void)windowDidResize:(NSNotification *)notification; +- (void)windowWillClose:(NSNotification *)notification; + +@end + +#endif // QNSWINDOWDELEGATE_H diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm new file mode 100644 index 0000000..c04602b --- /dev/null +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnswindowdelegate.h" + +#include +#include + +@implementation QNSWindowDelegate + +- (id) initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow +{ + self = [super init]; + + if (self) { + m_cocoaWindow = cocoaWindow; + } + return self; +} + +- (void)windowDidResize:(NSNotification *)notification +{ + Q_UNUSED(notification); + if (m_cocoaWindow) { + m_cocoaWindow->windowDidResize(); + } +} + +- (void)windowWillClose:(NSNotification *)notification +{ + Q_UNUSED(notification); + QWindowSystemInterface::handleCloseEvent(m_cocoaWindow->widget()); +} + +@end -- cgit v0.12 From 5e537fe88283c273482acc4824cb8123427a6692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 27 Oct 2010 11:36:06 +0200 Subject: Fix QT_BLITTER_RASTEROVERLAY and namespace error Reviewed-by: paul --- src/gui/image/qpixmap_blitter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 9a7ebe2..01a86f9 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -263,7 +263,8 @@ QRectF QBlittablePixmapData::clipAndTransformRect(const QRectF &rect) const return transformationRect; } -QT_END_NAMESPACE #endif //QT_BLITTER_RASTEROVERLAY +QT_END_NAMESPACE + #endif //QT_NO_BLITTABLE -- cgit v0.12 From c0330e4fdad175fa66c7bc2cf9afe0ca901857a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 28 Oct 2010 07:32:21 +0200 Subject: Compile fix for RVCT 4 --- src/gui/image/qpixmap_blitter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 01a86f9..f47b601 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -63,8 +63,8 @@ void QBlittablePixmapData::resize(int width, int height) h = height; is_null = (w <= 0 || h <= 0); } -extern int qt_defaultDpiX(); -extern int qt_defaultDpiY(); +Q_DECL_IMPORT extern int qt_defaultDpiX(); +Q_DECL_IMPORT extern int qt_defaultDpiY(); int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const { -- cgit v0.12 From 915c4d27a35d008d57a729d41543b1cfa033fcd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 28 Oct 2010 07:49:12 +0200 Subject: Fix qt_defaultDpi, but not use Q_DECL_IMPORT but Q_GUI_EXPORT --- src/gui/image/qpixmap_blitter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index f47b601..12455b1 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -63,8 +63,8 @@ void QBlittablePixmapData::resize(int width, int height) h = height; is_null = (w <= 0 || h <= 0); } -Q_DECL_IMPORT extern int qt_defaultDpiX(); -Q_DECL_IMPORT extern int qt_defaultDpiY(); +Q_GUI_EXPORT extern int qt_defaultDpiX(); +Q_GUI_EXPORT extern int qt_defaultDpiY(); int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const { -- cgit v0.12 From 9a26fba1b08a031b8053236feab989333ab60bfc Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 28 Oct 2010 13:31:00 +0200 Subject: Add missing QT_MODULE macros. --- src/corelib/global/qnaclunimplemented.h | 2 ++ src/gui/text/qplatformfontdatabase_qpa.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/corelib/global/qnaclunimplemented.h b/src/corelib/global/qnaclunimplemented.h index ba43915..71b3465 100644 --- a/src/corelib/global/qnaclunimplemented.h +++ b/src/corelib/global/qnaclunimplemented.h @@ -54,6 +54,8 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +QT_MODULE(Core) + extern "C" { void pthread_cleanup_push(void (*handler)(void *), void *arg); diff --git a/src/gui/text/qplatformfontdatabase_qpa.h b/src/gui/text/qplatformfontdatabase_qpa.h index adaa4cb..2b9ea63 100644 --- a/src/gui/text/qplatformfontdatabase_qpa.h +++ b/src/gui/text/qplatformfontdatabase_qpa.h @@ -12,6 +12,8 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +QT_MODULE(Gui) + class QWritingSystemsPrivate; class Q_GUI_EXPORT QSupportedWritingSystems -- cgit v0.12 From fee7ca62b6611f4a662fbb4541c83e280be08aba Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 28 Oct 2010 13:47:57 +0200 Subject: Fix typos found by the spellchecking autotest --- src/corelib/global/qnaclunimplemented.cpp | 2 +- src/plugins/generic/linuxinput/qlinuxinput.cpp | 2 +- src/plugins/platforms/eglconvenience/qeglconvenience.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/global/qnaclunimplemented.cpp b/src/corelib/global/qnaclunimplemented.cpp index 618ff3e..050bac6 100644 --- a/src/corelib/global/qnaclunimplemented.cpp +++ b/src/corelib/global/qnaclunimplemented.cpp @@ -51,7 +51,7 @@ There are two main classes of functions: - - Fuctions that are called but can have no effect: + - Functions that are called but can have no effect: For these we simply give an empty implementation - Functions that are referenced in the source code, but diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp index bd57fa3..c5bfd33 100644 --- a/src/plugins/generic/linuxinput/qlinuxinput.cpp +++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp @@ -445,7 +445,7 @@ QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(const QString &key, const // record the original mode so we can restore it again in the destructor. ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode); - // setting this tranlation mode is even needed in INPUT mode to prevent + // setting this translation mode is even needed in INPUT mode to prevent // the shell from also interpreting codes, if the process has a tty // attached: e.g. Ctrl+C wouldn't copy, but kill the application. ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW); diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp index b3a4c53..106041d 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp @@ -39,7 +39,7 @@ QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat & // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit, // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that // if the application sets the red/green/blue size to 5/6/5 on the QPlatformWindowFormat, - // they will probably get a 32-bit config, even when there's an RGB565 config avaliable. + // they will probably get a 32-bit config, even when there's an RGB565 config available. // Now normalize the values so -1 becomes 0 redSize = redSize > 0 ? redSize : 0; @@ -111,7 +111,7 @@ bool q_reduceConfigAttributes(QVector *configAttributes) // those with smaller (but faster) lower color depths. One // way around this is to set EGL_BUFFER_SIZE to 16, which // trumps the others. Of course, there may not be a 16-bit - // config avaliable, so it's the first restraint we remove. + // config available, so it's the first restraint we remove. i = configAttributes->indexOf(EGL_BUFFER_SIZE); if (i >= 0) { if (configAttributes->at(i+1) == 16) { -- cgit v0.12 From 8b7dad6c1290c3c5f9ce35ea9d13a4b7e6398572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 28 Oct 2010 14:34:55 +0200 Subject: Fix the license in files for Lighthouse --- mkspecs/qws/linux-nacl-g++/qplatformdefs.h | 78 +++++++++++----------- mkspecs/qws/macx-nacl-g++/qplatformdefs.h | 78 +++++++++++----------- .../global/qconfig-minimal-system-dependencies.h | 78 +++++++++++----------- src/corelib/global/qnaclunimplemented.cpp | 78 +++++++++++----------- src/corelib/global/qnaclunimplemented.h | 78 +++++++++++----------- src/gui/image/qpixmap_blitter.cpp | 41 ++++++++++++ src/gui/image/qpixmap_blitter_p.h | 41 ++++++++++++ .../kernel/qplatformeventloopintegration_qpa.cpp | 41 ++++++++++++ src/gui/kernel/qplatformeventloopintegration_qpa.h | 41 ++++++++++++ src/gui/painting/qblittable.cpp | 41 ++++++++++++ src/gui/painting/qblittable_p.h | 41 ++++++++++++ src/gui/painting/qpaintengine_blitter.cpp | 41 ++++++++++++ src/gui/painting/qpaintengine_blitter_p.h | 41 ++++++++++++ src/gui/text/qfontengine_qpa.cpp | 41 ++++++++++++ src/gui/text/qplatformfontdatabase_qpa.cpp | 41 ++++++++++++ src/gui/text/qplatformfontdatabase_qpa.h | 41 ++++++++++++ src/plugins/platforms/cocoa/cocoa.pro | 2 +- src/plugins/platforms/cocoa/qcocoaintegration.mm | 4 +- .../platforms/directfb/qdirectfbblitter.cpp | 41 ++++++++++++ src/plugins/platforms/directfb/qdirectfbblitter.h | 41 ++++++++++++ .../platforms/directfb/qdirectfbconvenience.cpp | 41 ++++++++++++ .../platforms/directfb/qdirectfbconvenience.h | 41 ++++++++++++ src/plugins/platforms/directfb/qdirectfbcursor.cpp | 41 ++++++++++++ src/plugins/platforms/directfb/qdirectfbcursor.h | 41 ++++++++++++ .../platforms/directfb/qdirectfbglcontext.cpp | 41 ++++++++++++ .../platforms/directfb/qdirectfbglcontext.h | 41 ++++++++++++ src/plugins/platforms/directfb/qdirectfbinput.cpp | 41 ++++++++++++ src/plugins/platforms/directfb/qdirectfbinput.h | 41 ++++++++++++ .../platforms/directfb/qdirectfbintegration.cpp | 2 +- .../platforms/directfb/qdirectfbintegration.h | 2 +- src/plugins/platforms/directfb/qdirectfbwindow.cpp | 5 +- src/plugins/platforms/directfb/qdirectfbwindow.h | 4 +- .../platforms/directfb/qdirectfbwindowsurface.cpp | 4 +- .../platforms/directfb/qdirectfbwindowsurface.h | 4 +- .../platforms/eglconvenience/qeglconvenience.cpp | 41 ++++++++++++ .../platforms/eglconvenience/qeglconvenience.h | 35 +++++----- .../eglconvenience/qeglplatformcontext.cpp | 32 ++++----- .../platforms/eglconvenience/qeglplatformcontext.h | 32 ++++----- src/plugins/platforms/eglfs/qeglfsscreen.cpp | 35 +++++----- src/plugins/platforms/eglfs/qeglfsscreen.h | 35 +++++----- src/plugins/platforms/eglfs/qeglfswindow.cpp | 35 +++++----- src/plugins/platforms/eglfs/qeglfswindow.h | 35 +++++----- .../platforms/eglfs/qeglfswindowsurface.cpp | 35 +++++----- src/plugins/platforms/eglfs/qeglfswindowsurface.h | 35 +++++----- src/plugins/platforms/fb_base/fb_base.cpp | 42 +++++++++++- src/plugins/platforms/fb_base/fb_base.h | 41 ++++++++++++ .../basicunix/qbasicunixfontdatabase.cpp | 41 ++++++++++++ .../basicunix/qbasicunixfontdatabase.h | 41 ++++++++++++ .../fontconfig/qfontconfigdatabase.cpp | 41 ++++++++++++ .../fontdatabases/fontconfig/qfontconfigdatabase.h | 41 ++++++++++++ .../genericunix/qgenericunixfontdatabase.h | 41 ++++++++++++ src/plugins/platforms/minimal/main.cpp | 3 +- .../platforms/minimal/qminimalintegration.cpp | 41 ++++++++++++ .../platforms/minimal/qminimalintegration.h | 3 +- .../platforms/minimal/qminimalwindowsurface.cpp | 5 +- .../platforms/minimal/qminimalwindowsurface.h | 4 +- src/plugins/platforms/openkode/main.cpp | 32 ++++----- .../platforms/openkode/openkodekeytranslator.h | 34 +++++----- .../openkode/qopenkodeeventloopintegration.cpp | 41 ++++++++++++ .../openkode/qopenkodeeventloopintegration.h | 41 ++++++++++++ .../platforms/openkode/qopenkodeintegration.cpp | 32 ++++----- .../platforms/openkode/qopenkodeintegration.h | 32 ++++----- src/plugins/platforms/openkode/qopenkodewindow.cpp | 35 +++++----- src/plugins/platforms/openkode/qopenkodewindow.h | 34 +++++----- src/plugins/platforms/openkode/shaders/frag.glslf | 41 ++++++++++++ src/plugins/platforms/openkode/shaders/vert.glslv | 41 ++++++++++++ 66 files changed, 1869 insertions(+), 466 deletions(-) diff --git a/mkspecs/qws/linux-nacl-g++/qplatformdefs.h b/mkspecs/qws/linux-nacl-g++/qplatformdefs.h index a670ee5..01b26d9 100644 --- a/mkspecs/qws/linux-nacl-g++/qplatformdefs.h +++ b/mkspecs/qws/linux-nacl-g++/qplatformdefs.h @@ -1,43 +1,43 @@ /**************************************************************************** - ** - ** 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 QtCore 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$ - ** - ****************************************************************************/ +** +** 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 qmake spec 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 QPLATFORMDEFS_H #define QPLATFORMDEFS_H diff --git a/mkspecs/qws/macx-nacl-g++/qplatformdefs.h b/mkspecs/qws/macx-nacl-g++/qplatformdefs.h index a670ee5..01b26d9 100644 --- a/mkspecs/qws/macx-nacl-g++/qplatformdefs.h +++ b/mkspecs/qws/macx-nacl-g++/qplatformdefs.h @@ -1,43 +1,43 @@ /**************************************************************************** - ** - ** 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 QtCore 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$ - ** - ****************************************************************************/ +** +** 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 qmake spec 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 QPLATFORMDEFS_H #define QPLATFORMDEFS_H diff --git a/src/corelib/global/qconfig-minimal-system-dependencies.h b/src/corelib/global/qconfig-minimal-system-dependencies.h index c7e3633..63319b9 100644 --- a/src/corelib/global/qconfig-minimal-system-dependencies.h +++ b/src/corelib/global/qconfig-minimal-system-dependencies.h @@ -1,43 +1,43 @@ /**************************************************************************** - ** - ** 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 QtCore 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$ - ** - ****************************************************************************/ +** +** 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 QtCore 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$ +** +****************************************************************************/ #define QT_FONTS_ARE_RESOURCES diff --git a/src/corelib/global/qnaclunimplemented.cpp b/src/corelib/global/qnaclunimplemented.cpp index 050bac6..1a89b8df 100644 --- a/src/corelib/global/qnaclunimplemented.cpp +++ b/src/corelib/global/qnaclunimplemented.cpp @@ -1,43 +1,43 @@ /**************************************************************************** - ** - ** 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 QtCore 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$ - ** - ****************************************************************************/ +** +** 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 QtCore 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 "qnaclunimplemented.h" #include diff --git a/src/corelib/global/qnaclunimplemented.h b/src/corelib/global/qnaclunimplemented.h index 71b3465..2d3d426 100644 --- a/src/corelib/global/qnaclunimplemented.h +++ b/src/corelib/global/qnaclunimplemented.h @@ -1,43 +1,43 @@ /**************************************************************************** - ** - ** 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 QtCore 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$ - ** - ****************************************************************************/ +** +** 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 QtCore 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 QNACLUNIMPLEMENTED_H #define QNACLUNIMPLEMENTED_H diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 12455b1..e8a7b89 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 "qpixmap_blitter_p.h" #include diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index e404199..55b5618 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 QPIXMAP_BLITTER_P_H #define QPIXMAP_BLITTER_P_H diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.cpp b/src/gui/kernel/qplatformeventloopintegration_qpa.cpp index e69de29..8bdba5e 100644 --- a/src/gui/kernel/qplatformeventloopintegration_qpa.cpp +++ b/src/gui/kernel/qplatformeventloopintegration_qpa.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.h b/src/gui/kernel/qplatformeventloopintegration_qpa.h index 7343566..a06fecf 100644 --- a/src/gui/kernel/qplatformeventloopintegration_qpa.h +++ b/src/gui/kernel/qplatformeventloopintegration_qpa.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 QPLATFORMEVENTLOOPINTEGRATION_QPA_H #define QPLATFORMEVENTLOOPINTEGRATION_QPA_H diff --git a/src/gui/painting/qblittable.cpp b/src/gui/painting/qblittable.cpp index 0b2bd64..f4b84a9 100644 --- a/src/gui/painting/qblittable.cpp +++ b/src/gui/painting/qblittable.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 "qblittable_p.h" #ifndef QT_NO_BLITTABLE diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h index 71e80af..cb56cb2 100644 --- a/src/gui/painting/qblittable_p.h +++ b/src/gui/painting/qblittable_p.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 QBLITTABLE_P_H #define QBLITTABLE_P_H diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index f2e6cdd..2e8d9dd 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 "private/qpaintengine_blitter_p.h" #include "private/qblittable_p.h" diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index 3a2fce5..c8aa536 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 QPAINTENGINE_BLITTER_P_H #define QPAINTENGINE_BLITTER_P_H diff --git a/src/gui/text/qfontengine_qpa.cpp b/src/gui/text/qfontengine_qpa.cpp index 910bbfe..cccbc92 100644 --- a/src/gui/text/qfontengine_qpa.cpp +++ b/src/gui/text/qfontengine_qpa.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 "qfontengine_qpa_p.h" #include diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp index 26f4faa..370c921 100644 --- a/src/gui/text/qplatformfontdatabase_qpa.cpp +++ b/src/gui/text/qplatformfontdatabase_qpa.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 "qplatformfontdatabase_qpa.h" #include #include diff --git a/src/gui/text/qplatformfontdatabase_qpa.h b/src/gui/text/qplatformfontdatabase_qpa.h index 2b9ea63..75b0a18 100644 --- a/src/gui/text/qplatformfontdatabase_qpa.h +++ b/src/gui/text/qplatformfontdatabase_qpa.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 QPLATFORMFONTDATABASE_QPA_H #define QPLATFORMFONTDATABASE_QPA_H diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 7701b9c..1633ee4 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -23,7 +23,7 @@ OBJECTIVE_HEADERS = qcocoaintegration.h \ LIBS += -lz LIBS += -framework cocoa -include(../fontdatabases/genericunix/genericunix.pri) +include(../fontdatabases/coretext/coretext.pri) target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index baf5a73..79d5f51 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -45,7 +45,7 @@ #include "qcocoawindowsurface.h" #include "qcocoaeventloopintegration.h" -#include "qgenericunixfontdatabase.h" +#include "qcoretextfontdatabase.h" #include @@ -74,7 +74,7 @@ QCocoaScreen::~QCocoaScreen() } QCocoaIntegration::QCocoaIntegration() - : mFontDb(new QGenericUnixFontDatabase()) + : mFontDb(new QCoreTextFontDatabase()) { mPool = new QCocoaAutoReleasePool; diff --git a/src/plugins/platforms/directfb/qdirectfbblitter.cpp b/src/plugins/platforms/directfb/qdirectfbblitter.cpp index 15bb18b..d379b65 100644 --- a/src/plugins/platforms/directfb/qdirectfbblitter.cpp +++ b/src/plugins/platforms/directfb/qdirectfbblitter.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 "qdirectfbblitter.h" #include "qdirectfbconvenience.h" diff --git a/src/plugins/platforms/directfb/qdirectfbblitter.h b/src/plugins/platforms/directfb/qdirectfbblitter.h index 2a39912..1e874ba 100644 --- a/src/plugins/platforms/directfb/qdirectfbblitter.h +++ b/src/plugins/platforms/directfb/qdirectfbblitter.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 QDIRECTFBBLITTER_H #define QDIRECTFBBLITTER_H diff --git a/src/plugins/platforms/directfb/qdirectfbconvenience.cpp b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp index adf9687..91a1b3a 100644 --- a/src/plugins/platforms/directfb/qdirectfbconvenience.cpp +++ b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 "qdirectfbconvenience.h" #include "qdirectfbblitter.h" diff --git a/src/plugins/platforms/directfb/qdirectfbconvenience.h b/src/plugins/platforms/directfb/qdirectfbconvenience.h index ab5b3de..3669159 100644 --- a/src/plugins/platforms/directfb/qdirectfbconvenience.h +++ b/src/plugins/platforms/directfb/qdirectfbconvenience.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 QDIRECTFBCONVENIENCE_H #define QDIRECTFBCONVENIENCE_H diff --git a/src/plugins/platforms/directfb/qdirectfbcursor.cpp b/src/plugins/platforms/directfb/qdirectfbcursor.cpp index f2c9f35..51502f8 100644 --- a/src/plugins/platforms/directfb/qdirectfbcursor.cpp +++ b/src/plugins/platforms/directfb/qdirectfbcursor.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 "qdirectfbcursor.h" #include "qdirectfbconvenience.h" diff --git a/src/plugins/platforms/directfb/qdirectfbcursor.h b/src/plugins/platforms/directfb/qdirectfbcursor.h index 6aecb16..ea8b7b0 100644 --- a/src/plugins/platforms/directfb/qdirectfbcursor.h +++ b/src/plugins/platforms/directfb/qdirectfbcursor.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 QDIRECTFBCURSOR_H #define QDIRECTFBCURSOR_H diff --git a/src/plugins/platforms/directfb/qdirectfbglcontext.cpp b/src/plugins/platforms/directfb/qdirectfbglcontext.cpp index fe96efe..033ff1e 100644 --- a/src/plugins/platforms/directfb/qdirectfbglcontext.cpp +++ b/src/plugins/platforms/directfb/qdirectfbglcontext.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 "qdirectfbglcontext.h" #include diff --git a/src/plugins/platforms/directfb/qdirectfbglcontext.h b/src/plugins/platforms/directfb/qdirectfbglcontext.h index 037587e..1785666 100644 --- a/src/plugins/platforms/directfb/qdirectfbglcontext.h +++ b/src/plugins/platforms/directfb/qdirectfbglcontext.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 QDIRECTFBGLCONTEXT_H #define QDIRECTFBGLCONTEXT_H diff --git a/src/plugins/platforms/directfb/qdirectfbinput.cpp b/src/plugins/platforms/directfb/qdirectfbinput.cpp index 7101b7b..9d2a8a8 100644 --- a/src/plugins/platforms/directfb/qdirectfbinput.cpp +++ b/src/plugins/platforms/directfb/qdirectfbinput.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 "qdirectfbinput.h" #include "qdirectfbconvenience.h" diff --git a/src/plugins/platforms/directfb/qdirectfbinput.h b/src/plugins/platforms/directfb/qdirectfbinput.h index 0b2e7ed..bca155f 100644 --- a/src/plugins/platforms/directfb/qdirectfbinput.h +++ b/src/plugins/platforms/directfb/qdirectfbinput.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 QDIRECTFBINPUT_H #define QDIRECTFBINPUT_H diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp index 1b3e035..8639bdb 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp +++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.h b/src/plugins/platforms/directfb/qdirectfbintegration.h index d2d8367..965bdd2 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.h +++ b/src/plugins/platforms/directfb/qdirectfbintegration.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.cpp b/src/plugins/platforms/directfb/qdirectfbwindow.cpp index 74e7a72..1cd23ad 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindow.cpp +++ b/src/plugins/platforms/directfb/qdirectfbwindow.cpp @@ -1,10 +1,10 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 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,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "qdirectfbwindow.h" #include "qdirectfbinput.h" #include "qdirectfbglcontext.h" diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.h b/src/plugins/platforms/directfb/qdirectfbwindow.h index eaf5173..19491c5 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindow.h +++ b/src/plugins/platforms/directfb/qdirectfbwindow.h @@ -1,10 +1,10 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 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/directfb/qdirectfbwindowsurface.cpp b/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp index 2aef70d..b1a8899 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp @@ -1,10 +1,10 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 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/directfb/qdirectfbwindowsurface.h b/src/plugins/platforms/directfb/qdirectfbwindowsurface.h index d48f534..aaa74d4 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/platforms/directfb/qdirectfbwindowsurface.h @@ -1,10 +1,10 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 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/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp index 106041d..b203fe8 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 "qeglconvenience.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h index 484894b..604262b 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.h +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h @@ -1,16 +1,17 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QtOpenVG module of the Qt Toolkit. +** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,24 +21,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef QEGLCONVENIENCE_H #define QEGLCONVENIENCE_H diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp index 04720b5..ae3b539 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 plugins of the Qt Toolkit. @@ -9,8 +10,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,21 +21,20 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h index b0cbbe0..ae1a891 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h @@ -1,6 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 plugins of the Qt Toolkit. @@ -9,8 +10,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,21 +21,20 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index 2d23cca..9a40b86 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -1,16 +1,17 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QtOpenVG module of the Qt Toolkit. +** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,24 +21,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "qeglfsscreen.h" #include "../eglconvenience/qeglconvenience.h" diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h index f68ab14..9ed1b04 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.h +++ b/src/plugins/platforms/eglfs/qeglfsscreen.h @@ -1,16 +1,17 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QtOpenVG module of the Qt Toolkit. +** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,24 +21,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef QEGLSCREEN_H #define QEGLSCREEN_H diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index 86cc98b..d0e15d3 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -1,16 +1,17 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QtOpenVG module of the Qt Toolkit. +** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,24 +21,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "qeglfswindow.h" #include diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h index 0c3bc84..43f185b 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.h +++ b/src/plugins/platforms/eglfs/qeglfswindow.h @@ -1,16 +1,17 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QtOpenVG module of the Qt Toolkit. +** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,24 +21,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef QEGLWINDOW_H #define QEGLWINDOW_H diff --git a/src/plugins/platforms/eglfs/qeglfswindowsurface.cpp b/src/plugins/platforms/eglfs/qeglfswindowsurface.cpp index a613dda..fcea4d3 100644 --- a/src/plugins/platforms/eglfs/qeglfswindowsurface.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindowsurface.cpp @@ -1,16 +1,17 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QtOpenVG module of the Qt Toolkit. +** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,24 +21,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "qeglfswindowsurface.h" #include diff --git a/src/plugins/platforms/eglfs/qeglfswindowsurface.h b/src/plugins/platforms/eglfs/qeglfswindowsurface.h index 571b9bd..f8aca40 100644 --- a/src/plugins/platforms/eglfs/qeglfswindowsurface.h +++ b/src/plugins/platforms/eglfs/qeglfswindowsurface.h @@ -1,16 +1,17 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QtOpenVG module of the Qt Toolkit. +** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,24 +21,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef QEGLWINDOWSURFACE_H #define QEGLWINDOWSURFACE_H diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp index 48488d4..b000a18 100644 --- a/src/plugins/platforms/fb_base/fb_base.cpp +++ b/src/plugins/platforms/fb_base/fb_base.cpp @@ -1,5 +1,45 @@ -#include "fb_base.h" +/**************************************************************************** +** +** 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 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 "fb_base.h" #include #include #include diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h index e52455a..45a5663 100644 --- a/src/plugins/platforms/fb_base/fb_base.h +++ b/src/plugins/platforms/fb_base/fb_base.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 QLIGHTHOUSEGRAPHICSSCREEN_H #define QLIGHTHOUSEGRAPHICSSCREEN_H diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp index 5b6f69a..4634477 100644 --- a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp +++ b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 "qbasicunixfontdatabase.h" #include diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h index 95015df..0af118d 100644 --- a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h +++ b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 QBASICUNIXFONTDATABASE_H #define QBASICUNIXFONTDATABASE_H diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 85515ed..c9d1b74 100644 --- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 "qfontconfigdatabase.h" #include diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h index 5945b6e..33382dc 100644 --- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h +++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 QFONTCONFIGDATABASE_H #define QFONTCONFIGDATABASE_H diff --git a/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h b/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h index ec083f8..327c8f5 100644 --- a/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h +++ b/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 QGENERICUNIXFONTDATABASE_H #define QGENERICUNIXFONTDATABASE_H diff --git a/src/plugins/platforms/minimal/main.cpp b/src/plugins/platforms/minimal/main.cpp index a4d646d..82c15c2 100644 --- a/src/plugins/platforms/minimal/main.cpp +++ b/src/plugins/platforms/minimal/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -39,6 +39,7 @@ ** ****************************************************************************/ + #include #include "qminimalintegration.h" diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index e947bf1..c90e92e 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 "qminimalintegration.h" #include "qminimalwindowsurface.h" diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h index a2f7449..95b952e 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.h +++ b/src/plugins/platforms/minimal/qminimalintegration.h @@ -1,7 +1,6 @@ - /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/plugins/platforms/minimal/qminimalwindowsurface.cpp b/src/plugins/platforms/minimal/qminimalwindowsurface.cpp index ad5997e..acf0e6e 100644 --- a/src/plugins/platforms/minimal/qminimalwindowsurface.cpp +++ b/src/plugins/platforms/minimal/qminimalwindowsurface.cpp @@ -1,10 +1,10 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 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,6 +39,7 @@ ** ****************************************************************************/ + #include "qminimalwindowsurface.h" #include #include diff --git a/src/plugins/platforms/minimal/qminimalwindowsurface.h b/src/plugins/platforms/minimal/qminimalwindowsurface.h index 96f989d..98b26f6 100644 --- a/src/plugins/platforms/minimal/qminimalwindowsurface.h +++ b/src/plugins/platforms/minimal/qminimalwindowsurface.h @@ -1,10 +1,10 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 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/openkode/main.cpp b/src/plugins/platforms/openkode/main.cpp index b60ae1b..527747e 100644 --- a/src/plugins/platforms/openkode/main.cpp +++ b/src/plugins/platforms/openkode/main.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 plugins of the Qt Toolkit. @@ -9,8 +10,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,21 +21,20 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/platforms/openkode/openkodekeytranslator.h b/src/plugins/platforms/openkode/openkodekeytranslator.h index e0ba5c1..0070edc 100644 --- a/src/plugins/platforms/openkode/openkodekeytranslator.h +++ b/src/plugins/platforms/openkode/openkodekeytranslator.h @@ -1,16 +1,17 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QtOpenVG module of the Qt Toolkit. +** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,21 +21,20 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp index bc92d0e..73d874c 100644 --- a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 "qopenkodeeventloopintegration.h" #include diff --git a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h index 03f800c..61bd444 100644 --- a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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 QOPENKODEEVENTLOOPINTEGRATION_H #define QOPENKODEEVENTLOOPINTEGRATION_H diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index 0c29a33..60be897 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 plugins of the Qt Toolkit. @@ -9,8 +10,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,21 +21,20 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h index 907b7e2..a067491 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeintegration.h @@ -1,6 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 plugins of the Qt Toolkit. @@ -9,8 +10,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,21 +21,20 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index fadf564..32517c6 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -1,16 +1,17 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QtOpenVG module of the Qt Toolkit. +** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,24 +21,24 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "qopenkodewindow.h" #include "qopenkodeintegration.h" #include "../eglconvenience/qeglplatformcontext.h" diff --git a/src/plugins/platforms/openkode/qopenkodewindow.h b/src/plugins/platforms/openkode/qopenkodewindow.h index 27d33d6..4992807 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.h +++ b/src/plugins/platforms/openkode/qopenkodewindow.h @@ -1,16 +1,17 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 QtOpenVG module of the Qt Toolkit. +** 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. +** 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 @@ -20,21 +21,20 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. +** 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. +** +** +** +** +** +** ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/plugins/platforms/openkode/shaders/frag.glslf b/src/plugins/platforms/openkode/shaders/frag.glslf index ed360fe..c768437 100644 --- a/src/plugins/platforms/openkode/shaders/frag.glslf +++ b/src/plugins/platforms/openkode/shaders/frag.glslf @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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$ +** +****************************************************************************/ + uniform sampler2D tex_samp; varying vec2 texcoord_var; diff --git a/src/plugins/platforms/openkode/shaders/vert.glslv b/src/plugins/platforms/openkode/shaders/vert.glslv index 57b5866..8a64f4d 100644 --- a/src/plugins/platforms/openkode/shaders/vert.glslv +++ b/src/plugins/platforms/openkode/shaders/vert.glslv @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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 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$ +** +****************************************************************************/ + uniform vec2 window; // window size // Per-vertex attributes] -- cgit v0.12